mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: themedata
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
127
lib/main.dart
127
lib/main.dart
@@ -12,7 +12,6 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:PiliPalaX/common/widgets/custom_toast.dart';
|
import 'package:PiliPalaX/common/widgets/custom_toast.dart';
|
||||||
import 'package:PiliPalaX/http/init.dart';
|
import 'package:PiliPalaX/http/init.dart';
|
||||||
import 'package:PiliPalaX/models/common/color_type.dart';
|
import 'package:PiliPalaX/models/common/color_type.dart';
|
||||||
import 'package:PiliPalaX/models/common/theme_type.dart';
|
|
||||||
import 'package:PiliPalaX/pages/search/index.dart';
|
import 'package:PiliPalaX/pages/search/index.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||||
import 'package:PiliPalaX/router/app_pages.dart';
|
import 'package:PiliPalaX/router/app_pages.dart';
|
||||||
@@ -107,8 +106,8 @@ class MyApp extends StatelessWidget {
|
|||||||
['color'];
|
['color'];
|
||||||
Color brandColor = defaultColor;
|
Color brandColor = defaultColor;
|
||||||
// 主题模式
|
// 主题模式
|
||||||
ThemeType currentThemeValue = ThemeType.values[setting
|
// ThemeType currentThemeValue = ThemeType.values[setting
|
||||||
.get(SettingBoxKey.themeMode, defaultValue: ThemeType.system.code)];
|
// .get(SettingBoxKey.themeMode, defaultValue: ThemeType.system.code)];
|
||||||
// 是否动态取色
|
// 是否动态取色
|
||||||
bool isDynamicColor =
|
bool isDynamicColor =
|
||||||
setting.get(SettingBoxKey.dynamicColor, defaultValue: true);
|
setting.get(SettingBoxKey.dynamicColor, defaultValue: true);
|
||||||
@@ -145,10 +144,12 @@ class MyApp extends StatelessWidget {
|
|||||||
lightColorScheme = ColorScheme.fromSeed(
|
lightColorScheme = ColorScheme.fromSeed(
|
||||||
seedColor: brandColor,
|
seedColor: brandColor,
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
|
// dynamicSchemeVariant: DynamicSchemeVariant.neutral,
|
||||||
);
|
);
|
||||||
darkColorScheme = ColorScheme.fromSeed(
|
darkColorScheme = ColorScheme.fromSeed(
|
||||||
seedColor: brandColor,
|
seedColor: brandColor,
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
|
// dynamicSchemeVariant: DynamicSchemeVariant.neutral,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// 图片缓存
|
// 图片缓存
|
||||||
@@ -156,76 +157,13 @@ class MyApp extends StatelessWidget {
|
|||||||
return GetMaterialApp(
|
return GetMaterialApp(
|
||||||
// showSemanticsDebugger: true,
|
// showSemanticsDebugger: true,
|
||||||
title: 'PiliPalaX',
|
title: 'PiliPalaX',
|
||||||
theme: ThemeData(
|
theme: _getThemeData(
|
||||||
// fontFamily: 'HarmonyOS',
|
colorScheme: lightColorScheme,
|
||||||
colorScheme: currentThemeValue == ThemeType.dark
|
isDynamic: lightDynamic != null && isDynamicColor,
|
||||||
? darkColorScheme
|
|
||||||
: lightColorScheme,
|
|
||||||
useMaterial3: true,
|
|
||||||
navigationBarTheme: NavigationBarThemeData(
|
|
||||||
surfaceTintColor: (lightDynamic != null && isDynamicColor)
|
|
||||||
? lightColorScheme.surfaceTint
|
|
||||||
: lightColorScheme.surfaceContainer),
|
|
||||||
snackBarTheme: SnackBarThemeData(
|
|
||||||
actionTextColor: lightColorScheme.primary,
|
|
||||||
backgroundColor: lightColorScheme.secondaryContainer,
|
|
||||||
closeIconColor: lightColorScheme.secondary,
|
|
||||||
contentTextStyle: TextStyle(color: lightColorScheme.secondary),
|
|
||||||
elevation: 20,
|
|
||||||
),
|
|
||||||
pageTransitionsTheme: const PageTransitionsTheme(
|
|
||||||
builders: <TargetPlatform, PageTransitionsBuilder>{
|
|
||||||
TargetPlatform.android: ZoomPageTransitionsBuilder(
|
|
||||||
allowEnterRouteSnapshotting: false,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
popupMenuTheme: PopupMenuThemeData(
|
|
||||||
surfaceTintColor: lightColorScheme.surfaceTint,
|
|
||||||
),
|
|
||||||
cardTheme: CardTheme(
|
|
||||||
elevation: 1,
|
|
||||||
surfaceTintColor: lightColorScheme.surfaceTint,
|
|
||||||
shadowColor: Colors.transparent,
|
|
||||||
),
|
|
||||||
dialogTheme: DialogTheme(
|
|
||||||
surfaceTintColor: lightColorScheme.surfaceTint,
|
|
||||||
),
|
|
||||||
progressIndicatorTheme: ProgressIndicatorThemeData(
|
|
||||||
refreshBackgroundColor: lightColorScheme.onSecondary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
darkTheme: ThemeData(
|
darkTheme: _getThemeData(
|
||||||
// fontFamily: 'HarmonyOS',
|
colorScheme: darkColorScheme,
|
||||||
colorScheme: currentThemeValue == ThemeType.light
|
isDynamic: darkDynamic != null && isDynamicColor,
|
||||||
? lightColorScheme
|
|
||||||
: darkColorScheme,
|
|
||||||
useMaterial3: true,
|
|
||||||
navigationBarTheme: NavigationBarThemeData(
|
|
||||||
surfaceTintColor: (darkDynamic != null && isDynamicColor)
|
|
||||||
? darkColorScheme.surfaceTint
|
|
||||||
: darkColorScheme.surfaceContainer),
|
|
||||||
snackBarTheme: SnackBarThemeData(
|
|
||||||
actionTextColor: darkColorScheme.primary,
|
|
||||||
backgroundColor: darkColorScheme.secondaryContainer,
|
|
||||||
closeIconColor: darkColorScheme.secondary,
|
|
||||||
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
|
|
||||||
elevation: 20,
|
|
||||||
),
|
|
||||||
popupMenuTheme: PopupMenuThemeData(
|
|
||||||
surfaceTintColor: darkColorScheme.surfaceTint,
|
|
||||||
),
|
|
||||||
cardTheme: CardTheme(
|
|
||||||
elevation: 1,
|
|
||||||
surfaceTintColor: darkColorScheme.surfaceTint,
|
|
||||||
shadowColor: Colors.transparent,
|
|
||||||
),
|
|
||||||
dialogTheme: DialogTheme(
|
|
||||||
surfaceTintColor: darkColorScheme.surfaceTint,
|
|
||||||
),
|
|
||||||
progressIndicatorTheme: ProgressIndicatorThemeData(
|
|
||||||
refreshBackgroundColor: darkColorScheme.onSecondary,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
themeMode: GStorage.themeMode,
|
themeMode: GStorage.themeMode,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
@@ -257,4 +195,49 @@ class MyApp extends StatelessWidget {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThemeData _getThemeData({
|
||||||
|
required ColorScheme colorScheme,
|
||||||
|
required bool isDynamic,
|
||||||
|
}) {
|
||||||
|
Color surfaceTintColor =
|
||||||
|
isDynamic ? colorScheme.surfaceTint : colorScheme.surfaceContainer;
|
||||||
|
return ThemeData(
|
||||||
|
colorScheme: colorScheme,
|
||||||
|
useMaterial3: true,
|
||||||
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
|
surfaceTintColor: surfaceTintColor,
|
||||||
|
),
|
||||||
|
snackBarTheme: SnackBarThemeData(
|
||||||
|
actionTextColor: colorScheme.primary,
|
||||||
|
backgroundColor: colorScheme.secondaryContainer,
|
||||||
|
closeIconColor: colorScheme.secondary,
|
||||||
|
contentTextStyle: TextStyle(
|
||||||
|
color: colorScheme.secondary,
|
||||||
|
),
|
||||||
|
elevation: 20,
|
||||||
|
),
|
||||||
|
pageTransitionsTheme: const PageTransitionsTheme(
|
||||||
|
builders: <TargetPlatform, PageTransitionsBuilder>{
|
||||||
|
TargetPlatform.android: ZoomPageTransitionsBuilder(
|
||||||
|
allowEnterRouteSnapshotting: false,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
popupMenuTheme: PopupMenuThemeData(
|
||||||
|
surfaceTintColor: surfaceTintColor,
|
||||||
|
),
|
||||||
|
cardTheme: CardTheme(
|
||||||
|
elevation: 1,
|
||||||
|
surfaceTintColor: surfaceTintColor,
|
||||||
|
shadowColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
dialogTheme: DialogTheme(
|
||||||
|
surfaceTintColor: surfaceTintColor,
|
||||||
|
),
|
||||||
|
progressIndicatorTheme: ProgressIndicatorThemeData(
|
||||||
|
refreshBackgroundColor: colorScheme.onSecondary,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user