Add display of legs and top traction, adjust colour based on device theme
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dynamic_color/dynamic_color.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/authservice.dart';
|
||||
import 'package:mileograph_flutter/services/dataService.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'components/login/login.dart';
|
||||
import 'components/pages/dashboard.dart';
|
||||
import 'components/dashboard/topTractionPanel.dart';
|
||||
|
||||
late ApiService api;
|
||||
|
||||
@@ -54,41 +58,47 @@ class AppRoot extends StatelessWidget {
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
MyApp({super.key});
|
||||
|
||||
final ColorScheme defaultLight = ColorScheme.fromSeed(seedColor: Colors.red);
|
||||
final ColorScheme defaultDark = ColorScheme.fromSeed(
|
||||
seedColor: Colors.red,
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
||||
// the application has a purple toolbar. Then, without quitting the app,
|
||||
// try changing the seedColor in the colorScheme below to Colors.green
|
||||
// and then invoke "hot reload" (save your changes or press the "hot
|
||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
||||
// the command line to start the app).
|
||||
//fullPage
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// state is not lost during the reload. To reset the state, use hot
|
||||
// restart instead.
|
||||
//
|
||||
// This works for code too, not just values: Most code changes can be
|
||||
// tested with just a hot reload.
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueGrey),
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.blueGrey,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
),
|
||||
themeMode: ThemeMode.system,
|
||||
home: AppRoot(),
|
||||
return DynamicColorBuilder(
|
||||
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
||||
// the application has a purple toolbar. Then, without quitting the app,
|
||||
// try changing the seedColor in the colorScheme below to Colors.green
|
||||
// and then invoke "hot reload" (save your changes or press the "hot
|
||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
||||
// the command line to start the app).
|
||||
//fullPage
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// state is not lost during the reload. To reset the state, use hot
|
||||
// restart instead.
|
||||
//
|
||||
// This works for code too, not just values: Most code changes can be
|
||||
// tested with just a hot reload.
|
||||
colorScheme: lightDynamic ?? defaultLight,
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: darkDynamic ?? defaultDark,
|
||||
),
|
||||
themeMode: ThemeMode.system,
|
||||
home: AppRoot(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +124,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
final List<Widget> contentPages = [
|
||||
Dashboard(),
|
||||
Center(child: Text("Calculator Page")),
|
||||
Center(child: Text("Entries Page")),
|
||||
LegsPage(),
|
||||
Center(child: Text("Traction Page")),
|
||||
Center(child: Text("Trips Page")),
|
||||
];
|
||||
@@ -135,6 +145,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
if (data.homepageStats == null) {
|
||||
data.fetchHomepageStats();
|
||||
}
|
||||
if (data.legs.isEmpty) {
|
||||
data.fetchLegs();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -152,7 +165,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
currentPage = Center(
|
||||
child: FilledButton(
|
||||
onPressed: data.fetchHomepageStats,
|
||||
child: Text("Fetch"),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user