Add play next in popupmenu.

This commit is contained in:
stonega 2020-10-29 21:05:58 +08:00
parent 434609eaeb
commit 074f31e7cd
17 changed files with 373 additions and 260 deletions

View File

@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
"password" : MessageLookupByLibrary.simpleMessage("Password"), "password" : MessageLookupByLibrary.simpleMessage("Password"),
"pause" : MessageLookupByLibrary.simpleMessage("Pause"), "pause" : MessageLookupByLibrary.simpleMessage("Pause"),
"play" : MessageLookupByLibrary.simpleMessage("Play"), "play" : MessageLookupByLibrary.simpleMessage("Play"),
"playNext" : MessageLookupByLibrary.simpleMessage("Play next"),
"playNextDes" : MessageLookupByLibrary.simpleMessage("Add episode to top of the playlist"),
"playback" : MessageLookupByLibrary.simpleMessage("Playback control"), "playback" : MessageLookupByLibrary.simpleMessage("Playback control"),
"player" : MessageLookupByLibrary.simpleMessage("Player"), "player" : MessageLookupByLibrary.simpleMessage("Player"),
"playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medium"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medium"),

View File

@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
"password" : MessageLookupByLibrary.simpleMessage("Password"), "password" : MessageLookupByLibrary.simpleMessage("Password"),
"pause" : MessageLookupByLibrary.simpleMessage("Pause"), "pause" : MessageLookupByLibrary.simpleMessage("Pause"),
"play" : MessageLookupByLibrary.simpleMessage("Reproducir"), "play" : MessageLookupByLibrary.simpleMessage("Reproducir"),
"playNext" : MessageLookupByLibrary.simpleMessage(""),
"playNextDes" : MessageLookupByLibrary.simpleMessage(""),
"playback" : MessageLookupByLibrary.simpleMessage("Control de reproducción"), "playback" : MessageLookupByLibrary.simpleMessage("Control de reproducción"),
"player" : MessageLookupByLibrary.simpleMessage("Reproductor"), "player" : MessageLookupByLibrary.simpleMessage("Reproductor"),
"playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medio"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medio"),

View File

@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
"password" : MessageLookupByLibrary.simpleMessage("Password"), "password" : MessageLookupByLibrary.simpleMessage("Password"),
"pause" : MessageLookupByLibrary.simpleMessage("Pause"), "pause" : MessageLookupByLibrary.simpleMessage("Pause"),
"play" : MessageLookupByLibrary.simpleMessage("Lecture"), "play" : MessageLookupByLibrary.simpleMessage("Lecture"),
"playNext" : MessageLookupByLibrary.simpleMessage(""),
"playNextDes" : MessageLookupByLibrary.simpleMessage(""),
"playback" : MessageLookupByLibrary.simpleMessage("Commandes du lecteur"), "playback" : MessageLookupByLibrary.simpleMessage("Commandes du lecteur"),
"player" : MessageLookupByLibrary.simpleMessage("Player"), "player" : MessageLookupByLibrary.simpleMessage("Player"),
"playerHeightMed" : MessageLookupByLibrary.simpleMessage("Moyen"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Moyen"),

View File

@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
"password" : MessageLookupByLibrary.simpleMessage("Password"), "password" : MessageLookupByLibrary.simpleMessage("Password"),
"pause" : MessageLookupByLibrary.simpleMessage("Pausa"), "pause" : MessageLookupByLibrary.simpleMessage("Pausa"),
"play" : MessageLookupByLibrary.simpleMessage("Riproduci"), "play" : MessageLookupByLibrary.simpleMessage("Riproduci"),
"playNext" : MessageLookupByLibrary.simpleMessage(""),
"playNextDes" : MessageLookupByLibrary.simpleMessage(""),
"playback" : MessageLookupByLibrary.simpleMessage("Controlli di riproduzione"), "playback" : MessageLookupByLibrary.simpleMessage("Controlli di riproduzione"),
"player" : MessageLookupByLibrary.simpleMessage("Player"), "player" : MessageLookupByLibrary.simpleMessage("Player"),
"playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medio"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Medio"),

View File

@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
"password" : MessageLookupByLibrary.simpleMessage("Password"), "password" : MessageLookupByLibrary.simpleMessage("Password"),
"pause" : MessageLookupByLibrary.simpleMessage("Pausa"), "pause" : MessageLookupByLibrary.simpleMessage("Pausa"),
"play" : MessageLookupByLibrary.simpleMessage("Reproduzir"), "play" : MessageLookupByLibrary.simpleMessage("Reproduzir"),
"playNext" : MessageLookupByLibrary.simpleMessage(""),
"playNextDes" : MessageLookupByLibrary.simpleMessage(""),
"playback" : MessageLookupByLibrary.simpleMessage("Controlo da reprodução"), "playback" : MessageLookupByLibrary.simpleMessage("Controlo da reprodução"),
"player" : MessageLookupByLibrary.simpleMessage("Reprodutor"), "player" : MessageLookupByLibrary.simpleMessage("Reprodutor"),
"playerHeightMed" : MessageLookupByLibrary.simpleMessage("Médio"), "playerHeightMed" : MessageLookupByLibrary.simpleMessage("Médio"),

View File

@ -220,6 +220,8 @@ class MessageLookup extends MessageLookupByLibrary {
"password" : MessageLookupByLibrary.simpleMessage("密码"), "password" : MessageLookupByLibrary.simpleMessage("密码"),
"pause" : MessageLookupByLibrary.simpleMessage("暂停"), "pause" : MessageLookupByLibrary.simpleMessage("暂停"),
"play" : MessageLookupByLibrary.simpleMessage("播放"), "play" : MessageLookupByLibrary.simpleMessage("播放"),
"playNext" : MessageLookupByLibrary.simpleMessage("下一首"),
"playNextDes" : MessageLookupByLibrary.simpleMessage("添加节目到播放列表的顶部"),
"playback" : MessageLookupByLibrary.simpleMessage("播放控制"), "playback" : MessageLookupByLibrary.simpleMessage("播放控制"),
"player" : MessageLookupByLibrary.simpleMessage("播放器"), "player" : MessageLookupByLibrary.simpleMessage("播放器"),
"playerHeightMed" : MessageLookupByLibrary.simpleMessage(""), "playerHeightMed" : MessageLookupByLibrary.simpleMessage(""),

View File

@ -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` /// `Plugins`
String get plugins { String get plugins {
return Intl.message( return Intl.message(

View File

@ -752,10 +752,10 @@ class ShowEpisode extends StatelessWidget {
audio.episodeLoad(episodes[index]); audio.episodeLoad(episodes[index]);
} }
}), }),
menuList.contains(1) if (menuList.contains(1))
? FocusedMenuItem( FocusedMenuItem(
backgroundColor: context.brightness == backgroundColor:
Brightness.light context.brightness == Brightness.light
? context.primaryColor ? context.primaryColor
: context.dialogBackgroundColor, : context.dialogBackgroundColor,
title: data.item2.contains( title: data.item2.contains(
@ -769,26 +769,24 @@ class ShowEpisode extends StatelessWidget {
onPressed: () { onPressed: () {
if (!data.item2.contains( if (!data.item2.contains(
episodes[index].enclosureUrl)) { episodes[index].enclosureUrl)) {
audio audio.addToPlaylist(episodes[index]);
.addToPlaylist(episodes[index]);
Fluttertoast.showToast( Fluttertoast.showToast(
msg: s.toastAddPlaylist, msg: s.toastAddPlaylist,
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} else { } else {
audio.delFromPlaylist( audio
episodes[index]); .delFromPlaylist(episodes[index]);
Fluttertoast.showToast( Fluttertoast.showToast(
msg: s.toastRemovePlaylist, msg: s.toastRemovePlaylist,
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} }
}) }),
: null, if (menuList.contains(2))
menuList.contains(2) FocusedMenuItem(
? FocusedMenuItem( backgroundColor:
backgroundColor: context.brightness == context.brightness == Brightness.light
Brightness.light
? context.primaryColor ? context.primaryColor
: context.dialogBackgroundColor, : context.dialogBackgroundColor,
title: isLiked title: isLiked
@ -814,12 +812,11 @@ class ShowEpisode extends StatelessWidget {
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} }
}) }),
: null, if (menuList.contains(3))
menuList.contains(3) FocusedMenuItem(
? FocusedMenuItem( backgroundColor:
backgroundColor: context.brightness == context.brightness == Brightness.light
Brightness.light
? context.primaryColor ? context.primaryColor
: context.dialogBackgroundColor, : context.dialogBackgroundColor,
title: isListened > 0 title: isListened > 0
@ -842,20 +839,18 @@ class ShowEpisode extends StatelessWidget {
), ),
onPressed: () async { onPressed: () async {
if (isListened < 1) { if (isListened < 1) {
await _markListened( await _markListened(episodes[index]);
episodes[index]);
audio.setEpisodeState = true; audio.setEpisodeState = true;
Fluttertoast.showToast( Fluttertoast.showToast(
msg: s.markListened, msg: s.markListened,
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} }
}) }),
: null, if (menuList.contains(4))
menuList.contains(4) FocusedMenuItem(
? FocusedMenuItem( backgroundColor:
backgroundColor: context.brightness == context.brightness == Brightness.light
Brightness.light
? context.primaryColor ? context.primaryColor
: context.dialogBackgroundColor, : context.dialogBackgroundColor,
title: isDownloaded title: isDownloaded
@ -874,8 +869,25 @@ class ShowEpisode extends StatelessWidget {
// downloader // downloader
// .startTask(episodes[index]); // .startTask(episodes[index]);
} }
}) }),
: null 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( action: () => Navigator.push(
context, context,

View File

@ -364,6 +364,14 @@
"@playerHeightTall": {}, "@playerHeightTall": {},
"playing": "Playing", "playing": "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": "Plugins",
"@plugins": {}, "@plugins": {},
"podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}",

View File

@ -364,6 +364,14 @@
"@playerHeightTall": {}, "@playerHeightTall": {},
"playing": "Reproduciendo", "playing": "Reproduciendo",
"@playing": {}, "@playing": {},
"playNext": "",
"@playNext": {
"description": "Popup menu for episode."
},
"playNextDes": "",
"@playNextDes": {
"description": "Description for next play."
},
"plugins": "Plugins", "plugins": "Plugins",
"@plugins": {}, "@plugins": {},
"podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}",

View File

@ -364,6 +364,14 @@
"@playerHeightTall": {}, "@playerHeightTall": {},
"playing": "En cours", "playing": "En cours",
"@playing": {}, "@playing": {},
"playNext": "",
"@playNext": {
"description": "Popup menu for episode."
},
"playNextDes": "",
"@playNextDes": {
"description": "Description for next play."
},
"plugins": "Plugins", "plugins": "Plugins",
"@plugins": {}, "@plugins": {},
"podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}",

View File

@ -364,6 +364,14 @@
"@playerHeightTall": {}, "@playerHeightTall": {},
"playing": "In riproduzione", "playing": "In riproduzione",
"@playing": {}, "@playing": {},
"playNext": "",
"@playNext": {
"description": "Popup menu for episode."
},
"playNextDes": "",
"@playNextDes": {
"description": "Description for next play."
},
"plugins": "Plugin", "plugins": "Plugin",
"@plugins": {}, "@plugins": {},
"podcast": "{count, plural, zero{} one{Podcast} other{Podcast}}", "podcast": "{count, plural, zero{} one{Podcast} other{Podcast}}",

View File

@ -364,6 +364,14 @@
"@playerHeightTall": {}, "@playerHeightTall": {},
"playing": "Em reprodução", "playing": "Em reprodução",
"@playing": {}, "@playing": {},
"playNext": "",
"@playNext": {
"description": "Popup menu for episode."
},
"playNextDes": "",
"@playNextDes": {
"description": "Description for next play."
},
"plugins": "Plugins", "plugins": "Plugins",
"@plugins": {}, "@plugins": {},
"podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}", "podcast": "{count, plural, zero{} one{Podcast} other{Podcasts}}",

View File

@ -364,6 +364,14 @@
"@playerHeightTall": {}, "@playerHeightTall": {},
"playing": "正在播放", "playing": "正在播放",
"@playing": {}, "@playing": {},
"playNext": "下一首",
"@playNext": {
"description": "Popup menu for episode."
},
"playNextDes": "添加节目到播放列表的顶部",
"@playNextDes": {
"description": "Description for next play."
},
"plugins": "插件", "plugins": "插件",
"@plugins": {}, "@plugins": {},
"podcast": "{count, plural, zero{} other{播客}}", "podcast": "{count, plural, zero{} other{播客}}",

View File

@ -132,9 +132,10 @@ class KeyValueStorage {
Future<List<int>> getMenu() async { Future<List<int>> getMenu() async {
var prefs = await SharedPreferences.getInstance(); var prefs = await SharedPreferences.getInstance();
if (prefs.getStringList(key) == null || prefs.getStringList(key).isEmpty) { 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); var list = prefs.getStringList(key);
if(list.length == 5) list = [...list,'15'];
return list.map(int.parse).toList(); return list.map(int.parse).toList();
} }

View File

@ -117,7 +117,7 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
)), )),
FutureBuilder<List<int>>( FutureBuilder<List<int>>(
future: _getEpisodeMenu(), future: _getEpisodeMenu(),
initialData: [0, 1, 12, 13, 14], initialData: [0, 1, 12, 13, 14, 15],
builder: (context, snapshot) { builder: (context, snapshot) {
var menu = snapshot.data; var menu = snapshot.data;
return Expanded( return Expanded(
@ -206,8 +206,15 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
text: s.download, text: s.download,
description: s.popupMenuDownloadDes); description: s.popupMenuDownloadDes);
break; break;
case 5:
return _popupMenuItem(menu, e,
icon: Icon(LineIcons.bolt_solid,
color: Colors.amber,),
text: s.playNext,
description: s.playNextDes);
break;
default: default:
return Text('Text'); return Center();
break; break;
} }
}).toList(), }).toList(),

View File

@ -666,8 +666,8 @@ class EpisodeGrid extends StatelessWidget {
audio.episodeLoad(episodes[index]); audio.episodeLoad(episodes[index]);
} }
}), }),
menuList.contains(1) if (menuList.contains(1))
? FocusedMenuItem( FocusedMenuItem(
backgroundColor: context.brightness == backgroundColor: context.brightness ==
Brightness.light Brightness.light
? context.primaryColor ? context.primaryColor
@ -683,8 +683,8 @@ class EpisodeGrid extends StatelessWidget {
onPressed: () { onPressed: () {
if (!data.item2.contains( if (!data.item2.contains(
episodes[index].enclosureUrl)) { episodes[index].enclosureUrl)) {
audio.addToPlaylist( audio
episodes[index]); .addToPlaylist(episodes[index]);
Fluttertoast.showToast( Fluttertoast.showToast(
msg: s.toastAddPlaylist, msg: s.toastAddPlaylist,
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
@ -697,10 +697,9 @@ class EpisodeGrid extends StatelessWidget {
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} }
}) }),
: null, if (menuList.contains(2))
menuList.contains(2) FocusedMenuItem(
? FocusedMenuItem(
backgroundColor: context.brightness == backgroundColor: context.brightness ==
Brightness.light Brightness.light
? context.primaryColor ? context.primaryColor
@ -728,10 +727,9 @@ class EpisodeGrid extends StatelessWidget {
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} }
}) }),
: null, if (menuList.contains(3))
menuList.contains(3) FocusedMenuItem(
? FocusedMenuItem(
backgroundColor: context.brightness == backgroundColor: context.brightness ==
Brightness.light Brightness.light
? context.primaryColor ? context.primaryColor
@ -744,8 +742,7 @@ class EpisodeGrid extends StatelessWidget {
: Text( : Text(
s.markListened, s.markListened,
maxLines: 1, maxLines: 1,
overflow: overflow: TextOverflow.ellipsis,
TextOverflow.ellipsis,
), ),
trailingIcon: SizedBox( trailingIcon: SizedBox(
width: 23, width: 23,
@ -773,10 +770,9 @@ class EpisodeGrid extends StatelessWidget {
gravity: ToastGravity.BOTTOM, gravity: ToastGravity.BOTTOM,
); );
} }
}) }),
: null, if (menuList.contains(4))
menuList.contains(4) FocusedMenuItem(
? FocusedMenuItem(
backgroundColor: context.brightness == backgroundColor: context.brightness ==
Brightness.light Brightness.light
? context.primaryColor ? context.primaryColor
@ -797,8 +793,25 @@ class EpisodeGrid extends StatelessWidget {
// downloader // downloader
// .startTask(episodes[index]); // .startTask(episodes[index]);
} }
}) }),
: null 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, action: action,
child: _episodeCard(context, child: _episodeCard(context,