mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
121 lines
3.9 KiB
Dart
121 lines
3.9 KiB
Dart
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'package:spotify/spotify.dart';
|
|
import 'package:spotube/components/shared/image/universal_image.dart';
|
|
import 'package:spotube/hooks/use_breakpoint_value.dart';
|
|
import 'package:spotube/hooks/use_brightness_value.dart';
|
|
import 'package:spotube/provider/blacklist_provider.dart';
|
|
import 'package:spotube/utils/service_utils.dart';
|
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
|
|
|
class ArtistCard extends HookConsumerWidget {
|
|
final Artist artist;
|
|
const ArtistCard(this.artist, {Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final theme = Theme.of(context);
|
|
final backgroundImage = UniversalImage.imageProvider(
|
|
TypeConversionUtils.image_X_UrlString(
|
|
artist.images,
|
|
placeholder: ImagePlaceholder.artist,
|
|
),
|
|
);
|
|
final isBlackListed = ref.watch(
|
|
BlackListNotifier.provider.select(
|
|
(blacklist) => blacklist.contains(
|
|
BlacklistedElement.artist(artist.id!, artist.name!),
|
|
),
|
|
),
|
|
);
|
|
|
|
final radius = BorderRadius.circular(15);
|
|
|
|
final double size = useBreakpointValue<double>(
|
|
sm: 130,
|
|
md: 150,
|
|
others: 170,
|
|
);
|
|
|
|
return Container(
|
|
width: size,
|
|
margin: const EdgeInsets.symmetric(vertical: 5),
|
|
child: Material(
|
|
shadowColor: theme.colorScheme.background,
|
|
color: Color.lerp(
|
|
theme.colorScheme.surfaceVariant,
|
|
theme.colorScheme.surface,
|
|
useBrightnessValue(.9, .7),
|
|
),
|
|
elevation: 3,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: radius,
|
|
side: isBlackListed
|
|
? const BorderSide(
|
|
color: Colors.red,
|
|
width: 2,
|
|
)
|
|
: BorderSide.none,
|
|
),
|
|
child: InkWell(
|
|
onTap: () {
|
|
ServiceUtils.navigate(context, "/artist/${artist.id}");
|
|
},
|
|
borderRadius: radius,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Column(
|
|
children: [
|
|
Stack(
|
|
children: [
|
|
ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxHeight: size,
|
|
),
|
|
child: CircleAvatar(
|
|
backgroundImage: backgroundImage,
|
|
radius: size / 2,
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 10,
|
|
vertical: 5,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: Colors.blue,
|
|
borderRadius: BorderRadius.circular(50)),
|
|
child: const Text(
|
|
"Artist",
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 10),
|
|
AutoSizeText(
|
|
artist.name!,
|
|
maxLines: 1,
|
|
textAlign: TextAlign.center,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
),
|
|
);
|
|
}
|
|
}
|