spotube/lib/pages/stats/fees/fees.dart
Kingkor Roy Tirtho 82307bc030
feat: personalized stats based on local music history (#1522)
* feat: add playback history provider

* feat: implement recently played section

* refactor: use route names

* feat: add stats summary and top tracks/artists/albums

* feat: add top date based filtering

* feat: add stream money calculation

* refactor: place search in mobile navbar and settings in home appbar

* feat: add individual minutes and streams page

* feat(stats): add individual minutes and streams page

* chore: default period to 1 month

* feat: add text to explain user how hypothetical fees are calculated

* chore: ensure usage of route names instead of direct paths

* cd: add cache key

* cd: remove media_kit_event_loop from git
2024-06-01 11:40:01 +06:00

66 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sliver_tools/sliver_tools.dart';
import 'package:spotube/collections/formatters.dart';
import 'package:spotube/components/shared/page_window_title_bar.dart';
import 'package:spotube/components/stats/common/artist_item.dart';
import 'package:spotube/provider/history/state.dart';
import 'package:spotube/provider/history/top.dart';
class StatsStreamFeesPage extends HookConsumerWidget {
static const name = "stats_stream_fees";
const StatsStreamFeesPage({super.key});
@override
Widget build(BuildContext context, ref) {
final ThemeData(:textTheme, :hintColor) = Theme.of(context);
final artists = ref.watch(
playbackHistoryTopProvider(HistoryDuration.days30)
.select((value) => value.artists),
);
return Scaffold(
appBar: const PageWindowTitleBar(
automaticallyImplyLeading: true,
centerTitle: false,
title: Text("Streaming fees (hypothetical)"),
),
body: CustomScrollView(
slivers: [
SliverCrossAxisConstrained(
maxCrossAxisExtent: 600,
alignment: -1,
child: SliverPadding(
padding: const EdgeInsets.all(16.0),
sliver: SliverToBoxAdapter(
child: Text(
"*This is calculated based on Spotify's per stream "
"payout of \$0.003 to \$0.005. This is a hypothetical "
"calculation to give user insight about how much they "
"would have paid to the artists if they were to listen "
"their song in Spotify.",
style: textTheme.bodySmall?.copyWith(
color: hintColor,
),
),
),
),
),
SliverList.builder(
itemCount: artists.length,
itemBuilder: (context, index) {
final artist = artists[index];
return StatsArtistItem(
artist: artist.artist,
info: Text(usdFormatter.format(artist.count * 0.005)),
);
},
),
],
),
);
}
}