mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
47 lines
1.7 KiB
Dart
47 lines
1.7 KiB
Dart
import 'package:flutter_undraw/flutter_undraw.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
|
import 'package:skeletonizer/skeletonizer.dart';
|
|
import 'package:spotify/spotify.dart';
|
|
import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/provider/spotify/spotify.dart';
|
|
|
|
class HomeFeaturedSection extends HookConsumerWidget {
|
|
const HomeFeaturedSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final featuredPlaylists = ref.watch(featuredPlaylistsProvider);
|
|
final featuredPlaylistsNotifier =
|
|
ref.watch(featuredPlaylistsProvider.notifier);
|
|
|
|
if (featuredPlaylists.hasError) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Undraw(
|
|
illustration: UndrawIllustration.fixingBugs,
|
|
height: 200 * context.theme.scaling,
|
|
color: context.theme.colorScheme.primary,
|
|
),
|
|
Text(context.l10n.something_went_wrong).small().muted(),
|
|
const Gap(8),
|
|
],
|
|
);
|
|
}
|
|
|
|
return Skeletonizer(
|
|
enabled: featuredPlaylists.isLoading,
|
|
child: HorizontalPlaybuttonCardView<PlaylistSimple>(
|
|
items: featuredPlaylists.asData?.value.items ?? [],
|
|
title: Text(context.l10n.featured),
|
|
isLoadingNextPage: featuredPlaylists.isLoadingNextPage,
|
|
hasNextPage: featuredPlaylists.asData?.value.hasMore ?? false,
|
|
onFetchMore: featuredPlaylistsNotifier.fetchMore,
|
|
),
|
|
);
|
|
}
|
|
}
|