mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
47 lines
1.6 KiB
Dart
47 lines
1.6 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
import 'package:spotube/collections/routes.gr.dart';
|
|
import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart';
|
|
import 'package:spotube/extensions/context.dart';
|
|
import 'package:spotube/provider/metadata_plugin/browse/sections.dart';
|
|
|
|
class HomePageBrowseSection extends HookConsumerWidget {
|
|
const HomePageBrowseSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final browseSections = ref.watch(metadataPluginBrowseSectionsProvider);
|
|
final sections = browseSections.asData?.value.items;
|
|
|
|
return SliverList.builder(
|
|
itemCount: sections?.length ?? 0,
|
|
itemBuilder: (context, index) {
|
|
final section = sections![index];
|
|
if (section.items.isEmpty) return const SizedBox.shrink();
|
|
|
|
return HorizontalPlaybuttonCardView(
|
|
items: section.items,
|
|
title: Text(section.title),
|
|
hasNextPage: false,
|
|
isLoadingNextPage: false,
|
|
onFetchMore: () {},
|
|
titleTrailing: section.browseMore
|
|
? Button.text(
|
|
child: Text(context.l10n.browse_all),
|
|
onPressed: () {
|
|
context.navigateTo(
|
|
HomeBrowseSectionItemsRoute(
|
|
sectionId: section.id,
|
|
section: section,
|
|
),
|
|
);
|
|
},
|
|
)
|
|
: null,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|