Files
mileograph_flutter/lib/components/calculator/route_summary_widget.dart
Pete Gregory 44d79e7c28
All checks were successful
Release / meta (push) Successful in 9s
Release / linux-build (push) Successful in 8m3s
Release / android-build (push) Successful in 19m21s
Release / release-master (push) Successful in 40s
Release / release-dev (push) Successful in 42s
Improve entries page and latest changes panel, units on events and timeline
2025-12-23 17:41:21 +00:00

90 lines
2.3 KiB
Dart

import 'package:flutter/material.dart';
class RouteSummaryWidget extends StatelessWidget {
final double distance;
final VoidCallback onDetailsPressed;
const RouteSummaryWidget({
super.key,
required this.distance,
required this.onDetailsPressed,
});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Expanded(
child: Text(
"Total Distance: ${distance.toStringAsFixed(2)} mi",
style: Theme.of(context).textTheme.titleMedium,
),
),
TextButton(
onPressed: onDetailsPressed,
child: const Text("View Details"),
),
],
),
);
}
}
class RouteDetailsView extends StatelessWidget {
final List<String> route;
final List<double> costs;
final VoidCallback onBack;
final Set<String> routingPoints;
const RouteDetailsView({
super.key,
required this.route,
required this.costs,
required this.onBack,
this.routingPoints = const {},
});
@override
Widget build(BuildContext context) {
final highlightColor = Theme.of(context).colorScheme.primary;
final mutedColor = Theme.of(context).colorScheme.outlineVariant;
return Column(
children: [
Align(
alignment: Alignment.centerLeft,
child: TextButton.icon(
onPressed: onBack,
icon: const Icon(Icons.arrow_back),
label: const Text('Back'),
),
),
Expanded(
child: ListView.builder(
itemCount: route.length,
itemBuilder: (context, index) {
final label = route[index];
final isRoutingPoint = routingPoints.contains(label);
return ListTile(
leading: Icon(
Icons.circle,
size: 12,
color: isRoutingPoint ? highlightColor : mutedColor,
),
title: Text(
label,
style: isRoutingPoint
? TextStyle(color: highlightColor, fontWeight: FontWeight.w600)
: null,
),
trailing: Text("${costs[index].toStringAsFixed(2)} mi"),
);
},
),
),
],
);
}
}