mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
30 lines
992 B
Dart
30 lines
992 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:spotube/collections/formatters.dart';
|
|
import 'package:spotube/modules/stats/common/artist_item.dart';
|
|
import 'package:spotube/provider/history/top.dart';
|
|
|
|
class TopArtists extends HookConsumerWidget {
|
|
const TopArtists({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, ref) {
|
|
final historyDuration = ref.watch(playbackHistoryTopDurationProvider);
|
|
final artists = ref.watch(playbackHistoryTopProvider(historyDuration)
|
|
.select((value) => value.whenData((s) => s.artists)));
|
|
|
|
final artistsData = artists.asData?.value ?? [];
|
|
|
|
return SliverList.builder(
|
|
itemCount: artistsData.length,
|
|
itemBuilder: (context, index) {
|
|
final artist = artistsData[index];
|
|
return StatsArtistItem(
|
|
artist: artist.artist,
|
|
info: Text("${compactNumberFormatter.format(artist.count)} plays"),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|