add support for network calculation from the calculator
All checks were successful
Release / meta (push) Successful in 1m39s
Release / linux-build (push) Successful in 1m55s
Release / web-build (push) Successful in 3m12s
Release / android-build (push) Successful in 6m48s
Release / release-master (push) Successful in 22s
Release / release-dev (push) Successful in 28s
All checks were successful
Release / meta (push) Successful in 1m39s
Release / linux-build (push) Successful in 1m55s
Release / web-build (push) Successful in 3m12s
Release / android-build (push) Successful in 6m48s
Release / release-master (push) Successful in 22s
Release / release-dev (push) Successful in 28s
This commit is contained in:
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mileograph_flutter/components/calculator/route_summary_widget.dart';
|
||||
import 'package:mileograph_flutter/objects/objects.dart';
|
||||
import 'package:mileograph_flutter/services/distance_unit_service.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CalculatorDetailsPage extends StatelessWidget {
|
||||
const CalculatorDetailsPage({
|
||||
@@ -34,13 +36,85 @@ class CalculatorDetailsPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: RouteDetailsView(
|
||||
route: parsed.calculatedRoute,
|
||||
costs: parsed.costs,
|
||||
routingPoints: parsed.inputRoute.toSet(),
|
||||
onBack: () => context.pop(),
|
||||
final networks = List<NetworkMileage>.from(parsed.networkMileage)
|
||||
..sort((a, b) => b.miles.compareTo(a.miles));
|
||||
final countries = List<CountryMileage>.from(parsed.countryMileage)
|
||||
..sort((a, b) => b.miles.compareTo(a.miles));
|
||||
|
||||
return Scaffold(
|
||||
endDrawer: _NetworksDrawer(
|
||||
networks: networks,
|
||||
countries: countries,
|
||||
),
|
||||
body: Builder(
|
||||
builder: (scaffoldContext) => Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: RouteDetailsView(
|
||||
route: parsed.calculatedRoute,
|
||||
costs: parsed.costs,
|
||||
routingPoints: parsed.inputRoute.toSet(),
|
||||
onBack: () => context.pop(),
|
||||
onNetworksPressed: () =>
|
||||
Scaffold.of(scaffoldContext).openEndDrawer(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _NetworksDrawer extends StatelessWidget {
|
||||
const _NetworksDrawer({
|
||||
required this.networks,
|
||||
required this.countries,
|
||||
});
|
||||
|
||||
final List<NetworkMileage> networks;
|
||||
final List<CountryMileage> countries;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final distanceUnits = context.watch<DistanceUnitService>();
|
||||
return Drawer(
|
||||
child: SafeArea(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text(
|
||||
'Networks',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (networks.isEmpty)
|
||||
const Text('No network mileage data.')
|
||||
else
|
||||
...networks.map(
|
||||
(entry) => ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(entry.network),
|
||||
trailing:
|
||||
Text(distanceUnits.format(entry.miles, decimals: 2)),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Countries',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (countries.isEmpty)
|
||||
const Text('No country mileage data.')
|
||||
else
|
||||
...countries.map(
|
||||
(entry) => ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(entry.country),
|
||||
trailing:
|
||||
Text(distanceUnits.format(entry.miles, decimals: 2)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user