dashboard overhaul
All checks were successful
All checks were successful
This commit is contained in:
@@ -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),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user