mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
40 lines
1.2 KiB
Dart
40 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:skeletonizer/skeletonizer.dart';
|
|
import 'package:spotube/collections/fake.dart';
|
|
import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart';
|
|
import 'package:spotube/models/database/database.dart';
|
|
import 'package:spotube/provider/history/recent.dart';
|
|
|
|
class HomeRecentlyPlayedSection extends HookConsumerWidget {
|
|
const HomeRecentlyPlayedSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final history = ref.watch(recentlyPlayedItems);
|
|
final historyData =
|
|
history.asData?.value ?? FakeData.historyRecentlyPlayedItems;
|
|
|
|
if (history.asData?.value.isEmpty == true) {
|
|
return const SizedBox();
|
|
}
|
|
|
|
return Skeletonizer(
|
|
enabled: history.isLoading,
|
|
child: HorizontalPlaybuttonCardView(
|
|
title: const Text('Recently Played'),
|
|
items: [
|
|
for (final item in historyData)
|
|
if (item.playlist != null)
|
|
item.playlist
|
|
else if (item.album != null)
|
|
item.album
|
|
],
|
|
hasNextPage: false,
|
|
isLoadingNextPage: false,
|
|
onFetchMore: () {},
|
|
),
|
|
);
|
|
}
|
|
}
|