dashboard overhaul
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 7m15s
Release / android-build (push) Successful in 18m37s
Release / release-master (push) Successful in 23s
Release / release-dev (push) Successful in 26s

This commit is contained in:
2025-12-22 19:39:50 +00:00
parent 7feb672e7e
commit b1a8f7baf4
6 changed files with 659 additions and 283 deletions

View File

@@ -38,9 +38,25 @@ class _LatestLocoChangesPanelState extends State<LatestLocoChangesPanel> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Latest loco changes',
style: textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),
Row(
children: [
const Icon(Icons.bolt, size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(
'Latest loco changes',
style: textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800,
),
),
),
if (isLoading && changes.isNotEmpty)
const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
),
],
),
const SizedBox(height: 8),
if (isLoading && changes.isEmpty)

View File

@@ -10,6 +10,7 @@ class LeaderboardPanel extends StatelessWidget {
Widget build(BuildContext context) {
final data = context.watch<DataService>();
final leaderboard = data.homepageStats?.leaderboard ?? [];
final textTheme = Theme.of(context).textTheme;
if (data.isHomepageLoading && leaderboard.isEmpty) {
return const Padding(
padding: EdgeInsets.all(16.0),
@@ -23,12 +24,32 @@ class LeaderboardPanel extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Leaderboard",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
Row(
children: [
const Icon(Icons.emoji_events, size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(
"Leaderboard",
style: textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800,
),
),
),
if (leaderboard.isNotEmpty)
Container(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(10),
),
child: Text(
'Top ${leaderboard.length}',
style: textTheme.labelSmall,
),
),
],
),
const SizedBox(height: 8),
if (leaderboard.isEmpty)
@@ -38,43 +59,38 @@ class LeaderboardPanel extends StatelessWidget {
)
else
Column(
children: List.generate(
leaderboard.length,
(index) {
final leaderboardEntry = leaderboard[index];
return Container(
width: double.infinity,
margin: const EdgeInsets.symmetric(
horizontal: 0, vertical: 8),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text.rich(
TextSpan(
children: [
TextSpan(
text: '${index + 1}. ',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
TextSpan(
text: leaderboardEntry.userFullName,
),
],
),
),
Text(
'${leaderboardEntry.mileage.toStringAsFixed(1)} mi',
),
],
children: [
for (int index = 0; index < leaderboard.length; index++) ...[
ListTile(
contentPadding: EdgeInsets.zero,
dense: true,
leading: CircleAvatar(
radius: 18,
backgroundColor:
Theme.of(context).colorScheme.secondaryContainer,
child: Text(
'${index + 1}',
style: textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w800,
),
),
),
);
},
),
title: Text(
leaderboard[index].userFullName,
style: textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w700,
),
),
trailing: Text(
'${leaderboard[index].mileage.toStringAsFixed(1)} mi',
style: textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w700,
),
),
),
if (index != leaderboard.length - 1) const Divider(height: 12),
],
],
),
],
),

View File

@@ -11,6 +11,7 @@ class TopTractionPanel extends StatelessWidget {
final data = context.watch<DataService>();
final stats = data.homepageStats;
final locos = stats?.topLocos ?? [];
final textTheme = Theme.of(context).textTheme;
if (data.isHomepageLoading && locos.isEmpty) {
return const Padding(
padding: EdgeInsets.all(16.0),
@@ -24,12 +25,19 @@ class TopTractionPanel extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Top Traction",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
Row(
children: [
const Icon(Icons.train, size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(
"Top traction",
style: textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800,
),
),
),
],
),
const SizedBox(height: 8),
if (locos.isEmpty)
@@ -39,52 +47,46 @@ class TopTractionPanel extends StatelessWidget {
)
else
Column(
children: List.generate(
locos.length,
(index) {
final loco = locos[index];
return Container(
width: double.infinity,
margin:
const EdgeInsets.symmetric(horizontal: 0, vertical: 8),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text.rich(
TextSpan(
children: [
TextSpan(
text: '${index + 1}. ',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
TextSpan(
text:
'${loco.locoClass} ${loco.number}',
),
],
),
),
Text(
loco.name ?? '',
style:
const TextStyle(fontStyle: FontStyle.italic),
),
],
),
Text('${loco.mileage?.toStringAsFixed(1)} mi'),
],
children: [
for (int index = 0; index < locos.length; index++) ...[
ListTile(
contentPadding: EdgeInsets.zero,
dense: true,
leading: CircleAvatar(
radius: 18,
backgroundColor:
Theme.of(context).colorScheme.primaryContainer,
child: Text(
'${index + 1}',
style: textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w800,
),
),
),
);
},
),
title: Text(
'${locos[index].locoClass} ${locos[index].number}',
style: textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w700,
),
),
subtitle: (locos[index].name ?? '').isEmpty
? null
: Text(
locos[index].name ?? '',
style: textTheme.bodySmall?.copyWith(
fontStyle: FontStyle.italic,
),
),
trailing: Text(
'${locos[index].mileage?.toStringAsFixed(1)} mi',
style: textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w700,
),
),
),
if (index != locos.length - 1) const Divider(height: 12),
],
],
),
],
),