mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-29 21:02:09 +02:00
149 lines
4.3 KiB
Dart
149 lines
4.3 KiB
Dart
part of 'queue_tab.dart';
|
|
|
|
class _QueueItemSliverRow extends ConsumerWidget {
|
|
final String itemId;
|
|
final ColorScheme colorScheme;
|
|
final Widget Function(BuildContext, DownloadItem, ColorScheme) itemBuilder;
|
|
|
|
const _QueueItemSliverRow({
|
|
super.key,
|
|
required this.itemId,
|
|
required this.colorScheme,
|
|
required this.itemBuilder,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final item = ref.watch(
|
|
downloadQueueLookupProvider.select((lookup) => lookup.byItemId[itemId]),
|
|
);
|
|
if (item == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
return RepaintBoundary(child: itemBuilder(context, item, colorScheme));
|
|
}
|
|
}
|
|
|
|
enum _CollectionEntryType { wishlist, loved, favoriteArtists, playlist }
|
|
|
|
class _CollectionEntry {
|
|
final _CollectionEntryType type;
|
|
final int playlistIndex;
|
|
|
|
const _CollectionEntry._(this.type, [this.playlistIndex = -1]);
|
|
|
|
static const wishlist = _CollectionEntry._(_CollectionEntryType.wishlist);
|
|
static const loved = _CollectionEntry._(_CollectionEntryType.loved);
|
|
static const favoriteArtists = _CollectionEntry._(
|
|
_CollectionEntryType.favoriteArtists,
|
|
);
|
|
static _CollectionEntry playlist(int index) =>
|
|
_CollectionEntry._(_CollectionEntryType.playlist, index);
|
|
}
|
|
|
|
class _FilterChip extends ConsumerWidget {
|
|
final String label;
|
|
final int count;
|
|
final bool isSelected;
|
|
final VoidCallback onTap;
|
|
|
|
const _FilterChip({
|
|
required this.label,
|
|
required this.count,
|
|
required this.isSelected,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
final mornye = context.isMornye;
|
|
|
|
final content = Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
label,
|
|
style: mornye
|
|
? Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: isSelected
|
|
? colorScheme.onSurface
|
|
: colorScheme.onSurfaceVariant,
|
|
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,
|
|
)
|
|
: null,
|
|
),
|
|
const SizedBox(width: 6),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: isSelected
|
|
? colorScheme.primary.withValues(alpha: 0.2)
|
|
: colorScheme.outline.withValues(alpha: 0.2),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Text(
|
|
count.toString(),
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
color: isSelected
|
|
? colorScheme.onPrimaryContainer
|
|
: colorScheme.onSurfaceVariant,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
|
|
if (mornye) {
|
|
return Semantics(
|
|
button: true,
|
|
selected: isSelected,
|
|
label: '$label, $count',
|
|
excludeSemantics: true,
|
|
onTap: onTap,
|
|
child: MornyeGlass(
|
|
radius: 22,
|
|
blurEnabled:
|
|
!ref.watch(lowEndDeviceProvider) ||
|
|
ref.watch(backdropBlurEnabledProvider),
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
borderRadius: BorderRadius.circular(22),
|
|
child: AnimatedContainer(
|
|
duration: MediaQuery.disableAnimationsOf(context)
|
|
? Duration.zero
|
|
: context.tokens.motionFast,
|
|
constraints: const BoxConstraints(minHeight: 44),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 10,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: isSelected
|
|
? colorScheme.primary.withValues(alpha: 0.10)
|
|
: Colors.transparent,
|
|
borderRadius: BorderRadius.circular(22),
|
|
),
|
|
child: content,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
return AppChoiceChip(
|
|
label: Text(label),
|
|
count: count,
|
|
singleChoice: true,
|
|
selected: isSelected,
|
|
onSelected: (_) => onTap(),
|
|
);
|
|
}
|
|
}
|