Skip to content

Commit

Permalink
feat: shuffle keep playing track at top, linux title bar drag no working
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Nov 24, 2022
1 parent 00d0d38 commit 1223cf2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
24 changes: 12 additions & 12 deletions lib/components/Settings/Settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,28 @@ class Settings extends HookConsumerWidget {
leading: const Icon(Icons.ad_units_rounded),
title: const PlatformText("Mimic Platform"),
trailing: (context, update) =>
PlatformDropDownMenu<TargetPlatform>(
DropdownButton<TargetPlatform>(
value: Spotube.of(context).appPlatform,
items: [
PlatformDropDownMenuItem(
items: const [
DropdownMenuItem(
value: TargetPlatform.android,
child: const PlatformText("Android (Material You)"),
child: PlatformText("Android (Material You)"),
),
PlatformDropDownMenuItem(
DropdownMenuItem(
value: TargetPlatform.iOS,
child: const PlatformText("iOS (Cupertino)"),
child: PlatformText("iOS (Cupertino)"),
),
PlatformDropDownMenuItem(
DropdownMenuItem(
value: TargetPlatform.macOS,
child: const PlatformText("macOS (Aqua)"),
child: PlatformText("macOS (Aqua)"),
),
PlatformDropDownMenuItem(
DropdownMenuItem(
value: TargetPlatform.linux,
child: const PlatformText("Linux (GTK+Libadwaita)"),
child: PlatformText("Linux (GTK+Libadwaita)"),
),
PlatformDropDownMenuItem(
DropdownMenuItem(
value: TargetPlatform.windows,
child: const PlatformText("Windows 11 (Fluent UI)"),
child: PlatformText("Windows 11 (Fluent UI)"),
),
],
onChanged: (value) {
Expand Down
9 changes: 7 additions & 2 deletions lib/components/Shared/PageWindowTitleBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ class PageWindowTitleBar extends PlatformAppBar {
}) : super(
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
Expand Down
6 changes: 5 additions & 1 deletion lib/models/CurrentPlaylist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ class CurrentPlaylist {

List<String> get trackIds => tracks.map((e) => e.id!).toList();

bool shuffle() {
bool shuffle(Track? topTrack) {
// won't shuffle if already shuffled
if (_tempTrack == null) {
_tempTrack = [...tracks];
tracks.shuffle();
if (topTrack != null) {
tracks.remove(topTrack);
tracks.insert(0, topTrack);
}
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/Playback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class Playback extends PersistedChangeNotifier {
switch (playbackMode) {
case PlaybackMode.normal:
playbackMode = PlaybackMode.shuffle;
playlist?.shuffle();
playlist?.shuffle(track);
break;
case PlaybackMode.shuffle:
playbackMode = PlaybackMode.repeat;
Expand Down

0 comments on commit 1223cf2

Please sign in to comment.