initial codex commit
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:mileograph_flutter/components/pages/calculator.dart';
|
||||
import 'package:mileograph_flutter/components/pages/newEntry.dart';
|
||||
import 'package:mileograph_flutter/components/pages/new_entry.dart';
|
||||
import 'package:mileograph_flutter/components/pages/traction.dart';
|
||||
import 'package:mileograph_flutter/components/pages/trips.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -13,7 +13,6 @@ import 'package:mileograph_flutter/services/dataService.dart';
|
||||
|
||||
import 'components/login/login.dart';
|
||||
import 'components/pages/dashboard.dart';
|
||||
import 'components/dashboard/topTractionPanel.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
@@ -188,18 +187,28 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
if (!_fetched) {
|
||||
_fetched = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final data = context.read<DataService>();
|
||||
final auth = context.read<AuthService>();
|
||||
api.setTokenProvider(() => auth.token);
|
||||
if (data.homepageStats == null) {
|
||||
data.fetchHomepageStats();
|
||||
}
|
||||
if (data.legs.isEmpty) {
|
||||
data.fetchLegs();
|
||||
}
|
||||
if (data.traction.isEmpty) {
|
||||
data.fetchHadTraction();
|
||||
}
|
||||
Future(() async {
|
||||
final data = context.read<DataService>();
|
||||
final auth = context.read<AuthService>();
|
||||
api.setTokenProvider(() => auth.token);
|
||||
await auth.tryRestoreSession();
|
||||
if (!auth.isLoggedIn) return;
|
||||
if (data.homepageStats == null) {
|
||||
data.fetchHomepageStats();
|
||||
}
|
||||
if (data.legs.isEmpty) {
|
||||
data.fetchLegs();
|
||||
}
|
||||
if (data.traction.isEmpty) {
|
||||
data.fetchHadTraction();
|
||||
}
|
||||
if (data.onThisDay.isEmpty) {
|
||||
data.fetchOnThisDay();
|
||||
}
|
||||
if (data.tripDetails.isEmpty) {
|
||||
data.fetchTripDetails();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -212,7 +221,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
final data = context.watch<DataService>();
|
||||
final auth = context.read<AuthService>();
|
||||
|
||||
if (data.homepageStats != null) {
|
||||
if (data.homepageStats != null || !data.isHomepageLoading) {
|
||||
currentPage = widget.child;
|
||||
} else {
|
||||
currentPage = Center(child: CircularProgressIndicator());
|
||||
|
||||
Reference in New Issue
Block a user