Added class clearance fixes and improvements
Some checks failed
Release / meta (push) Successful in 18s
Release / android-build (push) Successful in 11m48s
Release / linux-build (push) Successful in 1m24s
Release / web-build (push) Successful in 6m15s
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
Some checks failed
Release / meta (push) Successful in 18s
Release / android-build (push) Successful in 11m48s
Release / linux-build (push) Successful in 1m24s
Release / web-build (push) Successful in 6m15s
Release / release-dev (push) Has been cancelled
Release / release-master (push) Has been cancelled
This commit is contained in:
@@ -141,6 +141,7 @@ class _StatsPageState extends State<StatsPage> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildTypeCountsSection(context, year),
|
||||
_buildSection<StatsClassMileage>(
|
||||
context,
|
||||
title: 'Top classes',
|
||||
@@ -201,6 +202,83 @@ class _StatsPageState extends State<StatsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
List<MapEntry<String, int>> _sortedTypeCounts(Map<String, int> counts) {
|
||||
final entries = counts.entries.toList();
|
||||
entries.sort((a, b) {
|
||||
final countCompare = b.value.compareTo(a.value);
|
||||
if (countCompare != 0) return countCompare;
|
||||
return a.key.compareTo(b.key);
|
||||
});
|
||||
return entries;
|
||||
}
|
||||
|
||||
Widget _buildTypeCountsSection(BuildContext context, StatsYear year) {
|
||||
if (year.winnerTypeCounts.isEmpty && year.totalTypeCounts.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Type counts',
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildTypeCountsRow(
|
||||
context,
|
||||
label: 'Winners',
|
||||
counts: year.winnerTypeCounts,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildTypeCountsRow(
|
||||
context,
|
||||
label: 'Total',
|
||||
counts: year.totalTypeCounts,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTypeCountsRow(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required Map<String, int> counts,
|
||||
}) {
|
||||
final theme = Theme.of(context);
|
||||
final entries = _sortedTypeCounts(counts);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: theme.textTheme.labelLarge,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
if (entries.isEmpty)
|
||||
Text(
|
||||
'No data',
|
||||
style: theme.textTheme.bodySmall,
|
||||
)
|
||||
else
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 6,
|
||||
children: entries
|
||||
.map((entry) => _buildInfoChip(
|
||||
context,
|
||||
label: entry.key,
|
||||
value: _countFormat.format(entry.value),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSection<T>(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
|
||||
Reference in New Issue
Block a user