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 'dart:io';
import 'package:sqflite_common_ffi/sqflite_ffi.dart'; //for testing on desktop import 'package:sqflite_common_ffi/sqflite_ffi.dart'; //for testing on desktop
import 'utilities.dart'; import 'utilities.dart';
import 'package:dynamic_color/dynamic_color.dart';
void main() async { void main() async {
await dotenv.load(); await dotenv.load();
@@ -18,29 +19,34 @@ void main() async {
runApp(const MyApp()); runApp(const MyApp());
} }
final _defaultLightScheme = ColorScheme.fromSeed(seedColor: Colors.yellow);
final _defaultDarkScheme = ColorScheme.fromSeed(
seedColor: Colors.yellow,
brightness: Brightness.dark,
);
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key}); const MyApp({super.key});
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return DynamicColorBuilder(
title: 'Oeffimaster', builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
theme: ThemeData( return MaterialApp(
brightness: Brightness.light, theme: ThemeData(
colorSchemeSeed: Colors.yellow, useMaterial3: true,
), colorScheme: lightDynamic ?? _defaultLightScheme,
darkTheme: ThemeData( ),
brightness: Brightness.dark, darkTheme: ThemeData(
colorSchemeSeed: Colors.yellow, useMaterial3: true,
), colorScheme: darkDynamic ?? _defaultDarkScheme,
themeMode: ThemeMode.system, ),
// home: const MyHomePage(title: 'Oeffimaster'), //this is what matters themeMode: ThemeMode.system,
home: const JourneyOverviewPage(), home: const JourneyOverviewPage(),
// routes: { title: 'Oeffimaster',
// //'/': (context) => const MyHomePage(title: 'Oeffimaster'), );
// '/stations': (context) => const ChooseStationPage(), },
// },
); );
} }
} }
+8
View File
@@ -65,6 +65,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.9" 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: fake_async:
dependency: transitive dependency: transitive
description: description:
+1
View File
@@ -39,6 +39,7 @@ dependencies:
sqflite: ^2.4.2+1 sqflite: ^2.4.2+1
sqlite3: ^3.3.0 sqlite3: ^3.3.0
sqflite_common_ffi: ^2.4.0+3 sqflite_common_ffi: ^2.4.0+3
dynamic_color: ^1.9.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter