mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: album & playlist card, player view and album view play button logic
This commit is contained in:
parent
a1d423090c
commit
55852bd15b
@ -23,7 +23,7 @@ class AlbumCard extends HookConsumerWidget {
|
||||
return PlaybuttonCard(
|
||||
imageUrl: TypeConversionUtils.image_X_UrlString(album.images),
|
||||
margin: EdgeInsets.symmetric(horizontal: marginH.toDouble()),
|
||||
isPlaying: playback.playlist?.id == album.id,
|
||||
isPlaying: isPlaylistPlaying && playback.isPlaying,
|
||||
isLoading: playback.status == PlaybackStatus.loading &&
|
||||
playback.playlist?.id == album.id,
|
||||
title: album.name!,
|
||||
@ -34,7 +34,11 @@ class AlbumCard extends HookConsumerWidget {
|
||||
},
|
||||
onPlaybuttonPressed: () async {
|
||||
SpotifyApi spotify = ref.read(spotifyProvider);
|
||||
if (isPlaylistPlaying) return;
|
||||
if (isPlaylistPlaying && playback.isPlaying) {
|
||||
return playback.pause();
|
||||
} else if (isPlaylistPlaying && !playback.isPlaying) {
|
||||
return playback.resume();
|
||||
}
|
||||
List<Track> tracks = (await spotify.albums.getTracks(album.id!).all())
|
||||
.map((track) =>
|
||||
TypeConversionUtils.simpleTrack_X_Track(track, album))
|
||||
|
@ -55,10 +55,11 @@ class AlbumView extends HookConsumerWidget {
|
||||
|
||||
final breakpoint = useBreakpoints();
|
||||
|
||||
final isAlbumPlaying =
|
||||
playback.playlist?.id != null && playback.playlist?.id == album.id;
|
||||
return TrackCollectionView(
|
||||
id: album.id!,
|
||||
isPlaying:
|
||||
playback.playlist?.id != null && playback.playlist?.id == album.id,
|
||||
isPlaying: isAlbumPlaying,
|
||||
title: album.name!,
|
||||
titleImage: albumArt,
|
||||
tracksSnapshot: tracksSnapshot,
|
||||
@ -67,14 +68,18 @@ class AlbumView extends HookConsumerWidget {
|
||||
bottomSpace: breakpoint.isLessThanOrEqualTo(Breakpoints.md),
|
||||
onPlay: ([track]) {
|
||||
if (tracksSnapshot.asData?.value != null) {
|
||||
playPlaylist(
|
||||
playback,
|
||||
tracksSnapshot.asData!.value
|
||||
.map((track) =>
|
||||
TypeConversionUtils.simpleTrack_X_Track(track, album))
|
||||
.toList(),
|
||||
currentTrack: track,
|
||||
);
|
||||
if (!isAlbumPlaying) {
|
||||
playPlaylist(
|
||||
playback,
|
||||
tracksSnapshot.asData!.value
|
||||
.map((track) =>
|
||||
TypeConversionUtils.simpleTrack_X_Track(track, album))
|
||||
.toList(),
|
||||
currentTrack: track,
|
||||
);
|
||||
} else {
|
||||
playback.stop();
|
||||
}
|
||||
}
|
||||
},
|
||||
onShare: () {
|
||||
|
@ -24,7 +24,7 @@ class PlaylistCard extends HookConsumerWidget {
|
||||
margin: EdgeInsets.symmetric(horizontal: marginH.toDouble()),
|
||||
title: playlist.name!,
|
||||
imageUrl: TypeConversionUtils.image_X_UrlString(playlist.images),
|
||||
isPlaying: isPlaylistPlaying,
|
||||
isPlaying: isPlaylistPlaying && playback.isPlaying,
|
||||
isLoading: playback.status == PlaybackStatus.loading && isPlaylistPlaying,
|
||||
onTap: () {
|
||||
GoRouter.of(context).push(
|
||||
@ -33,7 +33,11 @@ class PlaylistCard extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
onPlaybuttonPressed: () async {
|
||||
if (isPlaylistPlaying) return;
|
||||
if (isPlaylistPlaying && playback.isPlaying) {
|
||||
return playback.pause();
|
||||
} else if (isPlaylistPlaying && !playback.isPlaying) {
|
||||
return playback.resume();
|
||||
}
|
||||
SpotifyApi spotifyApi = ref.read(spotifyProvider);
|
||||
|
||||
List<Track> tracks = (playlist.id != "user-liked-tracks"
|
||||
|
@ -77,11 +77,15 @@ class PlaylistView extends HookConsumerWidget {
|
||||
playlist.owner!.id == meSnapshot.asData?.value.id,
|
||||
onPlay: ([track]) {
|
||||
if (tracksSnapshot.asData?.value != null) {
|
||||
playPlaylist(
|
||||
playback,
|
||||
tracksSnapshot.asData!.value,
|
||||
currentTrack: track,
|
||||
);
|
||||
if (!isPlaylistPlaying) {
|
||||
playPlaylist(
|
||||
playback,
|
||||
tracksSnapshot.asData!.value,
|
||||
currentTrack: track,
|
||||
);
|
||||
} else {
|
||||
playback.stop();
|
||||
}
|
||||
}
|
||||
},
|
||||
bottomSpace: breakpoint.isLessThanOrEqualTo(Breakpoints.md),
|
||||
|
@ -272,6 +272,16 @@ class TrackTile extends HookConsumerWidget {
|
||||
const SizedBox(width: 10),
|
||||
AdaptiveActions(
|
||||
actions: [
|
||||
if (auth.isLoggedIn)
|
||||
Action(
|
||||
icon: Icon(isSaved
|
||||
? Icons.favorite_rounded
|
||||
: Icons.favorite_border_rounded),
|
||||
text: const Text("Save as favorite"),
|
||||
onPressed: () {
|
||||
actionFavorite(isSaved);
|
||||
},
|
||||
),
|
||||
if (auth.isLoggedIn)
|
||||
Action(
|
||||
icon: const Icon(Icons.add_box_rounded),
|
||||
@ -284,16 +294,6 @@ class TrackTile extends HookConsumerWidget {
|
||||
text: const Text("Remove from playlist"),
|
||||
onPressed: actionRemoveFromPlaylist,
|
||||
),
|
||||
if (auth.isLoggedIn)
|
||||
Action(
|
||||
icon: Icon(isSaved
|
||||
? Icons.favorite_rounded
|
||||
: Icons.favorite_border_rounded),
|
||||
text: const Text("Save as favorite"),
|
||||
onPressed: () {
|
||||
actionFavorite(isSaved);
|
||||
},
|
||||
),
|
||||
Action(
|
||||
icon: const Icon(Icons.share_rounded),
|
||||
text: const Text("Share"),
|
||||
|
@ -39,7 +39,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
this.accentColorScheme = Colors.green,
|
||||
this.backgroundColorScheme = Colors.grey,
|
||||
this.checkUpdate = true,
|
||||
this.trackMatchAlgorithm = SpotubeTrackMatchAlgorithm.authenticPopular,
|
||||
this.trackMatchAlgorithm = SpotubeTrackMatchAlgorithm.youtube,
|
||||
this.audioQuality = AudioQuality.high,
|
||||
this.skipSponsorSegments = true,
|
||||
this.downloadLocation = "",
|
||||
|
Loading…
Reference in New Issue
Block a user