54 lines
1.6 KiB
Dart
54 lines
1.6 KiB
Dart
|
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!();
|
||
|
},
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|