Minor change.
This commit is contained in:
parent
1a145f701e
commit
b66ba4d56c
|
@ -61,7 +61,7 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
backgroundColor: Theme.of(context).primaryColor,
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
backgroundColor: context.primaryColor,
|
||||
backgroundColor: context.accentColor.withAlpha(70),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Selector<AudioPlayerNotifier, Tuple3<Playlist, bool, bool>>(
|
||||
|
@ -74,7 +74,9 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
Container(
|
||||
color: context.accentColor.withAlpha(70),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 2,
|
||||
|
@ -112,13 +114,14 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
? FutureBuilder<double>(
|
||||
future: _getListenTime(),
|
||||
initialData: 0.0,
|
||||
builder: (context, snapshot) => RichText(
|
||||
builder: (context, snapshot) =>
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
text: 'Today ',
|
||||
style: GoogleFonts.cairo(
|
||||
textStyle: TextStyle(
|
||||
color:
|
||||
Theme.of(context).accentColor,
|
||||
color: Theme.of(context)
|
||||
.accentColor,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
|
@ -225,13 +228,14 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
// )
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
CircleAvatar(
|
||||
radius: 15,
|
||||
//backgroundColor: _c.withOpacity(0.5),
|
||||
backgroundImage: FileImage(
|
||||
File("${episodes.first.imagePath}")),
|
||||
backgroundImage: FileImage(File(
|
||||
"${episodes.first.imagePath}")),
|
||||
),
|
||||
Container(
|
||||
width: 150,
|
||||
|
@ -244,8 +248,8 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 15),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 15),
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 15,
|
||||
|
@ -266,14 +270,11 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
),
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
height: 3,
|
||||
),
|
||||
Expanded(
|
||||
child: _loadHistory
|
||||
? HistoryList()
|
||||
: ReorderableListView(
|
||||
// scrollController: _playlistController,
|
||||
onReorder: (oldIndex, newIndex) {
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
|
@ -330,8 +331,8 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
Widget _episodeTag(String text, Color color) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: color, borderRadius: BorderRadius.all(Radius.circular(15.0))),
|
||||
height: 23.0,
|
||||
color: color, borderRadius: BorderRadius.circular(15.0)),
|
||||
height: 25.0,
|
||||
margin: EdgeInsets.only(right: 10.0),
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0),
|
||||
alignment: Alignment.center,
|
||||
|
@ -355,7 +356,7 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
return AnimatedContainer(
|
||||
duration: Duration(milliseconds: 300),
|
||||
alignment: Alignment.center,
|
||||
height: _delete ? 0 : 95.0,
|
||||
height: _delete ? 0 : 90.0,
|
||||
child: _delete
|
||||
? Container(
|
||||
color: Colors.transparent,
|
||||
|
@ -391,8 +392,8 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
),
|
||||
],
|
||||
),
|
||||
height: 50,
|
||||
color: Theme.of(context).accentColor,
|
||||
height: 30,
|
||||
color: context.accentColor,
|
||||
),
|
||||
onDismissed: (direction) async {
|
||||
setState(() {
|
||||
|
@ -417,11 +418,16 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
}),
|
||||
));
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 90.0,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: ListTile(
|
||||
title: Container(
|
||||
padding: EdgeInsets.only(top: 10.0, bottom: 5.0),
|
||||
padding: EdgeInsets.only(top: 5.0, bottom: 5.0),
|
||||
child: Text(
|
||||
widget.episode.title,
|
||||
maxLines: 1,
|
||||
|
@ -442,42 +448,45 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
],
|
||||
),
|
||||
subtitle: Container(
|
||||
padding: EdgeInsets.only(top: 5, bottom: 10),
|
||||
padding: EdgeInsets.only(top: 5, bottom: 5),
|
||||
height: 35,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
(widget.episode.explicit == 1)
|
||||
? Container(
|
||||
if (widget.episode.explicit == 1)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red[800],
|
||||
shape: BoxShape.circle),
|
||||
height: 20.0,
|
||||
width: 20.0,
|
||||
height: 25.0,
|
||||
width: 25.0,
|
||||
margin: EdgeInsets.only(right: 10.0),
|
||||
alignment: Alignment.center,
|
||||
child: Text('E',
|
||||
style: TextStyle(color: Colors.white)))
|
||||
: Center(),
|
||||
widget.episode.duration != 0
|
||||
? _episodeTag(
|
||||
s.minsCount(widget.episode.duration ~/ 60),
|
||||
Colors.cyan[300])
|
||||
: Center(),
|
||||
widget.episode.enclosureLength != null
|
||||
? _episodeTag(
|
||||
style:
|
||||
TextStyle(color: Colors.white))),
|
||||
if (widget.episode.duration != 0)
|
||||
_episodeTag(
|
||||
s.minsCount(
|
||||
widget.episode.duration ~/ 60),
|
||||
Colors.cyan[300]),
|
||||
if (widget.episode.enclosureLength != null)
|
||||
_episodeTag(
|
||||
'${(widget.episode.enclosureLength) ~/ 1000000}MB',
|
||||
Colors.lightBlue[300])
|
||||
: Center(),
|
||||
Colors.lightBlue[300]),
|
||||
],
|
||||
),
|
||||
),
|
||||
//trailing: Icon(Icons.menu),
|
||||
),
|
||||
// Divider(
|
||||
// height: 2,
|
||||
// ),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -503,12 +512,12 @@ class _HistoryListState extends State<HistoryList> {
|
|||
_loadMoreData() async {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_top = _top + 100;
|
||||
_top = _top + 20;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
int _top = 100;
|
||||
int _top = 20;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -538,13 +547,20 @@ class _HistoryListState extends State<HistoryList> {
|
|||
(Theme.of(context).brightness == Brightness.light)
|
||||
? episode.primaryColor.colorizedark()
|
||||
: episode.primaryColor.colorizeLight();
|
||||
return ListTile(
|
||||
return SizedBox(
|
||||
height: 90.0,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: ListTile(
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: 40, right: 20, top: 10),
|
||||
EdgeInsets.only(left: 40, right: 20),
|
||||
onTap: () => audio.episodeLoad(episode),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: c.withOpacity(0.5),
|
||||
backgroundImage: FileImage(File(episode.imagePath)),
|
||||
backgroundImage:
|
||||
FileImage(File(episode.imagePath)),
|
||||
),
|
||||
title: Text(
|
||||
snapshot.data[index].title,
|
||||
|
@ -553,13 +569,45 @@ class _HistoryListState extends State<HistoryList> {
|
|||
),
|
||||
subtitle: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
date.toDate(context),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
Selector<AudioPlayerNotifier,
|
||||
Tuple2<List<EpisodeBrief>, bool>>(
|
||||
selector: (_, audio) => Tuple2(
|
||||
audio.queue.playlist,
|
||||
audio.queueUpdate),
|
||||
builder: (_, data, __) {
|
||||
return data.item1.contains(episode)
|
||||
? IconButton(
|
||||
icon: Icon(
|
||||
Icons
|
||||
.playlist_add_check,
|
||||
color: context
|
||||
.accentColor),
|
||||
onPressed: () async {
|
||||
audio.delFromPlaylist(
|
||||
episode);
|
||||
Fluttertoast.showToast(
|
||||
msg: s
|
||||
.toastRemovePlaylist,
|
||||
gravity:
|
||||
ToastGravity.BOTTOM,
|
||||
);
|
||||
})
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.playlist_add,
|
||||
color:
|
||||
Colors.grey[700]),
|
||||
onPressed: () async {
|
||||
audio.addToPlaylist(
|
||||
episode);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastAddPlaylist,
|
||||
gravity:
|
||||
ToastGravity.BOTTOM,
|
||||
);
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
if (seekValue < 0.9)
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
|
@ -567,54 +615,43 @@ class _HistoryListState extends State<HistoryList> {
|
|||
onTap: () async {
|
||||
audio.episodeLoad(episode,
|
||||
startPosition:
|
||||
(seconds * 1000).toInt());
|
||||
(seconds * 1000)
|
||||
.toInt());
|
||||
},
|
||||
child: Container(
|
||||
height: 20,
|
||||
height: 25,
|
||||
alignment: Alignment.center,
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 5),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10.0)),
|
||||
borderRadius:
|
||||
BorderRadius.all(
|
||||
Radius.circular(
|
||||
20.0)),
|
||||
color: context.accentColor,
|
||||
),
|
||||
child: Text(
|
||||
seconds.toTime,
|
||||
style: TextStyle(color: Colors.white),
|
||||
s.timeLastPlayed(
|
||||
seconds.toTime),
|
||||
style: TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5),
|
||||
Selector<AudioPlayerNotifier,
|
||||
Tuple2<List<EpisodeBrief>, bool>>(
|
||||
selector: (_, audio) => Tuple2(
|
||||
audio.queue.playlist, audio.queueUpdate),
|
||||
builder: (_, data, __) {
|
||||
return data.item1.contains(episode)
|
||||
? IconButton(
|
||||
icon: Icon(Icons.playlist_add_check,
|
||||
color: context.accentColor),
|
||||
onPressed: () async {
|
||||
audio.delFromPlaylist(episode);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastRemovePlaylist,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
})
|
||||
: IconButton(
|
||||
icon: Icon(Icons.playlist_add,
|
||||
color: Colors.grey[700]),
|
||||
onPressed: () async {
|
||||
audio.addToPlaylist(episode);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastAddPlaylist,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
});
|
||||
},
|
||||
Spacer(),
|
||||
Text(
|
||||
date.toDate(context),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(height: 2)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -586,7 +586,7 @@ class DBHelper {
|
|||
}
|
||||
return 0;
|
||||
} catch (e) {
|
||||
developer.log(e, name: 'Update podcast error');
|
||||
developer.log(e.toString(), name: 'Update podcast error');
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,12 @@ import '../state/audio_state.dart';
|
|||
import '../state/download_state.dart';
|
||||
import '../type/episodebrief.dart';
|
||||
import '../type/fireside_data.dart';
|
||||
import '../type/play_histroy.dart';
|
||||
import '../type/podcastlocal.dart';
|
||||
import '../util/audiopanel.dart';
|
||||
import '../util/custom_widget.dart';
|
||||
import '../util/episodegrid.dart';
|
||||
import '../util/extension_helper.dart';
|
||||
import '../util/general_dialog.dart';
|
||||
import 'podcast_settings.dart';
|
||||
|
||||
class PodcastDetail extends StatefulWidget {
|
||||
PodcastDetail({Key key, @required this.podcastLocal, this.hide = false})
|
||||
|
@ -93,10 +92,12 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
Future _updateRssItem(BuildContext context, PodcastLocal podcastLocal) async {
|
||||
var dbHelper = DBHelper();
|
||||
final result = await dbHelper.updatePodcastRss(podcastLocal);
|
||||
if (result >= 0) {
|
||||
Fluttertoast.showToast(
|
||||
msg: context.s.updateEpisodesCount(result),
|
||||
gravity: ToastGravity.TOP,
|
||||
);
|
||||
}
|
||||
if (result > 0) {
|
||||
var autoDownload = await dbHelper.getAutoDownload(podcastLocal.id);
|
||||
if (autoDownload) {
|
||||
|
@ -163,19 +164,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
return index;
|
||||
}
|
||||
|
||||
_markListened(String podcastId) async {
|
||||
var dbHelper = DBHelper();
|
||||
var episodes = await dbHelper.getRssItem(podcastId, -1, reverse: true);
|
||||
for (var episode in episodes) {
|
||||
var marked = await dbHelper.checkMarked(episode);
|
||||
if (!marked) {
|
||||
final history = PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
|
||||
await dbHelper.saveHistory(history);
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget podcastInfo(BuildContext context) {
|
||||
return Container(
|
||||
height: 170,
|
||||
|
@ -308,33 +296,6 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
);
|
||||
}
|
||||
|
||||
_confirmMarkListened(BuildContext context) => generalDialog(
|
||||
context,
|
||||
title: Text(context.s.markConfirm),
|
||||
content: Text(context.s.markConfirmContent),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
context.s.cancel,
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
await _markListened(widget.podcastLocal.id);
|
||||
},
|
||||
child: Text(
|
||||
context.s.confirm,
|
||||
style: TextStyle(color: context.accentColor),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
_customPopupMenu(
|
||||
{Widget child,
|
||||
String tooltip,
|
||||
|
@ -370,7 +331,14 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
widget.podcastLocal.rssUrl.launchUrl;
|
||||
break;
|
||||
case 2:
|
||||
_confirmMarkListened(context);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
fullscreenDialog: true,
|
||||
builder: (context) =>
|
||||
PodcastSetting(podcastLocal: widget.podcastLocal),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -398,7 +366,7 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
child: Row(
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.rss_feed,
|
||||
LineIcons.rss_square_solid,
|
||||
color: context.textColor,
|
||||
),
|
||||
Padding(
|
||||
|
@ -412,23 +380,15 @@ class _PodcastDetailState extends State<PodcastDetail> {
|
|||
PopupMenuItem(
|
||||
value: 2,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 10),
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: 25,
|
||||
height: 25,
|
||||
child: CustomPaint(
|
||||
painter:
|
||||
ListenedAllPainter(context.textColor, stroke: 2)),
|
||||
),
|
||||
Icon(LineIcons.cog_solid, color: context.textColor),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
),
|
||||
Text(
|
||||
s.menuMarkAllListened,
|
||||
),
|
||||
Text(s.settings),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -80,14 +80,14 @@ class _PodcastCardState extends State<PodcastCard>
|
|||
int _seconds;
|
||||
int _skipSeconds;
|
||||
|
||||
Future<int> getSkipSecond(String id) async {
|
||||
Future<int> _getSkipSecond(String id) async {
|
||||
var dbHelper = DBHelper();
|
||||
var seconds = await dbHelper.getSkipSeconds(id);
|
||||
_skipSeconds = seconds;
|
||||
return seconds;
|
||||
}
|
||||
|
||||
saveSkipSeconds(String id, int seconds) async {
|
||||
_saveSkipSeconds(String id, int seconds) async {
|
||||
var dbHelper = DBHelper();
|
||||
await dbHelper.saveSkipSeconds(id, seconds);
|
||||
}
|
||||
|
@ -119,11 +119,6 @@ class _PodcastCardState extends State<PodcastCard>
|
|||
}
|
||||
}
|
||||
|
||||
String _stringForSeconds(double seconds) {
|
||||
if (seconds == null) return null;
|
||||
return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
@ -389,7 +384,8 @@ class _PodcastCardState extends State<PodcastCard>
|
|||
},
|
||||
),
|
||||
FutureBuilder<int>(
|
||||
future: getSkipSecond(widget.podcastLocal.id),
|
||||
future:
|
||||
_getSkipSecond(widget.podcastLocal.id),
|
||||
initialData: 0,
|
||||
builder: (context, snapshot) {
|
||||
return _buttonOnMenu(
|
||||
|
@ -398,7 +394,7 @@ class _PodcastCardState extends State<PodcastCard>
|
|||
size: _value == 0 ? 1 : 20 * (_value),
|
||||
),
|
||||
tooltip:
|
||||
'Skip${snapshot.data == 0 ? '' : _stringForSeconds(snapshot.data.toDouble())}',
|
||||
'Skip${snapshot.data == 0 ? '' : snapshot.data.toTime}',
|
||||
onTap: () {
|
||||
generalDialog(
|
||||
context,
|
||||
|
@ -425,7 +421,7 @@ class _PodcastCardState extends State<PodcastCard>
|
|||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
saveSkipSeconds(
|
||||
_saveSkipSeconds(
|
||||
widget.podcastLocal.id,
|
||||
_seconds);
|
||||
},
|
||||
|
|
|
@ -423,7 +423,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||
}
|
||||
|
||||
/// Reset error state.
|
||||
if (_audioState != AudioProcessingState.error && _playing) {
|
||||
if (_audioState != AudioProcessingState.error) {
|
||||
_remoteErrorMessage = null;
|
||||
}
|
||||
notifyListeners();
|
||||
|
|
|
@ -58,7 +58,16 @@ class PodcastGroup {
|
|||
Future getPodcasts() async {
|
||||
var dbHelper = DBHelper();
|
||||
if (podcastList != []) {
|
||||
try {
|
||||
_podcasts = await dbHelper.getPodcastLocal(podcastList);
|
||||
} catch (e) {
|
||||
await Future.delayed(Duration(milliseconds: 200));
|
||||
try {
|
||||
_podcasts = await dbHelper.getPodcastLocal(podcastList);
|
||||
} catch (e) {
|
||||
developer.log(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue