feat: shuffle keep playing track at top, linux title bar drag no working

This commit is contained in:
Kingkor Roy Tirtho 2022-11-24 13:49:40 +06:00
parent 00d0d38b54
commit 1223cf2629
4 changed files with 25 additions and 16 deletions

View File

@ -207,28 +207,28 @@ class Settings extends HookConsumerWidget {
leading: const Icon(Icons.ad_units_rounded), leading: const Icon(Icons.ad_units_rounded),
title: const PlatformText("Mimic Platform"), title: const PlatformText("Mimic Platform"),
trailing: (context, update) => trailing: (context, update) =>
PlatformDropDownMenu<TargetPlatform>( DropdownButton<TargetPlatform>(
value: Spotube.of(context).appPlatform, value: Spotube.of(context).appPlatform,
items: [ items: const [
PlatformDropDownMenuItem( DropdownMenuItem(
value: TargetPlatform.android, value: TargetPlatform.android,
child: const PlatformText("Android (Material You)"), child: PlatformText("Android (Material You)"),
), ),
PlatformDropDownMenuItem( DropdownMenuItem(
value: TargetPlatform.iOS, value: TargetPlatform.iOS,
child: const PlatformText("iOS (Cupertino)"), child: PlatformText("iOS (Cupertino)"),
), ),
PlatformDropDownMenuItem( DropdownMenuItem(
value: TargetPlatform.macOS, value: TargetPlatform.macOS,
child: const PlatformText("macOS (Aqua)"), child: PlatformText("macOS (Aqua)"),
), ),
PlatformDropDownMenuItem( DropdownMenuItem(
value: TargetPlatform.linux, value: TargetPlatform.linux,
child: const PlatformText("Linux (GTK+Libadwaita)"), child: PlatformText("Linux (GTK+Libadwaita)"),
), ),
PlatformDropDownMenuItem( DropdownMenuItem(
value: TargetPlatform.windows, value: TargetPlatform.windows,
child: const PlatformText("Windows 11 (Fluent UI)"), child: PlatformText("Windows 11 (Fluent UI)"),
), ),
], ],
onChanged: (value) { onChanged: (value) {

View File

@ -23,9 +23,14 @@ class PageWindowTitleBar extends PlatformAppBar {
}) : super( }) : super(
actions: [ actions: [
...?actions, ...?actions,
if (!kIsMacOS && !kIsMobile) const PlatformWindowButtons(), if (!kIsMacOS && !kIsMobile)
platform == TargetPlatform.linux
? MoveWindow(child: const PlatformWindowButtons())
: const PlatformWindowButtons(),
], ],
title: center, title: platform == TargetPlatform.linux
? MoveWindow(child: Center(child: center))
: center,
); );
@override @override

View File

@ -90,11 +90,15 @@ class CurrentPlaylist {
List<String> get trackIds => tracks.map((e) => e.id!).toList(); List<String> get trackIds => tracks.map((e) => e.id!).toList();
bool shuffle() { bool shuffle(Track? topTrack) {
// won't shuffle if already shuffled // won't shuffle if already shuffled
if (_tempTrack == null) { if (_tempTrack == null) {
_tempTrack = [...tracks]; _tempTrack = [...tracks];
tracks.shuffle(); tracks.shuffle();
if (topTrack != null) {
tracks.remove(topTrack);
tracks.insert(0, topTrack);
}
return true; return true;
} }
return false; return false;

View File

@ -290,7 +290,7 @@ class Playback extends PersistedChangeNotifier {
switch (playbackMode) { switch (playbackMode) {
case PlaybackMode.normal: case PlaybackMode.normal:
playbackMode = PlaybackMode.shuffle; playbackMode = PlaybackMode.shuffle;
playlist?.shuffle(); playlist?.shuffle(track);
break; break;
case PlaybackMode.shuffle: case PlaybackMode.shuffle:
playbackMode = PlaybackMode.repeat; playbackMode = PlaybackMode.repeat;