✨ Better explore
This commit is contained in:
53
lib/widgets/album/album_card.dart
Normal file
53
lib/widgets/album/album_card.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rhythm_box/widgets/auto_cache_image.dart';
|
||||
import 'package:rhythm_box/services/artist.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
|
||||
class AlbumCard extends StatelessWidget {
|
||||
final AlbumSimple? item;
|
||||
|
||||
final Function? onTap;
|
||||
|
||||
const AlbumCard({super.key, required this.item, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: (item?.images?.isNotEmpty ?? false)
|
||||
? AutoCacheImage(item!.images!.first.url!)
|
||||
: const Center(child: Icon(Icons.image)),
|
||||
),
|
||||
).paddingSymmetric(vertical: 8),
|
||||
Text(
|
||||
item?.name ?? 'Loading...',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
item?.artists?.asString() ?? 'Please stand by...',
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 8),
|
||||
onTap: () {
|
||||
if (onTap != null) return;
|
||||
onTap!();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -109,6 +109,7 @@ class _SyncedLyricsState extends State<SyncedLyrics> {
|
||||
final size = MediaQuery.of(context).size;
|
||||
|
||||
return CustomScrollView(
|
||||
cacheExtent: 10000,
|
||||
controller: _autoScrollController,
|
||||
slivers: [
|
||||
if (_lyric == null)
|
||||
@ -164,6 +165,9 @@ class _SyncedLyricsState extends State<SyncedLyrics> {
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
onTap: () async {
|
||||
final time = Duration(
|
||||
seconds: lyricSlice.time.inSeconds -
|
||||
@ -184,7 +188,7 @@ class _SyncedLyricsState extends State<SyncedLyrics> {
|
||||
: _unFocusColor,
|
||||
),
|
||||
duration: 500.ms,
|
||||
curve: Curves.easeInOut,
|
||||
curve: Curves.decelerate,
|
||||
child: Text(
|
||||
lyricSlice.text,
|
||||
textAlign:
|
||||
|
52
lib/widgets/playlist/playlist_card.dart
Normal file
52
lib/widgets/playlist/playlist_card.dart
Normal file
@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rhythm_box/widgets/auto_cache_image.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
|
||||
class PlaylistCard extends StatelessWidget {
|
||||
final PlaylistSimple? item;
|
||||
|
||||
final Function? onTap;
|
||||
|
||||
const PlaylistCard({super.key, required this.item, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: (item?.images?.isNotEmpty ?? false)
|
||||
? AutoCacheImage(item!.images!.first.url!)
|
||||
: const Center(child: Icon(Icons.image)),
|
||||
),
|
||||
).paddingSymmetric(vertical: 8),
|
||||
Text(
|
||||
item?.name ?? 'Loading...',
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
item?.description ?? 'Please stand by...',
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 8),
|
||||
onTap: () {
|
||||
if (onTap != null) return;
|
||||
onTap!();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
74
lib/widgets/playlist/playlist_section.dart
Normal file
74
lib/widgets/playlist/playlist_section.dart
Normal file
@ -0,0 +1,74 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:rhythm_box/widgets/album/album_card.dart';
|
||||
import 'package:rhythm_box/widgets/playlist/playlist_card.dart';
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
|
||||
class PlaylistSection extends StatelessWidget {
|
||||
final bool isLoading;
|
||||
final String title;
|
||||
final List<Object>? list;
|
||||
|
||||
const PlaylistSection({
|
||||
super.key,
|
||||
required this.isLoading,
|
||||
required this.title,
|
||||
required this.list,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
).paddingOnly(left: 32, right: 32, bottom: 4),
|
||||
SizedBox(
|
||||
height: 280,
|
||||
width: double.infinity,
|
||||
child: Skeletonizer(
|
||||
enabled: isLoading,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: list?.length ?? 20,
|
||||
itemBuilder: (context, idx) {
|
||||
final item = list?[idx];
|
||||
return SizedBox(
|
||||
width: 180,
|
||||
height: 180,
|
||||
child: switch (item.runtimeType) {
|
||||
const (AlbumSimple) || const (Album) => AlbumCard(
|
||||
item: item as AlbumSimple?,
|
||||
onTap: () {
|
||||
if (item == null) return;
|
||||
GoRouter.of(context).pushNamed(
|
||||
'playlistView',
|
||||
pathParameters: {'id': item.id!},
|
||||
);
|
||||
},
|
||||
),
|
||||
_ => PlaylistCard(
|
||||
item: item as PlaylistSimple?,
|
||||
onTap: () {
|
||||
if (item == null) return;
|
||||
GoRouter.of(context).pushNamed(
|
||||
'playlistView',
|
||||
pathParameters: {'id': item.id!},
|
||||
);
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user