Fix trips on entry page, correct order of trips on dashboard and trip page, move to prod api
This commit is contained in:
@@ -39,11 +39,7 @@ class Dashboard extends StatelessWidget {
|
||||
children: [
|
||||
_buildHeader(context, auth, stats, data.isHomepageLoading),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: metricChips,
|
||||
),
|
||||
Wrap(spacing: 12, runSpacing: 12, children: metricChips),
|
||||
const SizedBox(height: 16),
|
||||
isWide
|
||||
? Row(
|
||||
@@ -71,8 +67,12 @@ class Dashboard extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context, AuthService auth,
|
||||
HomepageStats? stats, bool loading) {
|
||||
Widget _buildHeader(
|
||||
BuildContext context,
|
||||
AuthService auth,
|
||||
HomepageStats? stats,
|
||||
bool loading,
|
||||
) {
|
||||
final greetingName =
|
||||
stats?.user?.full_name ?? auth.fullName ?? auth.username ?? 'there';
|
||||
return Row(
|
||||
@@ -82,10 +82,7 @@ class Dashboard extends StatelessWidget {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Dashboard',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
Text('Dashboard', style: Theme.of(context).textTheme.labelMedium),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'Welcome back, $greetingName',
|
||||
@@ -93,14 +90,15 @@ class Dashboard extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
if (loading) const Padding(
|
||||
padding: EdgeInsets.only(right: 8.0),
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
if (loading)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(right: 8.0),
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -121,11 +119,13 @@ class Dashboard extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label.toUpperCase(),
|
||||
style: textTheme.labelSmall?.copyWith(
|
||||
letterSpacing: 0.7,
|
||||
color: textTheme.bodySmall?.color?.withOpacity(0.7),
|
||||
)),
|
||||
Text(
|
||||
label.toUpperCase(),
|
||||
style: textTheme.labelSmall?.copyWith(
|
||||
letterSpacing: 0.7,
|
||||
color: textTheme.bodySmall?.color?.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
@@ -203,10 +203,9 @@ class Dashboard extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.w700),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -234,10 +233,7 @@ class Dashboard extends StatelessWidget {
|
||||
required String emptyMessage,
|
||||
}) {
|
||||
if (legs.isEmpty) {
|
||||
return Text(
|
||||
emptyMessage,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
);
|
||||
return Text(emptyMessage, style: Theme.of(context).textTheme.bodyMedium);
|
||||
}
|
||||
return Column(
|
||||
children: legs.take(5).map((leg) {
|
||||
@@ -257,10 +253,9 @@ class Dashboard extends StatelessWidget {
|
||||
if (leg.headcode.isNotEmpty)
|
||||
Text(
|
||||
leg.headcode,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall
|
||||
?.copyWith(color: Theme.of(context).hintColor),
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -286,7 +281,11 @@ class Dashboard extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildTripsCard(BuildContext context, DataService data) {
|
||||
final trips = data.trips;
|
||||
final trips_unsorted = data.trips;
|
||||
List trips = [];
|
||||
if (trips_unsorted.isNotEmpty) {
|
||||
trips = [...trips_unsorted]..sort((a, b) => b.tripId.compareTo(a.tripId));
|
||||
}
|
||||
return _buildCard(
|
||||
context,
|
||||
title: 'Trips',
|
||||
|
||||
@@ -38,6 +38,8 @@ class _TractionPageState extends State<TractionPage> {
|
||||
final _domainController = TextEditingController();
|
||||
final _typeController = TextEditingController();
|
||||
|
||||
int offset = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -239,40 +241,39 @@ class _TractionPageState extends State<TractionPage> {
|
||||
onSubmitted: (_) => _refreshTraction(),
|
||||
);
|
||||
},
|
||||
optionsViewBuilder:
|
||||
(context, onSelected, options) {
|
||||
final optionList = options.toList();
|
||||
if (optionList.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final maxWidth = isMobile
|
||||
? MediaQuery.of(context).size.width - 64
|
||||
: 240.0;
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: maxWidth,
|
||||
maxHeight: 240,
|
||||
),
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: optionList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final option = optionList[index];
|
||||
return ListTile(
|
||||
title: Text(option),
|
||||
onTap: () => onSelected(option),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
optionsViewBuilder: (context, onSelected, options) {
|
||||
final optionList = options.toList();
|
||||
if (optionList.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final maxWidth = isMobile
|
||||
? MediaQuery.of(context).size.width - 64
|
||||
: 240.0;
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: maxWidth,
|
||||
maxHeight: 240,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: optionList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final option = optionList[index];
|
||||
return ListTile(
|
||||
title: Text(option),
|
||||
onTap: () => onSelected(option),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
onSelected: (String selection) {
|
||||
setState(() {
|
||||
_selectedClass = selection;
|
||||
@@ -306,7 +307,7 @@ class _TractionPageState extends State<TractionPage> {
|
||||
),
|
||||
FilterChip(
|
||||
label: Text(
|
||||
_mileageFirst ? 'Mileage first' : 'Had first',
|
||||
_mileageFirst ? 'Mileage first' : 'Number order',
|
||||
),
|
||||
selected: _mileageFirst,
|
||||
onSelected: (v) {
|
||||
|
||||
@@ -46,11 +46,15 @@ class _TripsPageState extends State<TripsPage> {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Journeys',
|
||||
style: Theme.of(context).textTheme.labelMedium),
|
||||
Text(
|
||||
'Journeys',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text('Trips',
|
||||
style: Theme.of(context).textTheme.headlineSmall),
|
||||
Text(
|
||||
'Trips',
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
@@ -81,10 +85,9 @@ class _TripsPageState extends State<TripsPage> {
|
||||
children: [
|
||||
Text(
|
||||
'No trips yet',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.w700),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
@@ -101,8 +104,9 @@ class _TripsPageState extends State<TripsPage> {
|
||||
(trip) => Card(
|
||||
child: ListTile(
|
||||
title: Text(trip.tripName),
|
||||
subtitle:
|
||||
Text('${trip.tripMileage.toStringAsFixed(1)} mi'),
|
||||
subtitle: Text(
|
||||
'${trip.tripMileage.toStringAsFixed(1)} mi',
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -110,8 +114,9 @@ class _TripsPageState extends State<TripsPage> {
|
||||
)
|
||||
else
|
||||
Column(
|
||||
children:
|
||||
tripDetails.map((trip) => _buildTripCard(context, trip, isMobile)).toList(),
|
||||
children: tripDetails
|
||||
.map((trip) => _buildTripCard(context, trip, isMobile))
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -134,10 +139,9 @@ class _TripsPageState extends State<TripsPage> {
|
||||
children: [
|
||||
Text(
|
||||
trip.name,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.w700),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${trip.mileage.toStringAsFixed(1)} mi · ${trip.legCount} legs',
|
||||
@@ -145,10 +149,20 @@ class _TripsPageState extends State<TripsPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
tooltip: 'Details',
|
||||
onPressed: () => _showTripDetail(context, trip),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.train),
|
||||
tooltip: 'Traction',
|
||||
onPressed: () => _showTripWinners(context, trip),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.open_in_new),
|
||||
tooltip: 'Details',
|
||||
onPressed: () => _showTripDetail(context, trip),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -168,10 +182,9 @@ class _TripsPageState extends State<TripsPage> {
|
||||
),
|
||||
trailing: Text(
|
||||
leg.mileage?.toStringAsFixed(1) ?? '-',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
style: Theme.of(context).textTheme.labelLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
@@ -215,10 +228,9 @@ class _TripsPageState extends State<TripsPage> {
|
||||
),
|
||||
Text(
|
||||
trip.name,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text('${trip.mileage.toStringAsFixed(1)} mi'),
|
||||
@@ -237,9 +249,63 @@ class _TripsPageState extends State<TripsPage> {
|
||||
subtitle: Text(_formatDate(leg.beginTime)),
|
||||
trailing: Text(
|
||||
leg.mileage?.toStringAsFixed(1) ?? '-',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge
|
||||
style: Theme.of(context).textTheme.labelLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showTripWinners(BuildContext context, TripDetail trip) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (_) {
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
Text(
|
||||
trip.name,
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text('${trip.mileage.toStringAsFixed(1)} mi'),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
child: ListView.builder(
|
||||
itemCount: trip.legs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final leg = trip.legs[index];
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.train),
|
||||
title: Text('${leg.start} → ${leg.end}'),
|
||||
subtitle: Text(_formatDate(leg.beginTime)),
|
||||
trailing: Text(
|
||||
leg.mileage?.toStringAsFixed(1) ?? '-',
|
||||
style: Theme.of(context).textTheme.labelLarge
|
||||
?.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user