diff --git a/.github/workflows/spotube-nightly.yml b/.github/workflows/spotube-nightly.yml index 6d3a595ae..2be5ba277 100644 --- a/.github/workflows/spotube-nightly.yml +++ b/.github/workflows/spotube-nightly.yml @@ -7,7 +7,7 @@ on: jobs: build_ubuntu: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2.8.0 @@ -20,9 +20,9 @@ jobs: sudo apt-get update -y sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev - run: | - wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.0.0-beta.1/appimage-builder-1.0.0-677acbd-x86_64.AppImage - chmod +x appimage-builder-x86_64.AppImage - mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder + wget -O appimage-builder https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage + chmod +x appimage-builder + mv appimage-builder /usr/local/bin/ - run: | curl -sS https://webi.sh/yq | sh diff --git a/lib/components/shared/playlist_shuffle_button.dart b/lib/components/shared/playlist_shuffle_button.dart deleted file mode 100644 index d7de549e3..000000000 --- a/lib/components/shared/playlist_shuffle_button.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:platform_ui/platform_ui.dart'; - -class PlaylistShuffleButton extends StatelessWidget { - final onPressed; - - const PlaylistShuffleButton({ - Key? key, - this.onPressed, - }); - - @override - Widget build(BuildContext context) { - return PlatformIconButton( - tooltip: "Shuffle", - icon: const Icon(Icons.shuffle), - onPressed: this.onPressed, - ); - } -} diff --git a/lib/components/shared/track_table/track_collection_view.dart b/lib/components/shared/track_table/track_collection_view.dart index 1fe97a21f..c54278b49 100644 --- a/lib/components/shared/track_table/track_collection_view.dart +++ b/lib/components/shared/track_table/track_collection_view.dart @@ -24,9 +24,9 @@ class TrackCollectionView extends HookConsumerWidget { final String titleImage; final bool isPlaying; final void Function([Track? currentTrack]) onPlay; + final void Function([Track? currentTrack]) onShuffledPlay; final void Function() onShare; final Widget? heartBtn; - final Widget? shuffleButton; final AlbumSimple? album; final bool showShare; @@ -41,10 +41,10 @@ class TrackCollectionView extends HookConsumerWidget { required this.titleImage, required this.isPlaying, required this.onPlay, + required this.onShuffledPlay, required this.onShare, required this.routePath, this.heartBtn, - this.shuffleButton, this.album, this.description, this.showShare = true, @@ -70,7 +70,14 @@ class TrackCollectionView extends HookConsumerWidget { onPressed: onShare, ), if (heartBtn != null) heartBtn!, - if (shuffleButton != null) shuffleButton!, + PlatformIconButton( + tooltip: "Shuffle", + icon: Icon( + Icons.shuffle, + color: color?.titleTextColor, + ), + onPressed: onShuffledPlay, + ), const SizedBox(width: 5), // play playlist PlatformIconButton( diff --git a/lib/pages/album/album.dart b/lib/pages/album/album.dart index e3d1bb7bb..114866937 100644 --- a/lib/pages/album/album.dart +++ b/lib/pages/album/album.dart @@ -14,7 +14,6 @@ import 'package:spotube/utils/type_conversion_utils.dart'; import 'package:spotube/models/current_playlist.dart'; import 'package:spotube/provider/playback_provider.dart'; import 'package:spotube/provider/spotify_provider.dart'; -import 'package:spotube/components/shared/playlist_shuffle_button.dart'; class AlbumPage extends HookConsumerWidget { final AlbumSimple album; @@ -113,26 +112,32 @@ class AlbumPage extends HookConsumerWidget { ); }, heartBtn: AlbumHeartButton(album: album), - shuffleButton: PlaylistShuffleButton(onPressed: () { - var albumTracks = tracksSnapshot.data! - .map((track) => - TypeConversionUtils.simpleTrack_X_Track(track, album)) - .toList(); + onShuffledPlay: ([track]) { // Shuffle the tracks (create a copy of playlist) - var tracks = [...albumTracks]; - tracks.shuffle(); - - // If playback is playing a track then pause it - if (playback.isPlaying) { - playback.pause(); + if (tracksSnapshot.hasData) { + final tracks = tracksSnapshot.data! + .map((track) => + TypeConversionUtils.simpleTrack_X_Track(track, album)) + .toList() + ..shuffle(); + if (!isAlbumPlaying) { + playPlaylist( + playback, + tracks, + ref, + ); + } else if (isAlbumPlaying && track != null) { + playPlaylist( + playback, + tracks, + ref, + currentTrack: track, + ); + } else { + playback.stop(); + } } - - // Play the shuffled playlist - playPlaylist( playback, - tracks, - ref, - ); - }), + }, ); } } diff --git a/lib/pages/playlist/playlist.dart b/lib/pages/playlist/playlist.dart index c5989d206..2d5cd65c0 100644 --- a/lib/pages/playlist/playlist.dart +++ b/lib/pages/playlist/playlist.dart @@ -16,7 +16,6 @@ import 'package:spotube/services/queries/queries.dart'; import 'package:spotube/utils/service_utils.dart'; import 'package:spotube/utils/type_conversion_utils.dart'; -import 'package:spotube/components/shared/playlist_shuffle_button.dart'; class PlaylistView extends HookConsumerWidget { final logger = getLogger(PlaylistView); @@ -127,23 +126,29 @@ class PlaylistView extends HookConsumerWidget { }); }, heartBtn: PlaylistHeartButton(playlist: playlist), - shuffleButton: PlaylistShuffleButton(onPressed: () { - // Shuffle the tracks (create a copy of playlist) - var tracks = [...?tracksSnapshot.data]; - tracks.shuffle(); + onShuffledPlay: ([track]) { + final tracks = [...?tracksSnapshot.data]..shuffle(); - // If playback is playing a track then pause it - if (playback.isPlaying) { - playback.pause(); + if (tracksSnapshot.hasData) { + if (!isPlaylistPlaying) { + playPlaylist( + playback, + tracks, + ref, + currentTrack: track, + ); + } else if (isPlaylistPlaying && track != null) { + playPlaylist( + playback, + tracks, + ref, + currentTrack: track, + ); + } else { + playback.stop(); + } } - - // Play the shuffled playlist - playPlaylist( playback, - tracks, - ref, - currentTrack: null, - ); - }), + }, ); } }