major refactor
All checks were successful
Release / meta (push) Successful in 7s
Release / linux-build (push) Successful in 6m36s
Release / android-build (push) Successful in 15m50s
Release / release-master (push) Successful in 23s
Release / release-dev (push) Successful in 25s

This commit is contained in:
2025-12-16 16:49:39 +00:00
parent 4a6aee8a15
commit 80be797322
23 changed files with 1517 additions and 1414 deletions

View File

@@ -9,9 +9,9 @@ import 'package:mileograph_flutter/components/pages/trips.dart';
import 'package:provider/provider.dart';
import 'package:mileograph_flutter/components/pages/legs.dart';
import 'package:mileograph_flutter/services/apiService.dart';
import 'package:mileograph_flutter/services/api_service.dart';
import 'package:mileograph_flutter/services/authservice.dart';
import 'package:mileograph_flutter/services/dataService.dart';
import 'package:mileograph_flutter/services/data_service.dart';
import 'package:mileograph_flutter/services/navigation_guard.dart';
import 'components/login/login.dart';
@@ -38,7 +38,7 @@ void main() {
},
),
ProxyProvider<AuthService, void>(
update: (_, auth, __) {
update: (_, auth, previous) {
api.setTokenProvider(() => auth.token);
api.setUnauthorizedHandler(() => auth.handleTokenExpired());
},
@@ -88,14 +88,17 @@ class MyApp extends StatelessWidget {
return MyHomePage(child: child);
},
routes: [
GoRoute(path: '/', builder: (_, __) => const Dashboard()),
GoRoute(path: '/calculator', builder: (_, __) => CalculatorPage()),
GoRoute(path: '/', builder: (context, state) => const Dashboard()),
GoRoute(
path: '/calculator',
builder: (context, state) => CalculatorPage(),
),
GoRoute(
path: '/calculator/details',
builder: (_, __) => CalculatorPage(),
builder: (context, state) => CalculatorPage(),
),
GoRoute(path: '/legs', builder: (_, __) => LegsPage()),
GoRoute(path: '/traction', builder: (_, __) => TractionPage()),
GoRoute(path: '/legs', builder: (context, state) => LegsPage()),
GoRoute(path: '/traction', builder: (context, state) => TractionPage()),
GoRoute(
path: '/traction/:id/timeline',
builder: (_, state) {
@@ -119,10 +122,10 @@ class MyApp extends StatelessWidget {
),
GoRoute(
path: '/traction/new',
builder: (_, __) => const NewTractionPage(),
builder: (context, state) => const NewTractionPage(),
),
GoRoute(path: '/trips', builder: (_, __) => TripsPage()),
GoRoute(path: '/add', builder: (_, __) => NewEntryPage()),
GoRoute(path: '/trips', builder: (context, state) => TripsPage()),
GoRoute(path: '/add', builder: (context, state) => NewEntryPage()),
GoRoute(
path: '/legs/edit/:id',
builder: (_, state) {
@@ -133,7 +136,7 @@ class MyApp extends StatelessWidget {
),
],
),
GoRoute(path: '/login', builder: (_, __) => const LoginScreen()),
GoRoute(path: '/login', builder: (context, state) => const LoginScreen()),
],
);
@@ -232,6 +235,7 @@ class _MyHomePageState extends State<MyHomePage> {
_fetched = true;
WidgetsBinding.instance.addPostFrameCallback((_) {
Future(() async {
if (!mounted) return;
final data = context.read<DataService>();
final auth = context.read<AuthService>();
api.setTokenProvider(() => auth.token);