Merge pull request #690 from imshahab/m3-dynamic-theme

Implement Material 3 dynamic theming
This commit is contained in:
Hiddify
2024-03-19 12:04:53 +01:00
committed by GitHub
9 changed files with 68 additions and 161 deletions

View File

@@ -1,4 +1,5 @@
import 'package:accessibility_tools/accessibility_tools.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@@ -38,33 +39,36 @@ class App extends HookConsumerWidget with PresLogger {
return WindowWrapper(
TrayWrapper(
ShortcutWrapper(
ConnectionWrapper(
MaterialApp.router(
routerConfig: router,
locale: locale.flutterLocale,
supportedLocales: AppLocaleUtils.supportedLocales,
localizationsDelegates: GlobalMaterialLocalizations.delegates,
debugShowCheckedModeBanner: false,
themeMode: themeMode.flutterThemeMode,
theme: theme.light(),
darkTheme: theme.dark(),
title: Constants.appName,
builder: (context, child) {
child = UpgradeAlert(
upgrader: upgrader,
navigatorKey: router.routerDelegate.navigatorKey,
child: child ?? const SizedBox(),
);
if (kDebugMode && _debugAccessibility) {
return AccessibilityTools(
checkFontOverflows: true,
child: child,
ConnectionWrapper(DynamicColorBuilder(
builder:
(ColorScheme? lightColorScheme, ColorScheme? darkColorScheme) {
return MaterialApp.router(
routerConfig: router,
locale: locale.flutterLocale,
supportedLocales: AppLocaleUtils.supportedLocales,
localizationsDelegates: GlobalMaterialLocalizations.delegates,
debugShowCheckedModeBanner: false,
themeMode: themeMode.flutterThemeMode,
theme: theme.lightTheme(lightColorScheme),
darkTheme: theme.darkTheme(darkColorScheme),
title: Constants.appName,
builder: (context, child) {
child = UpgradeAlert(
upgrader: upgrader,
navigatorKey: router.routerDelegate.navigatorKey,
child: child ?? const SizedBox(),
);
}
return child;
},
),
),
if (kDebugMode && _debugAccessibility) {
return AccessibilityTools(
checkFontOverflows: true,
child: child,
);
}
return child;
},
);
},
)),
),
),
);