RhythmBox/lib/widgets/album/album_card.dart

54 lines
1.6 KiB
Dart
Raw Normal View History

2024-08-29 17:38:02 +00:00
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: () {
2024-08-30 05:43:29 +00:00
if (onTap == null) return;
2024-08-29 17:38:02 +00:00
onTap!();
},
),
);
}
}