major refactor
All checks were successful
All checks were successful
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user