diff --git a/lib/main.dart b/lib/main.dart index 42c9c82..b823639 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -132,6 +132,38 @@ class _MyAppState extends State with WidgetsBindingObserver { }; } + ThemeData getTheme( + Color primary, + Color? secondary, + Color? tertiary, + Brightness brightness, + ) { + String? font; + List? fallback; + if (App.isWindows) { + font = 'Segoe UI'; + fallback = [ + 'Segoe UI', + 'Microsoft YaHei', + 'PingFang SC', + 'Noto Sans CJK', + 'Arial', + 'sans-serif' + ]; + } + return ThemeData( + colorScheme: SeedColorScheme.fromSeeds( + primaryKey: primary, + secondaryKey: secondary, + tertiaryKey: tertiary, + brightness: brightness, + tones: FlexTones.vividBackground(brightness), + ), + fontFamily: font, + fontFamilyFallback: fallback, + ); + } + @override Widget build(BuildContext context) { Widget home; @@ -158,24 +190,9 @@ class _MyAppState extends State with WidgetsBindingObserver { return MaterialApp( home: home, debugShowCheckedModeBanner: false, - theme: ThemeData( - colorScheme: SeedColorScheme.fromSeeds( - primaryKey: primary, - secondaryKey: secondary, - tertiaryKey: tertiary, - tones: FlexTones.vividBackground(Brightness.light), - ), - ), + theme: getTheme(primary, secondary, tertiary, Brightness.light), navigatorKey: App.rootNavigatorKey, - darkTheme: ThemeData( - colorScheme: SeedColorScheme.fromSeeds( - primaryKey: primary, - secondaryKey: secondary, - tertiaryKey: tertiary, - brightness: Brightness.dark, - tones: FlexTones.vividBackground(Brightness.dark), - ), - ), + darkTheme: getTheme(primary, secondary, tertiary, Brightness.dark), themeMode: switch (appdata.settings['theme_mode']) { 'light' => ThemeMode.light, 'dark' => ThemeMode.dark,