change app name, add route calculator
This commit is contained in:
73
lib/components/calculator/routeSummaryWidget.dart
Normal file
73
lib/components/calculator/routeSummaryWidget.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
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;
|
||||
|
||||
const RouteDetailsView({
|
||||
super.key,
|
||||
required this.route,
|
||||
required this.costs,
|
||||
required this.onBack,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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) {
|
||||
return ListTile(
|
||||
title: Text(route[index]),
|
||||
trailing: Text("${costs[index].toStringAsFixed(2)} mi"),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user