Skip to content
Snippets Groups Projects
statistics_content.dart 2.13 KiB
Newer Older
  • Learn to ignore specific revisions
  • import 'package:easy_localization/easy_localization.dart';
    import 'package:flutter/material.dart';
    
    import '../../../models/statistics.dart';
    
    class StatisticsContent extends StatelessWidget {
      final StatisticsData statistics;
      final bool isLoading;
    
      const StatisticsContent({super.key, required this.statistics, required this.isLoading});
    
      @override
      Widget build(BuildContext context) {
        final TextTheme textTheme = Theme.of(context).primaryTextTheme;
    
        final String placeholder = '⏳';
    
        return Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Text(
              'global_statistics',
              style: textTheme.titleLarge!.apply(fontWeightDelta: 2),
            ).tr(),
            Text(
              'statistics_total_scrobbles_count',
              style: textTheme.bodyMedium,
            ).tr(
              namedArgs: {
                'count': this.isLoading ? placeholder : this.statistics.totalCount.toString(),
              },
            ),
            Text(
              'statistics_last_scrobble',
              style: textTheme.bodyMedium,
            ).tr(
              namedArgs: {
                'datetime': this.isLoading
                    ? placeholder
                    : DateFormat().format(this.statistics.lastScrobble),
              },
            ),
            Text(
              'statistics_selected_period',
    
    Benoît Harrault's avatar
    Benoît Harrault committed
              style: textTheme.bodyMedium!.apply(fontWeightDelta: 2),
    
            ).tr(
              namedArgs: {
                'daysCount':
                    this.isLoading ? placeholder : this.statistics.selectedPeriod.toString(),
              },
            ),
            Text(
    
    Benoît Harrault's avatar
    Benoît Harrault committed
              'statistics_recent_scrobbles_count_and_discoveries',
    
              style: textTheme.bodyMedium,
            ).tr(
              namedArgs: {
                'count': this.isLoading ? placeholder : this.statistics.recentCount.toString(),
                'artistsCount': this.isLoading
                    ? placeholder
                    : this.statistics.firstPlayedArtistsCount.toString(),
                'tracksCount': this.isLoading
                    ? placeholder
                    : this.statistics.firstPlayedTracksCount.toString(),
              },
            ),
          ],
        );
      }
    }