Compare commits
1 Commits
0.7.8-dev.
...
0.8.0-dev.
| Author | SHA1 | Date | |
|---|---|---|---|
| 45bd872b23 |
@@ -40,6 +40,7 @@ class RouteDetailsView extends StatelessWidget {
|
|||||||
final List<double> costs;
|
final List<double> costs;
|
||||||
final VoidCallback onBack;
|
final VoidCallback onBack;
|
||||||
final Set<String> routingPoints;
|
final Set<String> routingPoints;
|
||||||
|
final VoidCallback? onNetworksPressed;
|
||||||
|
|
||||||
const RouteDetailsView({
|
const RouteDetailsView({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -47,6 +48,7 @@ class RouteDetailsView extends StatelessWidget {
|
|||||||
required this.costs,
|
required this.costs,
|
||||||
required this.onBack,
|
required this.onBack,
|
||||||
this.routingPoints = const {},
|
this.routingPoints = const {},
|
||||||
|
this.onNetworksPressed,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -56,13 +58,21 @@ class RouteDetailsView extends StatelessWidget {
|
|||||||
final mutedColor = Theme.of(context).colorScheme.outlineVariant;
|
final mutedColor = Theme.of(context).colorScheme.outlineVariant;
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Align(
|
Row(
|
||||||
alignment: Alignment.centerLeft,
|
children: [
|
||||||
child: TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: onBack,
|
onPressed: onBack,
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
label: const Text('Back'),
|
label: const Text('Back'),
|
||||||
),
|
),
|
||||||
|
const Spacer(),
|
||||||
|
if (onNetworksPressed != null)
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: onNetworksPressed,
|
||||||
|
icon: const Icon(Icons.account_tree),
|
||||||
|
label: const Text('Networks'),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ class _LegCardState extends State<LegCard> {
|
|||||||
final sharedTo = leg.sharedTo;
|
final sharedTo = leg.sharedTo;
|
||||||
final distanceUnits = context.watch<DistanceUnitService>();
|
final distanceUnits = context.watch<DistanceUnitService>();
|
||||||
final routeSegments = _parseRouteSegments(leg.route);
|
final routeSegments = _parseRouteSegments(leg.route);
|
||||||
|
final networkMileage = _sortedNetworkMileage(leg);
|
||||||
|
final countryMileage = _sortedCountryMileage(leg);
|
||||||
final textTheme = Theme.of(context).textTheme;
|
final textTheme = Theme.of(context).textTheme;
|
||||||
return Card(
|
return Card(
|
||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
@@ -160,10 +162,11 @@ class _LegCardState extends State<LegCard> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (leg.network.isNotEmpty) {
|
final networkSummary = _networkSummary(leg);
|
||||||
|
if (networkSummary != null) {
|
||||||
children.add(
|
children.add(
|
||||||
Text(
|
Text(
|
||||||
leg.network,
|
networkSummary,
|
||||||
style: textTheme.labelSmall,
|
style: textTheme.labelSmall,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -285,6 +288,28 @@ class _LegCardState extends State<LegCard> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
],
|
],
|
||||||
|
if (networkMileage.isNotEmpty || countryMileage.isNotEmpty) ...[
|
||||||
|
Text('Network mileage', style: textTheme.titleSmall),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
...networkMileage.map(
|
||||||
|
(entry) => Text(
|
||||||
|
'${entry.network}: ${distanceUnits.format(entry.miles, decimals: 1)}',
|
||||||
|
style: textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (countryMileage.isNotEmpty) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text('Country mileage', style: textTheme.titleSmall),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
...countryMileage.map(
|
||||||
|
(entry) => Text(
|
||||||
|
'${entry.country}: ${distanceUnits.format(entry.miles, decimals: 1)}',
|
||||||
|
style: textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
],
|
||||||
if (routeSegments.isNotEmpty) ...[
|
if (routeSegments.isNotEmpty) ...[
|
||||||
Text('Route', style: textTheme.titleSmall),
|
Text('Route', style: textTheme.titleSmall),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
@@ -483,6 +508,33 @@ class _LegCardState extends State<LegCard> {
|
|||||||
List<String> _parseRouteSegments(List<String> route) {
|
List<String> _parseRouteSegments(List<String> route) {
|
||||||
return route.map((e) => e.toString()).where((e) => e.trim().isNotEmpty).toList();
|
return route.map((e) => e.toString()).where((e) => e.trim().isNotEmpty).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<NetworkMileage> _sortedNetworkMileage(Leg leg) {
|
||||||
|
final items = leg.networkMileage
|
||||||
|
.where((entry) => entry.network.trim().isNotEmpty)
|
||||||
|
.toList();
|
||||||
|
items.sort((a, b) => b.miles.compareTo(a.miles));
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CountryMileage> _sortedCountryMileage(Leg leg) {
|
||||||
|
final items = leg.countryMileage
|
||||||
|
.where((entry) => entry.country.trim().isNotEmpty)
|
||||||
|
.toList();
|
||||||
|
items.sort((a, b) => b.miles.compareTo(a.miles));
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _networkSummary(Leg leg) {
|
||||||
|
final networks = _sortedNetworkMileage(leg);
|
||||||
|
if (networks.isNotEmpty) {
|
||||||
|
return networks.map((entry) => entry.network).join(', ');
|
||||||
|
}
|
||||||
|
if (leg.network.trim().isNotEmpty) {
|
||||||
|
return leg.network;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SharedIcons extends StatelessWidget {
|
class _SharedIcons extends StatelessWidget {
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class _LoginLogoState extends State<_LoginLogo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _colorToHex(Color color) {
|
String _colorToHex(Color color) {
|
||||||
final hex = color.value.toRadixString(16).padLeft(8, '0');
|
final hex = color.toARGB32().toRadixString(16).padLeft(8, '0');
|
||||||
return '#${hex.substring(2)}';
|
return '#${hex.substring(2)}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mileograph_flutter/components/calculator/route_summary_widget.dart';
|
import 'package:mileograph_flutter/components/calculator/route_summary_widget.dart';
|
||||||
import 'package:mileograph_flutter/objects/objects.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 {
|
class CalculatorDetailsPage extends StatelessWidget {
|
||||||
const CalculatorDetailsPage({
|
const CalculatorDetailsPage({
|
||||||
@@ -34,13 +36,85 @@ class CalculatorDetailsPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
final networks = List<NetworkMileage>.from(parsed.networkMileage)
|
||||||
padding: const EdgeInsets.all(16.0),
|
..sort((a, b) => b.miles.compareTo(a.miles));
|
||||||
child: RouteDetailsView(
|
final countries = List<CountryMileage>.from(parsed.countryMileage)
|
||||||
route: parsed.calculatedRoute,
|
..sort((a, b) => b.miles.compareTo(a.miles));
|
||||||
costs: parsed.costs,
|
|
||||||
routingPoints: parsed.inputRoute.toSet(),
|
return Scaffold(
|
||||||
onBack: () => context.pop(),
|
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)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -813,17 +813,17 @@ List<DateTime> _buildBoundaries(
|
|||||||
for (final seg in segments) {
|
for (final seg in segments) {
|
||||||
boundaryDates.add(seg.start);
|
boundaryDates.add(seg.start);
|
||||||
boundaryDates.add(seg.end);
|
boundaryDates.add(seg.end);
|
||||||
minStart = minStart == null || seg.start.isBefore(minStart!)
|
minStart = minStart == null || seg.start.isBefore(minStart)
|
||||||
? seg.start
|
? seg.start
|
||||||
: minStart;
|
: minStart;
|
||||||
maxEnd = maxEnd == null || seg.end.isAfter(maxEnd!) ? seg.end : maxEnd;
|
maxEnd = maxEnd == null || seg.end.isAfter(maxEnd) ? seg.end : maxEnd;
|
||||||
}
|
}
|
||||||
minStart ??= now.subtract(const Duration(days: 1));
|
final effectiveMinStart = minStart ?? now.subtract(const Duration(days: 1));
|
||||||
final effectiveMaxEnd = maxEnd ?? now;
|
final effectiveMaxEnd = maxEnd ?? now;
|
||||||
boundaryDates.add(effectiveMaxEnd);
|
boundaryDates.add(effectiveMaxEnd);
|
||||||
var boundaries = boundaryDates.toList()..sort();
|
var boundaries = boundaryDates.toList()..sort();
|
||||||
if (boundaries.length < 2) {
|
if (boundaries.length < 2) {
|
||||||
boundaries = [minStart!, effectiveMaxEnd];
|
boundaries = [effectiveMinStart, effectiveMaxEnd];
|
||||||
}
|
}
|
||||||
return boundaries;
|
return boundaries;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1399,16 +1399,18 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
|||||||
singleColumn: true,
|
singleColumn: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(height: 24),
|
if (_useManualMileage) ...[
|
||||||
TextFormField(
|
const Divider(height: 24),
|
||||||
controller: _networkController,
|
TextFormField(
|
||||||
textCapitalization: TextCapitalization.characters,
|
controller: _networkController,
|
||||||
inputFormatters: const [_UpperCaseTextFormatter()],
|
textCapitalization: TextCapitalization.characters,
|
||||||
decoration: const InputDecoration(
|
inputFormatters: const [_UpperCaseTextFormatter()],
|
||||||
labelText: 'Network',
|
decoration: const InputDecoration(
|
||||||
border: OutlineInputBorder(),
|
labelText: 'Network',
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
TextFormField(
|
TextFormField(
|
||||||
controller: _notesController,
|
controller: _notesController,
|
||||||
maxLines: 3,
|
maxLines: 3,
|
||||||
@@ -1520,6 +1522,9 @@ class _NewEntryPageState extends State<NewEntryPage> {
|
|||||||
onSelected: (val) {
|
onSelected: (val) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_useManualMileage = val;
|
_useManualMileage = val;
|
||||||
|
if (!val) {
|
||||||
|
_networkController.clear();
|
||||||
|
}
|
||||||
if (val && _routeResult != null) {
|
if (val && _routeResult != null) {
|
||||||
_mileageController.text = _formatDistance(
|
_mileageController.text = _formatDistance(
|
||||||
distanceUnitService,
|
distanceUnitService,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ extension _NewEntrySubmitLogic on _NewEntryPageState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_networkController.text.trim().isEmpty) {
|
if (_useManualMileage && _networkController.text.trim().isEmpty) {
|
||||||
missing.add('Network');
|
missing.add('Network');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ extension _NewEntrySubmitLogic on _NewEntryPageState {
|
|||||||
final isEditingExisting = _isEditing && widget.editLegId != null;
|
final isEditingExisting = _isEditing && widget.editLegId != null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final commonPayload = {
|
final commonPayload = {
|
||||||
if (isEditingExisting) "leg_id": widget.editLegId,
|
if (isEditingExisting) "leg_id": widget.editLegId,
|
||||||
"leg_trip": _selectedTripId,
|
"leg_trip": _selectedTripId,
|
||||||
"leg_begin_time": _legDateTime.toIso8601String(),
|
"leg_begin_time": _legDateTime.toIso8601String(),
|
||||||
@@ -104,7 +104,8 @@ extension _NewEntrySubmitLogic on _NewEntryPageState {
|
|||||||
"leg_destination_time": destinationTime.toIso8601String(),
|
"leg_destination_time": destinationTime.toIso8601String(),
|
||||||
"leg_notes": _notesController.text.trim(),
|
"leg_notes": _notesController.text.trim(),
|
||||||
"leg_headcode": _headcodeController.text.trim(),
|
"leg_headcode": _headcodeController.text.trim(),
|
||||||
"leg_network": _networkController.text.trim(),
|
if (_useManualMileage)
|
||||||
|
"leg_network": _networkController.text.trim(),
|
||||||
"leg_origin": _originController.text.trim(),
|
"leg_origin": _originController.text.trim(),
|
||||||
"leg_destination": _destinationController.text.trim(),
|
"leg_destination": _destinationController.text.trim(),
|
||||||
"leg_begin_delay": beginDelay,
|
"leg_begin_delay": beginDelay,
|
||||||
|
|||||||
@@ -170,6 +170,21 @@ class _StatsPageState extends State<StatsPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (year.topCountries.isNotEmpty)
|
||||||
|
_buildSection<StatsCountryMileage>(
|
||||||
|
context,
|
||||||
|
title: 'Top countries',
|
||||||
|
items: year.topCountries,
|
||||||
|
emptyLabel: 'No country data',
|
||||||
|
itemBuilder: (item, index) => ListTile(
|
||||||
|
dense: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
title: Text(item.country),
|
||||||
|
trailing: Text(
|
||||||
|
distanceUnits.format(item.mileage, decimals: 1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
_buildSection<StatsStationVisits>(
|
_buildSection<StatsStationVisits>(
|
||||||
context,
|
context,
|
||||||
title: 'Top stations',
|
title: 'Top stations',
|
||||||
|
|||||||
@@ -699,11 +699,8 @@ class _TractionPageState extends State<TractionPage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final hasAdminActions = isElevated;
|
final hasAdminActions = isElevated;
|
||||||
final hasMoreMenu = true;
|
|
||||||
|
|
||||||
final moreButton = !hasMoreMenu
|
final moreButton = PopupMenuButton<_TractionMoreAction>(
|
||||||
? null
|
|
||||||
: PopupMenuButton<_TractionMoreAction>(
|
|
||||||
tooltip: 'More options',
|
tooltip: 'More options',
|
||||||
onSelected: (action) async {
|
onSelected: (action) async {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
@@ -859,11 +856,11 @@ class _TractionPageState extends State<TractionPage> {
|
|||||||
final desktopActions = [
|
final desktopActions = [
|
||||||
refreshButton,
|
refreshButton,
|
||||||
newTractionButton,
|
newTractionButton,
|
||||||
if (moreButton != null) moreButton,
|
moreButton,
|
||||||
];
|
];
|
||||||
|
|
||||||
final mobileActions = [
|
final mobileActions = [
|
||||||
if (moreButton != null) moreButton,
|
moreButton,
|
||||||
newTractionButton,
|
newTractionButton,
|
||||||
refreshButton,
|
refreshButton,
|
||||||
];
|
];
|
||||||
@@ -1041,8 +1038,9 @@ class _TractionPageState extends State<TractionPage> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
errorMessage = e.toString();
|
errorMessage = e.toString();
|
||||||
} finally {
|
} finally {
|
||||||
if (!mounted) return;
|
if (mounted) {
|
||||||
setModalState(() => uploading = false);
|
setModalState(() => uploading = false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -517,6 +517,7 @@ class StatsAbout {
|
|||||||
final mileageByYear = <int, double>{};
|
final mileageByYear = <int, double>{};
|
||||||
final classByYear = <int, List<StatsClassMileage>>{};
|
final classByYear = <int, List<StatsClassMileage>>{};
|
||||||
final networkByYear = <int, List<StatsNetworkMileage>>{};
|
final networkByYear = <int, List<StatsNetworkMileage>>{};
|
||||||
|
final countryByYear = <int, List<StatsCountryMileage>>{};
|
||||||
final stationByYear = <int, List<StatsStationVisits>>{};
|
final stationByYear = <int, List<StatsStationVisits>>{};
|
||||||
final winnersByYear = <int, int>{};
|
final winnersByYear = <int, int>{};
|
||||||
final winnerTypeCountsByYear = <int, Map<String, int>>{};
|
final winnerTypeCountsByYear = <int, Map<String, int>>{};
|
||||||
@@ -577,6 +578,17 @@ class StatsAbout {
|
|||||||
return const [];
|
return const [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<StatsCountryMileage> parseCountryList(dynamic value) {
|
||||||
|
if (value is List) {
|
||||||
|
return value
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => StatsCountryMileage.fromJson(
|
||||||
|
e.map((key, value) => MapEntry(key.toString(), value))))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
return const [];
|
||||||
|
}
|
||||||
|
|
||||||
void parseYearMap<T>(
|
void parseYearMap<T>(
|
||||||
dynamic source,
|
dynamic source,
|
||||||
Map<int, T> target,
|
Map<int, T> target,
|
||||||
@@ -611,6 +623,11 @@ class StatsAbout {
|
|||||||
networkByYear,
|
networkByYear,
|
||||||
parseNetworkList,
|
parseNetworkList,
|
||||||
);
|
);
|
||||||
|
parseYearMap<List<StatsCountryMileage>>(
|
||||||
|
json['top_countries'],
|
||||||
|
countryByYear,
|
||||||
|
parseCountryList,
|
||||||
|
);
|
||||||
parseYearMap<List<StatsStationVisits>>(
|
parseYearMap<List<StatsStationVisits>>(
|
||||||
json['top_stations'],
|
json['top_stations'],
|
||||||
stationByYear,
|
stationByYear,
|
||||||
@@ -643,6 +660,7 @@ class StatsAbout {
|
|||||||
...mileageByYear.keys,
|
...mileageByYear.keys,
|
||||||
...classByYear.keys,
|
...classByYear.keys,
|
||||||
...networkByYear.keys,
|
...networkByYear.keys,
|
||||||
|
...countryByYear.keys,
|
||||||
...stationByYear.keys,
|
...stationByYear.keys,
|
||||||
...winnersByYear.keys,
|
...winnersByYear.keys,
|
||||||
...winnerTypeCountsByYear.keys,
|
...winnerTypeCountsByYear.keys,
|
||||||
@@ -656,6 +674,7 @@ class StatsAbout {
|
|||||||
mileage: mileageByYear[year] ?? 0,
|
mileage: mileageByYear[year] ?? 0,
|
||||||
topClasses: classByYear[year] ?? const [],
|
topClasses: classByYear[year] ?? const [],
|
||||||
topNetworks: networkByYear[year] ?? const [],
|
topNetworks: networkByYear[year] ?? const [],
|
||||||
|
topCountries: countryByYear[year] ?? const [],
|
||||||
topStations: stationByYear[year] ?? const [],
|
topStations: stationByYear[year] ?? const [],
|
||||||
winnerCount: winnersByYear[year] ?? 0,
|
winnerCount: winnersByYear[year] ?? 0,
|
||||||
winnerTypeCounts: winnerTypeCountsByYear[year] ?? const {},
|
winnerTypeCounts: winnerTypeCountsByYear[year] ?? const {},
|
||||||
@@ -678,6 +697,7 @@ class StatsYear {
|
|||||||
final double mileage;
|
final double mileage;
|
||||||
final List<StatsClassMileage> topClasses;
|
final List<StatsClassMileage> topClasses;
|
||||||
final List<StatsNetworkMileage> topNetworks;
|
final List<StatsNetworkMileage> topNetworks;
|
||||||
|
final List<StatsCountryMileage> topCountries;
|
||||||
final List<StatsStationVisits> topStations;
|
final List<StatsStationVisits> topStations;
|
||||||
final int winnerCount;
|
final int winnerCount;
|
||||||
final Map<String, int> winnerTypeCounts;
|
final Map<String, int> winnerTypeCounts;
|
||||||
@@ -688,6 +708,7 @@ class StatsYear {
|
|||||||
required this.mileage,
|
required this.mileage,
|
||||||
required this.topClasses,
|
required this.topClasses,
|
||||||
required this.topNetworks,
|
required this.topNetworks,
|
||||||
|
required this.topCountries,
|
||||||
required this.topStations,
|
required this.topStations,
|
||||||
required this.winnerCount,
|
required this.winnerCount,
|
||||||
required this.winnerTypeCounts,
|
required this.winnerTypeCounts,
|
||||||
@@ -727,6 +748,22 @@ class StatsNetworkMileage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class StatsCountryMileage {
|
||||||
|
final String country;
|
||||||
|
final double mileage;
|
||||||
|
|
||||||
|
StatsCountryMileage({
|
||||||
|
required this.country,
|
||||||
|
required this.mileage,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory StatsCountryMileage.fromJson(Map<String, dynamic> json) =>
|
||||||
|
StatsCountryMileage(
|
||||||
|
country: _asString(json['country'], 'Unknown'),
|
||||||
|
mileage: _asDouble(json['mileage']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class StatsStationVisits {
|
class StatsStationVisits {
|
||||||
final String station;
|
final String station;
|
||||||
final int visits;
|
final int visits;
|
||||||
@@ -1205,6 +1242,8 @@ class Leg {
|
|||||||
final String start, end, network, notes, headcode, user;
|
final String start, end, network, notes, headcode, user;
|
||||||
final String origin, destination;
|
final String origin, destination;
|
||||||
final List<String> route;
|
final List<String> route;
|
||||||
|
final List<NetworkMileage> networkMileage;
|
||||||
|
final List<CountryMileage> countryMileage;
|
||||||
final String? legShareId;
|
final String? legShareId;
|
||||||
final LegShareMeta? sharedFrom;
|
final LegShareMeta? sharedFrom;
|
||||||
final List<LegShareMeta> sharedTo;
|
final List<LegShareMeta> sharedTo;
|
||||||
@@ -1231,6 +1270,8 @@ class Leg {
|
|||||||
required this.driving,
|
required this.driving,
|
||||||
required this.user,
|
required this.user,
|
||||||
required this.locos,
|
required this.locos,
|
||||||
|
this.networkMileage = const [],
|
||||||
|
this.countryMileage = const [],
|
||||||
this.endTime,
|
this.endTime,
|
||||||
this.originTime,
|
this.originTime,
|
||||||
this.destinationTime,
|
this.destinationTime,
|
||||||
@@ -1300,6 +1341,14 @@ class Leg {
|
|||||||
: _asInt(json['leg_end_delay']),
|
: _asInt(json['leg_end_delay']),
|
||||||
origin: _asString(json['leg_origin']),
|
origin: _asString(json['leg_origin']),
|
||||||
destination: _asString(json['leg_destination']),
|
destination: _asString(json['leg_destination']),
|
||||||
|
networkMileage: (json['network_mileage'] as List? ?? const [])
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => NetworkMileage.fromJson(Map<String, dynamic>.from(e)))
|
||||||
|
.toList(),
|
||||||
|
countryMileage: (json['country_mileage'] as List? ?? const [])
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => CountryMileage.fromJson(Map<String, dynamic>.from(e)))
|
||||||
|
.toList(),
|
||||||
legShareId: _asString(json['leg_share_id']),
|
legShareId: _asString(json['leg_share_id']),
|
||||||
sharedFrom: sharedFrom,
|
sharedFrom: sharedFrom,
|
||||||
sharedTo: sharedTo,
|
sharedTo: sharedTo,
|
||||||
@@ -1470,12 +1519,16 @@ class RouteResult {
|
|||||||
final List<String> calculatedRoute;
|
final List<String> calculatedRoute;
|
||||||
final List<double> costs;
|
final List<double> costs;
|
||||||
final double distance;
|
final double distance;
|
||||||
|
final List<NetworkMileage> networkMileage;
|
||||||
|
final List<CountryMileage> countryMileage;
|
||||||
|
|
||||||
RouteResult({
|
RouteResult({
|
||||||
required this.inputRoute,
|
required this.inputRoute,
|
||||||
required this.calculatedRoute,
|
required this.calculatedRoute,
|
||||||
required this.costs,
|
required this.costs,
|
||||||
required this.distance,
|
required this.distance,
|
||||||
|
this.networkMileage = const [],
|
||||||
|
this.countryMileage = const [],
|
||||||
});
|
});
|
||||||
|
|
||||||
factory RouteResult.fromJson(Map<String, dynamic> json) {
|
factory RouteResult.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -1484,10 +1537,50 @@ class RouteResult {
|
|||||||
calculatedRoute: List<String>.from(json['calculated_route']),
|
calculatedRoute: List<String>.from(json['calculated_route']),
|
||||||
costs: (json['costs'] as List).map((e) => (e as num).toDouble()).toList(),
|
costs: (json['costs'] as List).map((e) => (e as num).toDouble()).toList(),
|
||||||
distance: (json['distance'] as num).toDouble(),
|
distance: (json['distance'] as num).toDouble(),
|
||||||
|
networkMileage: (json['network_mileage'] as List? ?? const [])
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => NetworkMileage.fromJson(Map<String, dynamic>.from(e)))
|
||||||
|
.toList(),
|
||||||
|
countryMileage: (json['country_mileage'] as List? ?? const [])
|
||||||
|
.whereType<Map>()
|
||||||
|
.map((e) => CountryMileage.fromJson(Map<String, dynamic>.from(e)))
|
||||||
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NetworkMileage {
|
||||||
|
final String network;
|
||||||
|
final double miles;
|
||||||
|
|
||||||
|
NetworkMileage({
|
||||||
|
required this.network,
|
||||||
|
required this.miles,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory NetworkMileage.fromJson(Map<String, dynamic> json) =>
|
||||||
|
NetworkMileage(
|
||||||
|
network: _asString(json['network']),
|
||||||
|
miles: _asDouble(json['miles']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class CountryMileage {
|
||||||
|
final String country;
|
||||||
|
final double miles;
|
||||||
|
|
||||||
|
CountryMileage({
|
||||||
|
required this.country,
|
||||||
|
required this.miles,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CountryMileage.fromJson(Map<String, dynamic> json) =>
|
||||||
|
CountryMileage(
|
||||||
|
country: _asString(json['country']),
|
||||||
|
miles: _asDouble(json['miles']),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class Station {
|
class Station {
|
||||||
final int id;
|
final int id;
|
||||||
final String name;
|
final String name;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.7.8+16
|
version: 0.8.0+17
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:mileograph_flutter/objects/objects.dart';
|
import 'package:mileograph_flutter/objects/objects.dart';
|
||||||
import 'package:mileograph_flutter/services/api_service.dart';
|
import 'package:mileograph_flutter/services/api_service.dart';
|
||||||
import 'package:mileograph_flutter/services/authservice.dart';
|
import 'package:mileograph_flutter/services/authservice.dart';
|
||||||
@@ -8,14 +7,18 @@ import 'package:mileograph_flutter/services/distance_unit_service.dart';
|
|||||||
import 'test_data.dart';
|
import 'test_data.dart';
|
||||||
|
|
||||||
class FakeApiService extends ApiService {
|
class FakeApiService extends ApiService {
|
||||||
FakeApiService({String baseUrl = 'https://example.com'})
|
FakeApiService({super.baseUrl = 'https://example.com'});
|
||||||
: super(baseUrl: baseUrl);
|
|
||||||
|
|
||||||
final Map<String, dynamic> getResponses = {};
|
final Map<String, dynamic> getResponses = {};
|
||||||
final Map<String, dynamic> postResponses = {};
|
final Map<String, dynamic> postResponses = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<dynamic> get(String endpoint, {Map<String, String>? headers}) async {
|
Future<dynamic> get(
|
||||||
|
String endpoint, {
|
||||||
|
Map<String, String>? headers,
|
||||||
|
bool includeAuth = true,
|
||||||
|
bool allowRetry = true,
|
||||||
|
}) async {
|
||||||
return getResponses[endpoint];
|
return getResponses[endpoint];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +27,8 @@ class FakeApiService extends ApiService {
|
|||||||
String endpoint,
|
String endpoint,
|
||||||
dynamic data, {
|
dynamic data, {
|
||||||
Map<String, String>? headers,
|
Map<String, String>? headers,
|
||||||
|
bool includeAuth = true,
|
||||||
|
bool allowRetry = true,
|
||||||
}) async {
|
}) async {
|
||||||
return postResponses[endpoint] ?? {};
|
return postResponses[endpoint] ?? {};
|
||||||
}
|
}
|
||||||
@@ -170,20 +175,16 @@ class FakeDataService extends DataService {
|
|||||||
@override
|
@override
|
||||||
Future<void> fetchOnThisDay({DateTime? date}) async {}
|
Future<void> fetchOnThisDay({DateTime? date}) async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> fetchTripDetails() async {}
|
Future<void> fetchTripDetails() async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> fetchHadTraction({int offset = 0, int limit = 100}) async {}
|
Future<void> fetchHadTraction({int offset = 0, int limit = 100}) async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> fetchLatestLocoChanges({
|
Future<void> fetchLatestLocoChanges({
|
||||||
int limit = 100,
|
int limit = 100,
|
||||||
int offset = 0,
|
int offset = 0,
|
||||||
bool append = false,
|
bool append = false,
|
||||||
}) async {}
|
}) async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> fetchClassClearanceProgress({
|
Future<void> fetchClassClearanceProgress({
|
||||||
int offset = 0,
|
int offset = 0,
|
||||||
int limit = 20,
|
int limit = 20,
|
||||||
@@ -204,12 +205,10 @@ class FakeDataService extends DataService {
|
|||||||
List<String> networkFilter = const [],
|
List<String> networkFilter = const [],
|
||||||
}) async {}
|
}) async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<TripLocoStat>> fetchTripLocoStats(int tripId) async {
|
Future<List<TripLocoStat>> fetchTripLocoStats(int tripId) async {
|
||||||
return const [];
|
return const [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> fetchTraction({
|
Future<void> fetchTraction({
|
||||||
bool hadOnly = false,
|
bool hadOnly = false,
|
||||||
int offset = 0,
|
int offset = 0,
|
||||||
@@ -221,7 +220,6 @@ class FakeDataService extends DataService {
|
|||||||
Map<String, dynamic>? filters,
|
Map<String, dynamic>? filters,
|
||||||
}) async {}
|
}) async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<String>> fetchClassList({bool force = false}) async {
|
Future<List<String>> fetchClassList({bool force = false}) async {
|
||||||
return locoClassesValue;
|
return locoClassesValue;
|
||||||
}
|
}
|
||||||
@@ -235,12 +233,10 @@ class FakeDataService extends DataService {
|
|||||||
@override
|
@override
|
||||||
Future<void> fetchStationNetworks() async {}
|
Future<void> fetchStationNetworks() async {}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Map<String, dynamic>?> fetchClassStats(String locoClass) async {
|
Future<Map<String, dynamic>?> fetchClassStats(String locoClass) async {
|
||||||
return TestData.classStats;
|
return TestData.classStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<List<LeaderboardEntry>> fetchClassLeaderboard(
|
Future<List<LeaderboardEntry>> fetchClassLeaderboard(
|
||||||
String locoClass, {
|
String locoClass, {
|
||||||
bool friends = false,
|
bool friends = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user