feat(ui): add dynamic color Scheme (based on wallpaper) if supported

This commit is contained in:
fbachus
2026-08-09 15:05:09 +02:00
parent 317abbdc8e
commit 5b073b9e94
3 changed files with 32 additions and 17 deletions
+23 -17
View File
@@ -6,6 +6,7 @@ import 'dart:async';
import 'dart:io';
import 'package:sqflite_common_ffi/sqflite_ffi.dart'; //for testing on desktop
import 'utilities.dart';
import 'package:dynamic_color/dynamic_color.dart';
void main() async {
await dotenv.load();
@@ -18,29 +19,34 @@ void main() async {
runApp(const MyApp());
}
final _defaultLightScheme = ColorScheme.fromSeed(seedColor: Colors.yellow);
final _defaultDarkScheme = ColorScheme.fromSeed(
seedColor: Colors.yellow,
brightness: Brightness.dark,
);
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Oeffimaster',
theme: ThemeData(
brightness: Brightness.light,
colorSchemeSeed: Colors.yellow,
),
darkTheme: ThemeData(
brightness: Brightness.dark,
colorSchemeSeed: Colors.yellow,
),
themeMode: ThemeMode.system,
// home: const MyHomePage(title: 'Oeffimaster'), //this is what matters
home: const JourneyOverviewPage(),
// routes: {
// //'/': (context) => const MyHomePage(title: 'Oeffimaster'),
// '/stations': (context) => const ChooseStationPage(),
// },
return DynamicColorBuilder(
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
return MaterialApp(
theme: ThemeData(
useMaterial3: true,
colorScheme: lightDynamic ?? _defaultLightScheme,
),
darkTheme: ThemeData(
useMaterial3: true,
colorScheme: darkDynamic ?? _defaultDarkScheme,
),
themeMode: ThemeMode.system,
home: const JourneyOverviewPage(),
title: 'Oeffimaster',
);
},
);
}
}
+8
View File
@@ -65,6 +65,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.9"
dynamic_color:
dependency: "direct main"
description:
name: dynamic_color
sha256: "4aeb76de323e8eb660bab5557d826ad7ebbf1434a598f0c6aa8a11a9696a6757"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
fake_async:
dependency: transitive
description:
+1
View File
@@ -39,6 +39,7 @@ dependencies:
sqflite: ^2.4.2+1
sqlite3: ^3.3.0
sqflite_common_ffi: ^2.4.0+3
dynamic_color: ^1.9.0
dev_dependencies:
flutter_test:
sdk: flutter