From 6a6ddf6e1f6dc72b794cae49adf8348da272babd Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Thu, 27 Apr 2023 23:00:27 +0600 Subject: [PATCH] feat: show album release year (#387) and fix layout of artist's album --- lib/components/artist/artist_album_list.dart | 49 ++++++++++--------- .../track_table/track_collection_view.dart | 12 +++++ lib/pages/artist/artist.dart | 10 ++-- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/lib/components/artist/artist_album_list.dart b/lib/components/artist/artist_album_list.dart index b12dd544d..8fa9be87f 100644 --- a/lib/components/artist/artist_album_list.dart +++ b/lib/components/artist/artist_album_list.dart @@ -33,35 +33,36 @@ class ArtistAlbumList extends HookConsumerWidget { ? false : (albumsQuery.pages.last.items?.length ?? 0) == 5; - return SizedBox( - height: 300, - child: ScrollConfiguration( - behavior: ScrollConfiguration.of(context).copyWith( - dragDevices: { - PointerDeviceKind.touch, - PointerDeviceKind.mouse, - }, - ), - child: Scrollbar( - interactive: false, - controller: scrollController, - child: Waypoint( + return Column( + children: [ + ScrollConfiguration( + behavior: ScrollConfiguration.of(context).copyWith( + dragDevices: { + PointerDeviceKind.touch, + PointerDeviceKind.mouse, + }, + ), + child: Scrollbar( + interactive: false, controller: scrollController, - onTouchEdge: albumsQuery.fetchNext, - child: ListView.builder( - itemCount: albums.length, + child: Waypoint( controller: scrollController, - scrollDirection: Axis.horizontal, - itemBuilder: (context, index) { - if (index == albums.length - 1 && hasNextPage) { - return const ShimmerPlaybuttonCard(count: 1); - } - return AlbumCard(albums[index]); - }, + onTouchEdge: albumsQuery.fetchNext, + child: SingleChildScrollView( + controller: scrollController, + scrollDirection: Axis.horizontal, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ...albums.map((album) => AlbumCard(album)), + if (hasNextPage) const ShimmerPlaybuttonCard(count: 1), + ], + ), + ), ), ), ), - ), + ], ); } } diff --git a/lib/components/shared/track_table/track_collection_view.dart b/lib/components/shared/track_table/track_collection_view.dart index 28db7444b..eb276ebe3 100644 --- a/lib/components/shared/track_table/track_collection_view.dart +++ b/lib/components/shared/track_table/track_collection_view.dart @@ -7,6 +7,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; +import 'package:spotube/components/album/album_card.dart'; import 'package:spotube/components/shared/compact_search.dart'; import 'package:spotube/components/shared/shimmers/shimmer_track_tile.dart'; import 'package:spotube/components/shared/page_window_title_bar.dart'; @@ -284,6 +285,17 @@ class TrackCollectionView extends HookConsumerWidget { fontWeight: FontWeight.w600, ), ), + if (album != null) + Text( + "${AlbumType.from(album?.albumType).formatted} • Released • ${DateTime.tryParse( + album?.releaseDate ?? "", + )?.year}", + style: + theme.textTheme.titleMedium!.copyWith( + color: color?.titleTextColor, + fontWeight: FontWeight.normal, + ), + ), if (description != null) Text( description!, diff --git a/lib/pages/artist/artist.dart b/lib/pages/artist/artist.dart index 3fddf5b09..5853808f4 100644 --- a/lib/pages/artist/artist.dart +++ b/lib/pages/artist/artist.dart @@ -34,6 +34,7 @@ class ArtistPage extends HookConsumerWidget { SpotifyApi spotify = ref.watch(spotifyProvider); final parentScrollController = useScrollController(); final theme = Theme.of(context); + final scaffoldMessenger = ScaffoldMessenger.of(context); final textTheme = theme.textTheme; final chipTextVariant = useBreakpointValue( sm: textTheme.bodySmall, @@ -126,7 +127,7 @@ class ArtistPage extends HookConsumerWidget { BorderRadius.circular(50)), child: Text( data.type!.toUpperCase(), - style: chipTextVariant?.copyWith( + style: chipTextVariant.copyWith( color: Colors.white, ), ), @@ -142,7 +143,7 @@ class ArtistPage extends HookConsumerWidget { BorderRadius.circular(50)), child: Text( "Blacklisted", - style: chipTextVariant?.copyWith( + style: chipTextVariant.copyWith( color: Colors.white, ), ), @@ -262,8 +263,7 @@ class ArtistPage extends HookConsumerWidget { text: data.externalUrls?.spotify), ); - ScaffoldMessenger.of(context) - .showSnackBar( + scaffoldMessenger.showSnackBar( const SnackBar( width: 300, behavior: SnackBarBehavior.floating, @@ -334,7 +334,7 @@ class ArtistPage extends HookConsumerWidget { ), onPressed: () { playlistNotifier.add(topTracks.toList()); - ScaffoldMessenger.of(context).showSnackBar( + scaffoldMessenger.showSnackBar( SnackBar( width: 300, behavior: SnackBarBehavior.floating,