Layout changes, fix bugs in new entry page
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mileograph_flutter/components/dashboard/latest_loco_changes_panel.dart';
|
||||
import 'package:mileograph_flutter/components/dashboard/leaderboard_panel.dart';
|
||||
import 'package:mileograph_flutter/components/dashboard/top_traction_panel.dart';
|
||||
import 'package:mileograph_flutter/objects/objects.dart';
|
||||
@@ -32,6 +33,7 @@ class _DashboardState extends State<Dashboard> {
|
||||
data.fetchOnThisDay(),
|
||||
data.fetchTripDetails(),
|
||||
data.fetchHadTraction(),
|
||||
data.fetchLatestLocoChanges(),
|
||||
]);
|
||||
},
|
||||
child: LayoutBuilder(
|
||||
@@ -41,7 +43,7 @@ class _DashboardState extends State<Dashboard> {
|
||||
context,
|
||||
totalMileage: stats?.totalMileage ?? 0,
|
||||
currentYearMileage: data.getMileageForCurrentYear(),
|
||||
trips: data.trips.length,
|
||||
legCount: stats?.legCount ?? data.trips.length,
|
||||
);
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -138,7 +140,7 @@ class _DashboardState extends State<Dashboard> {
|
||||
BuildContext context, {
|
||||
required double totalMileage,
|
||||
required double currentYearMileage,
|
||||
required int trips,
|
||||
required int legCount,
|
||||
}) {
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
Widget metricCard(String label, String value) {
|
||||
@@ -173,7 +175,7 @@ class _DashboardState extends State<Dashboard> {
|
||||
return [
|
||||
metricCard('Total mileage', '${totalMileage.toStringAsFixed(1)} mi'),
|
||||
metricCard('This year', '${currentYearMileage.toStringAsFixed(1)} mi'),
|
||||
metricCard('Trips logged', trips.toString()),
|
||||
metricCard('Entries logged', legCount.toString()),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -211,8 +213,6 @@ class _DashboardState extends State<Dashboard> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildQuickCalcCard(context),
|
||||
const SizedBox(height: 12),
|
||||
_buildTripsCard(context, data),
|
||||
],
|
||||
);
|
||||
@@ -220,10 +220,13 @@ class _DashboardState extends State<Dashboard> {
|
||||
|
||||
Widget _buildSidebar(BuildContext context, DataService data) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
TopTractionPanel(),
|
||||
const TopTractionPanel(),
|
||||
const SizedBox(height: 12),
|
||||
LeaderboardPanel(),
|
||||
const LeaderboardPanel(),
|
||||
const SizedBox(height: 12),
|
||||
const LatestLocoChangesPanel(),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -313,22 +316,6 @@ class _DashboardState extends State<Dashboard> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuickCalcCard(BuildContext context) {
|
||||
return _buildCard(
|
||||
context,
|
||||
title: 'Quick mileage calculator',
|
||||
action: TextButton.icon(
|
||||
onPressed: () => context.push('/calculator'),
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
label: const Text('Open calculator'),
|
||||
),
|
||||
child: Text(
|
||||
'Jump into the route calculator to quickly total a journey before saving it.',
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTripsCard(BuildContext context, DataService data) {
|
||||
final tripsUnsorted = data.trips;
|
||||
List trips = [];
|
||||
@@ -353,7 +340,6 @@ class _DashboardState extends State<Dashboard> {
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(trip.tripName),
|
||||
subtitle: Text('${trip.tripMileage.toStringAsFixed(1)} mi'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user