feat: show album release year (#387) and fix layout of artist's album

This commit is contained in:
Kingkor Roy Tirtho 2023-04-27 23:00:27 +06:00
parent 623d171d79
commit 6a6ddf6e1f
3 changed files with 42 additions and 29 deletions

View File

@ -33,9 +33,9 @@ class ArtistAlbumList extends HookConsumerWidget {
? false ? false
: (albumsQuery.pages.last.items?.length ?? 0) == 5; : (albumsQuery.pages.last.items?.length ?? 0) == 5;
return SizedBox( return Column(
height: 300, children: [
child: ScrollConfiguration( ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith( behavior: ScrollConfiguration.of(context).copyWith(
dragDevices: { dragDevices: {
PointerDeviceKind.touch, PointerDeviceKind.touch,
@ -48,20 +48,21 @@ class ArtistAlbumList extends HookConsumerWidget {
child: Waypoint( child: Waypoint(
controller: scrollController, controller: scrollController,
onTouchEdge: albumsQuery.fetchNext, onTouchEdge: albumsQuery.fetchNext,
child: ListView.builder( child: SingleChildScrollView(
itemCount: albums.length,
controller: scrollController, controller: scrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemBuilder: (context, index) { child: Row(
if (index == albums.length - 1 && hasNextPage) { crossAxisAlignment: CrossAxisAlignment.start,
return const ShimmerPlaybuttonCard(count: 1); children: [
} ...albums.map((album) => AlbumCard(album)),
return AlbumCard(albums[index]); if (hasNextPage) const ShimmerPlaybuttonCard(count: 1),
}, ],
), ),
), ),
), ),
), ),
),
],
); );
} }
} }

View File

@ -7,6 +7,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/assets.gen.dart';
import 'package:spotube/collections/spotube_icons.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/compact_search.dart';
import 'package:spotube/components/shared/shimmers/shimmer_track_tile.dart'; import 'package:spotube/components/shared/shimmers/shimmer_track_tile.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart'; import 'package:spotube/components/shared/page_window_title_bar.dart';
@ -284,6 +285,17 @@ class TrackCollectionView<T> extends HookConsumerWidget {
fontWeight: FontWeight.w600, 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) if (description != null)
Text( Text(
description!, description!,

View File

@ -34,6 +34,7 @@ class ArtistPage extends HookConsumerWidget {
SpotifyApi spotify = ref.watch(spotifyProvider); SpotifyApi spotify = ref.watch(spotifyProvider);
final parentScrollController = useScrollController(); final parentScrollController = useScrollController();
final theme = Theme.of(context); final theme = Theme.of(context);
final scaffoldMessenger = ScaffoldMessenger.of(context);
final textTheme = theme.textTheme; final textTheme = theme.textTheme;
final chipTextVariant = useBreakpointValue( final chipTextVariant = useBreakpointValue(
sm: textTheme.bodySmall, sm: textTheme.bodySmall,
@ -126,7 +127,7 @@ class ArtistPage extends HookConsumerWidget {
BorderRadius.circular(50)), BorderRadius.circular(50)),
child: Text( child: Text(
data.type!.toUpperCase(), data.type!.toUpperCase(),
style: chipTextVariant?.copyWith( style: chipTextVariant.copyWith(
color: Colors.white, color: Colors.white,
), ),
), ),
@ -142,7 +143,7 @@ class ArtistPage extends HookConsumerWidget {
BorderRadius.circular(50)), BorderRadius.circular(50)),
child: Text( child: Text(
"Blacklisted", "Blacklisted",
style: chipTextVariant?.copyWith( style: chipTextVariant.copyWith(
color: Colors.white, color: Colors.white,
), ),
), ),
@ -262,8 +263,7 @@ class ArtistPage extends HookConsumerWidget {
text: data.externalUrls?.spotify), text: data.externalUrls?.spotify),
); );
ScaffoldMessenger.of(context) scaffoldMessenger.showSnackBar(
.showSnackBar(
const SnackBar( const SnackBar(
width: 300, width: 300,
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
@ -334,7 +334,7 @@ class ArtistPage extends HookConsumerWidget {
), ),
onPressed: () { onPressed: () {
playlistNotifier.add(topTracks.toList()); playlistNotifier.add(topTracks.toList());
ScaffoldMessenger.of(context).showSnackBar( scaffoldMessenger.showSnackBar(
SnackBar( SnackBar(
width: 300, width: 300,
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,