From 074f31e7cda7db132a5508d2eb0ef29a79a974c3 Mon Sep 17 00:00:00 2001 From: stonega Date: Thu, 29 Oct 2020 21:05:58 +0800 Subject: [PATCH] Add play next in popupmenu. --- lib/generated/intl/messages_en.dart | 2 + lib/generated/intl/messages_es.dart | 2 + lib/generated/intl/messages_fr.dart | 2 + lib/generated/intl/messages_it.dart | 2 + lib/generated/intl/messages_pt.dart | 2 + lib/generated/intl/messages_zh-Hans.dart | 2 + lib/generated/l10n.dart | 20 ++ lib/home/home_groups.dart | 260 +++++++++++---------- lib/l10n/intl_en.arb | 8 + lib/l10n/intl_es.arb | 8 + lib/l10n/intl_fr.arb | 8 + lib/l10n/intl_it.arb | 8 + lib/l10n/intl_pt.arb | 8 + lib/l10n/intl_zh_Hans.arb | 8 + lib/local_storage/key_value_storage.dart | 3 +- lib/settings/popup_menu.dart | 11 +- lib/util/episodegrid.dart | 279 ++++++++++++----------- 17 files changed, 373 insertions(+), 260 deletions(-) diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 0bc12d8..c5f807d 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary { "password" : MessageLookupByLibrary.simpleMessage("Password"), "pause" : MessageLookupByLibrary.simpleMessage("Pause"), "play" : MessageLookupByLibrary.simpleMessage("Play"), + "playNext" : MessageLookupByLibrary.simpleMessage("Play next"), + "playNextDes" : MessageLookupByLibrary.simpleMessage("Add episode to top of the playlist"), "playback" : MessageLookupByLibrary.simpleMessage("Playback control"), "player" : MessageLookupByLibrary.simpleMessage("Player"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medium"), diff --git a/lib/generated/intl/messages_es.dart b/lib/generated/intl/messages_es.dart index 29de54f..ad6f8bb 100644 --- a/lib/generated/intl/messages_es.dart +++ b/lib/generated/intl/messages_es.dart @@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary { "password" : MessageLookupByLibrary.simpleMessage("Password"), "pause" : MessageLookupByLibrary.simpleMessage("Pause"), "play" : MessageLookupByLibrary.simpleMessage("Reproducir"), + "playNext" : MessageLookupByLibrary.simpleMessage(""), + "playNextDes" : MessageLookupByLibrary.simpleMessage(""), "playback" : MessageLookupByLibrary.simpleMessage("Control de reproducción"), "player" : MessageLookupByLibrary.simpleMessage("Reproductor"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medio"), diff --git a/lib/generated/intl/messages_fr.dart b/lib/generated/intl/messages_fr.dart index 16c09ed..dbcc74b 100644 --- a/lib/generated/intl/messages_fr.dart +++ b/lib/generated/intl/messages_fr.dart @@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary { "password" : MessageLookupByLibrary.simpleMessage("Password"), "pause" : MessageLookupByLibrary.simpleMessage("Pause"), "play" : MessageLookupByLibrary.simpleMessage("Lecture"), + "playNext" : MessageLookupByLibrary.simpleMessage(""), + "playNextDes" : MessageLookupByLibrary.simpleMessage(""), "playback" : MessageLookupByLibrary.simpleMessage("Commandes du lecteur"), "player" : MessageLookupByLibrary.simpleMessage("Player"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Moyen"), diff --git a/lib/generated/intl/messages_it.dart b/lib/generated/intl/messages_it.dart index 509ef91..9fbcedc 100644 --- a/lib/generated/intl/messages_it.dart +++ b/lib/generated/intl/messages_it.dart @@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary { "password" : MessageLookupByLibrary.simpleMessage("Password"), "pause" : MessageLookupByLibrary.simpleMessage("Pausa"), "play" : MessageLookupByLibrary.simpleMessage("Riproduci"), + "playNext" : MessageLookupByLibrary.simpleMessage(""), + "playNextDes" : MessageLookupByLibrary.simpleMessage(""), "playback" : MessageLookupByLibrary.simpleMessage("Controlli di riproduzione"), "player" : MessageLookupByLibrary.simpleMessage("Player"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medio"), diff --git a/lib/generated/intl/messages_pt.dart b/lib/generated/intl/messages_pt.dart index 7bbd85e..70e9407 100644 --- a/lib/generated/intl/messages_pt.dart +++ b/lib/generated/intl/messages_pt.dart @@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary { "password" : MessageLookupByLibrary.simpleMessage("Password"), "pause" : MessageLookupByLibrary.simpleMessage("Pausa"), "play" : MessageLookupByLibrary.simpleMessage("Reproduzir"), + "playNext" : MessageLookupByLibrary.simpleMessage(""), + "playNextDes" : MessageLookupByLibrary.simpleMessage(""), "playback" : MessageLookupByLibrary.simpleMessage("Controlo da reprodução"), "player" : MessageLookupByLibrary.simpleMessage("Reprodutor"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Médio"), diff --git a/lib/generated/intl/messages_zh-Hans.dart b/lib/generated/intl/messages_zh-Hans.dart index cc9b1a8..4047369 100644 --- a/lib/generated/intl/messages_zh-Hans.dart +++ b/lib/generated/intl/messages_zh-Hans.dart @@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary { "password" : MessageLookupByLibrary.simpleMessage("密码"), "pause" : MessageLookupByLibrary.simpleMessage("暂停"), "play" : MessageLookupByLibrary.simpleMessage("播放"), + "playNext" : MessageLookupByLibrary.simpleMessage("下一首"), + "playNextDes" : MessageLookupByLibrary.simpleMessage("添加节目到播放列表的顶部"), "playback" : MessageLookupByLibrary.simpleMessage("播放控制"), "player" : MessageLookupByLibrary.simpleMessage("播放器"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("中"), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 7345b36..557c854 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -1495,6 +1495,26 @@ class S { ); } + /// `Play next` + String get playNext { + return Intl.message( + 'Play next', + name: 'playNext', + desc: 'Popup menu for episode.', + args: [], + ); + } + + /// `Add episode to top of the playlist` + String get playNextDes { + return Intl.message( + 'Add episode to top of the playlist', + name: 'playNextDes', + desc: 'Description for next play.', + args: [], + ); + } + /// `Plugins` String get plugins { return Intl.message( diff --git a/lib/home/home_groups.dart b/lib/home/home_groups.dart index adcb353..b636699 100644 --- a/lib/home/home_groups.dart +++ b/lib/home/home_groups.dart @@ -752,130 +752,142 @@ class ShowEpisode extends StatelessWidget { audio.episodeLoad(episodes[index]); } }), - menuList.contains(1) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: data.item2.contains( - episodes[index].enclosureUrl) - ? Text(s.remove) - : Text(s.later), - trailingIcon: Icon( - LineIcons.clock_solid, - color: Colors.cyan, - ), - onPressed: () { - if (!data.item2.contains( - episodes[index].enclosureUrl)) { - audio - .addToPlaylist(episodes[index]); - Fluttertoast.showToast( - msg: s.toastAddPlaylist, - gravity: ToastGravity.BOTTOM, - ); - } else { - audio.delFromPlaylist( - episodes[index]); - Fluttertoast.showToast( - msg: s.toastRemovePlaylist, - gravity: ToastGravity.BOTTOM, - ); - } - }) - : null, - menuList.contains(2) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: isLiked - ? Text(s.unlike) - : Text(s.like), - trailingIcon: Icon(LineIcons.heart, - color: Colors.red, size: 21), - onPressed: () async { - if (isLiked) { - await _setUnliked( - episodes[index].enclosureUrl); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.unliked, - gravity: ToastGravity.BOTTOM, - ); - } else { - await _saveLiked( - episodes[index].enclosureUrl); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.liked, - gravity: ToastGravity.BOTTOM, - ); - } - }) - : null, - menuList.contains(3) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: isListened > 0 - ? Text(s.listened, - style: TextStyle( - color: context.textColor - .withOpacity(0.5))) - : Text( - s.markListened, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - trailingIcon: SizedBox( - width: 23, - height: 23, - child: CustomPaint( - painter: ListenedAllPainter( - Colors.blue, - stroke: 1.5)), - ), - onPressed: () async { - if (isListened < 1) { - await _markListened( - episodes[index]); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.markListened, - gravity: ToastGravity.BOTTOM, - ); - } - }) - : null, - menuList.contains(4) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: isDownloaded - ? Text(s.downloaded, - style: TextStyle( - color: context.textColor - .withOpacity(0.5))) - : Text(s.download), - trailingIcon: Icon( - LineIcons.download_solid, - color: Colors.green), - onPressed: () { - if (!isDownloaded) { - _requestDownload(context, - episode: episodes[index]); - // downloader - // .startTask(episodes[index]); - } - }) - : null + if (menuList.contains(1)) + FocusedMenuItem( + backgroundColor: + context.brightness == Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: data.item2.contains( + episodes[index].enclosureUrl) + ? Text(s.remove) + : Text(s.later), + trailingIcon: Icon( + LineIcons.clock_solid, + color: Colors.cyan, + ), + onPressed: () { + if (!data.item2.contains( + episodes[index].enclosureUrl)) { + audio.addToPlaylist(episodes[index]); + Fluttertoast.showToast( + msg: s.toastAddPlaylist, + gravity: ToastGravity.BOTTOM, + ); + } else { + audio + .delFromPlaylist(episodes[index]); + Fluttertoast.showToast( + msg: s.toastRemovePlaylist, + gravity: ToastGravity.BOTTOM, + ); + } + }), + if (menuList.contains(2)) + FocusedMenuItem( + backgroundColor: + context.brightness == Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: isLiked + ? Text(s.unlike) + : Text(s.like), + trailingIcon: Icon(LineIcons.heart, + color: Colors.red, size: 21), + onPressed: () async { + if (isLiked) { + await _setUnliked( + episodes[index].enclosureUrl); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.unliked, + gravity: ToastGravity.BOTTOM, + ); + } else { + await _saveLiked( + episodes[index].enclosureUrl); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.liked, + gravity: ToastGravity.BOTTOM, + ); + } + }), + if (menuList.contains(3)) + FocusedMenuItem( + backgroundColor: + context.brightness == Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: isListened > 0 + ? Text(s.listened, + style: TextStyle( + color: context.textColor + .withOpacity(0.5))) + : Text( + s.markListened, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + trailingIcon: SizedBox( + width: 23, + height: 23, + child: CustomPaint( + painter: ListenedAllPainter( + Colors.blue, + stroke: 1.5)), + ), + onPressed: () async { + if (isListened < 1) { + await _markListened(episodes[index]); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.markListened, + gravity: ToastGravity.BOTTOM, + ); + } + }), + if (menuList.contains(4)) + FocusedMenuItem( + backgroundColor: + context.brightness == Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: isDownloaded + ? Text(s.downloaded, + style: TextStyle( + color: context.textColor + .withOpacity(0.5))) + : Text(s.download), + trailingIcon: Icon( + LineIcons.download_solid, + color: Colors.green), + onPressed: () { + if (!isDownloaded) { + _requestDownload(context, + episode: episodes[index]); + // downloader + // .startTask(episodes[index]); + } + }), + if (menuList.contains(5)) + FocusedMenuItem( + backgroundColor: + context.brightness == Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: Text(s.playNext), + trailingIcon: Icon( + LineIcons.bolt_solid, + color: Colors.amber, + ), + onPressed: () { + audio.moveToTop(episodes[index]); + Fluttertoast.showToast( + msg: s.playNextDes, + gravity: ToastGravity.BOTTOM, + ); + }), ], action: () => Navigator.push( context, diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index b89eaaa..f5f5ae2 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -364,6 +364,14 @@ "@playerHeightTall": {}, "playing": "Playing", "@playing": {}, + "playNext": "Play next", + "@playNext": { + "description": "Popup menu for episode." + }, + "playNextDes": "Add episode to top of the playlist", + "@playNextDes": { + "description": "Description for next play." + }, "plugins": "Plugins", "@plugins": {}, "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", diff --git a/lib/l10n/intl_es.arb b/lib/l10n/intl_es.arb index 5cb25ad..25dfb06 100644 --- a/lib/l10n/intl_es.arb +++ b/lib/l10n/intl_es.arb @@ -364,6 +364,14 @@ "@playerHeightTall": {}, "playing": "Reproduciendo", "@playing": {}, + "playNext": "", + "@playNext": { + "description": "Popup menu for episode." + }, + "playNextDes": "", + "@playNextDes": { + "description": "Description for next play." + }, "plugins": "Plugins", "@plugins": {}, "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 9be4e14..eda6f0d 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -364,6 +364,14 @@ "@playerHeightTall": {}, "playing": "En cours", "@playing": {}, + "playNext": "", + "@playNext": { + "description": "Popup menu for episode." + }, + "playNextDes": "", + "@playNextDes": { + "description": "Description for next play." + }, "plugins": "Plugins", "@plugins": {}, "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", diff --git a/lib/l10n/intl_it.arb b/lib/l10n/intl_it.arb index 9f76294..f9d46dd 100644 --- a/lib/l10n/intl_it.arb +++ b/lib/l10n/intl_it.arb @@ -364,6 +364,14 @@ "@playerHeightTall": {}, "playing": "In riproduzione", "@playing": {}, + "playNext": "", + "@playNext": { + "description": "Popup menu for episode." + }, + "playNextDes": "", + "@playNextDes": { + "description": "Description for next play." + }, "plugins": "Plugin", "@plugins": {}, "podcast": "{count, plural, zero{} one{Podcast} other{Podcast}}", diff --git a/lib/l10n/intl_pt.arb b/lib/l10n/intl_pt.arb index 92d4d18..d779747 100644 --- a/lib/l10n/intl_pt.arb +++ b/lib/l10n/intl_pt.arb @@ -364,6 +364,14 @@ "@playerHeightTall": {}, "playing": "Em reprodução", "@playing": {}, + "playNext": "", + "@playNext": { + "description": "Popup menu for episode." + }, + "playNextDes": "", + "@playNextDes": { + "description": "Description for next play." + }, "plugins": "Plugins", "@plugins": {}, "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", diff --git a/lib/l10n/intl_zh_Hans.arb b/lib/l10n/intl_zh_Hans.arb index 79b4efb..88458c3 100644 --- a/lib/l10n/intl_zh_Hans.arb +++ b/lib/l10n/intl_zh_Hans.arb @@ -364,6 +364,14 @@ "@playerHeightTall": {}, "playing": "正在播放", "@playing": {}, + "playNext": "下一首", + "@playNext": { + "description": "Popup menu for episode." + }, + "playNextDes": "添加节目到播放列表的顶部", + "@playNextDes": { + "description": "Description for next play." + }, "plugins": "插件", "@plugins": {}, "podcast": "{count, plural, zero{} other{播客}}", diff --git a/lib/local_storage/key_value_storage.dart b/lib/local_storage/key_value_storage.dart index cdf6984..1f49029 100644 --- a/lib/local_storage/key_value_storage.dart +++ b/lib/local_storage/key_value_storage.dart @@ -132,9 +132,10 @@ class KeyValueStorage { Future> getMenu() async { var prefs = await SharedPreferences.getInstance(); if (prefs.getStringList(key) == null || prefs.getStringList(key).isEmpty) { - await prefs.setStringList(key, ['0', '1', '2', '13', '14']); + await prefs.setStringList(key, ['0', '1', '2', '13', '14', '15']); } var list = prefs.getStringList(key); + if(list.length == 5) list = [...list,'15']; return list.map(int.parse).toList(); } diff --git a/lib/settings/popup_menu.dart b/lib/settings/popup_menu.dart index 28f2410..8c3e77e 100644 --- a/lib/settings/popup_menu.dart +++ b/lib/settings/popup_menu.dart @@ -117,7 +117,7 @@ class _PopupMenuSettingState extends State { )), FutureBuilder>( future: _getEpisodeMenu(), - initialData: [0, 1, 12, 13, 14], + initialData: [0, 1, 12, 13, 14, 15], builder: (context, snapshot) { var menu = snapshot.data; return Expanded( @@ -206,8 +206,15 @@ class _PopupMenuSettingState extends State { text: s.download, description: s.popupMenuDownloadDes); break; + case 5: + return _popupMenuItem(menu, e, + icon: Icon(LineIcons.bolt_solid, + color: Colors.amber,), + text: s.playNext, + description: s.playNextDes); + break; default: - return Text('Text'); + return Center(); break; } }).toList(), diff --git a/lib/util/episodegrid.dart b/lib/util/episodegrid.dart index 8e6b4f2..e90e80e 100644 --- a/lib/util/episodegrid.dart +++ b/lib/util/episodegrid.dart @@ -666,139 +666,152 @@ class EpisodeGrid extends StatelessWidget { audio.episodeLoad(episodes[index]); } }), - menuList.contains(1) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: data.item2.contains( - episodes[index].enclosureUrl) - ? Text(s.remove) - : Text(s.later), - trailingIcon: Icon( - LineIcons.clock_solid, - color: Colors.cyan, - ), - onPressed: () { - if (!data.item2.contains( - episodes[index].enclosureUrl)) { - audio.addToPlaylist( - episodes[index]); - Fluttertoast.showToast( - msg: s.toastAddPlaylist, - gravity: ToastGravity.BOTTOM, - ); - } else { - audio.delFromPlaylist( - episodes[index]); - Fluttertoast.showToast( - msg: s.toastRemovePlaylist, - gravity: ToastGravity.BOTTOM, - ); - } - }) - : null, - menuList.contains(2) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: isLiked - ? Text(s.unlike) - : Text(s.like), - trailingIcon: Icon(LineIcons.heart, - color: Colors.red, size: 21), - onPressed: () async { - if (isLiked) { - await _setUnliked( - episodes[index].enclosureUrl); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.unliked, - gravity: ToastGravity.BOTTOM, - ); - } else { - await _saveLiked( - episodes[index].enclosureUrl); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.liked, - gravity: ToastGravity.BOTTOM, - ); - } - }) - : null, - menuList.contains(3) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: isListened > 0 - ? Text(s.markNotListened, - style: TextStyle( - color: context.textColor - .withOpacity(0.5))) - : Text( - s.markListened, - maxLines: 1, - overflow: - TextOverflow.ellipsis, - ), - trailingIcon: SizedBox( - width: 23, - height: 23, - child: CustomPaint( - painter: ListenedAllPainter( - Colors.blue, - stroke: 1.5)), - ), - onPressed: () async { - if (isListened < 1) { - await _markListened( - episodes[index]); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.markListened, - gravity: ToastGravity.BOTTOM, - ); - } else { - await _markNotListened( - episodes[index].enclosureUrl); - audio.setEpisodeState = true; - Fluttertoast.showToast( - msg: s.markNotListened, - gravity: ToastGravity.BOTTOM, - ); - } - }) - : null, - menuList.contains(4) - ? FocusedMenuItem( - backgroundColor: context.brightness == - Brightness.light - ? context.primaryColor - : context.dialogBackgroundColor, - title: isDownloaded - ? Text(s.downloaded, - style: TextStyle( - color: context.textColor - .withOpacity(0.5))) - : Text(s.download), - trailingIcon: Icon( - LineIcons.download_solid, - color: Colors.green), - onPressed: () async { - if (!isDownloaded) { - await _requestDownload(context, - episode: episodes[index]); - // downloader - // .startTask(episodes[index]); - } - }) - : null + if (menuList.contains(1)) + FocusedMenuItem( + backgroundColor: context.brightness == + Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: data.item2.contains( + episodes[index].enclosureUrl) + ? Text(s.remove) + : Text(s.later), + trailingIcon: Icon( + LineIcons.clock_solid, + color: Colors.cyan, + ), + onPressed: () { + if (!data.item2.contains( + episodes[index].enclosureUrl)) { + audio + .addToPlaylist(episodes[index]); + Fluttertoast.showToast( + msg: s.toastAddPlaylist, + gravity: ToastGravity.BOTTOM, + ); + } else { + audio.delFromPlaylist( + episodes[index]); + Fluttertoast.showToast( + msg: s.toastRemovePlaylist, + gravity: ToastGravity.BOTTOM, + ); + } + }), + if (menuList.contains(2)) + FocusedMenuItem( + backgroundColor: context.brightness == + Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: isLiked + ? Text(s.unlike) + : Text(s.like), + trailingIcon: Icon(LineIcons.heart, + color: Colors.red, size: 21), + onPressed: () async { + if (isLiked) { + await _setUnliked( + episodes[index].enclosureUrl); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.unliked, + gravity: ToastGravity.BOTTOM, + ); + } else { + await _saveLiked( + episodes[index].enclosureUrl); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.liked, + gravity: ToastGravity.BOTTOM, + ); + } + }), + if (menuList.contains(3)) + FocusedMenuItem( + backgroundColor: context.brightness == + Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: isListened > 0 + ? Text(s.markNotListened, + style: TextStyle( + color: context.textColor + .withOpacity(0.5))) + : Text( + s.markListened, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + trailingIcon: SizedBox( + width: 23, + height: 23, + child: CustomPaint( + painter: ListenedAllPainter( + Colors.blue, + stroke: 1.5)), + ), + onPressed: () async { + if (isListened < 1) { + await _markListened( + episodes[index]); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.markListened, + gravity: ToastGravity.BOTTOM, + ); + } else { + await _markNotListened( + episodes[index].enclosureUrl); + audio.setEpisodeState = true; + Fluttertoast.showToast( + msg: s.markNotListened, + gravity: ToastGravity.BOTTOM, + ); + } + }), + if (menuList.contains(4)) + FocusedMenuItem( + backgroundColor: context.brightness == + Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: isDownloaded + ? Text(s.downloaded, + style: TextStyle( + color: context.textColor + .withOpacity(0.5))) + : Text(s.download), + trailingIcon: Icon( + LineIcons.download_solid, + color: Colors.green), + onPressed: () async { + if (!isDownloaded) { + await _requestDownload(context, + episode: episodes[index]); + // downloader + // .startTask(episodes[index]); + } + }), + if (menuList.contains(5)) + FocusedMenuItem( + backgroundColor: context.brightness == + Brightness.light + ? context.primaryColor + : context.dialogBackgroundColor, + title: Text(s.playNext), + trailingIcon: Icon( + LineIcons.bolt_solid, + color: Colors.amber, + ), + onPressed: () { + audio.moveToTop(episodes[index]); + Fluttertoast.showToast( + msg: s.playNextDes, + gravity: ToastGravity.BOTTOM, + ); + }), ], action: action, child: _episodeCard(context,