mirror of
https://github.com/hiddify/hiddify-next.git
synced 2026-06-05 21:05:07 +08:00
65 lines
2.8 KiB
Dart
65 lines
2.8 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hiddify/core/theme/app_theme_mode.dart';
|
|
import 'package:hiddify/core/theme/theme_extensions.dart';
|
|
|
|
class AppTheme {
|
|
AppTheme(this.mode, this.fontFamily);
|
|
final AppThemeMode mode;
|
|
final String fontFamily;
|
|
|
|
ThemeData lightTheme(ColorScheme? lightColorScheme) {
|
|
final ColorScheme scheme = lightColorScheme ?? ColorScheme.fromSeed(seedColor: const Color(0xFF293CA0));
|
|
return ThemeData(
|
|
useMaterial3: true,
|
|
colorScheme: scheme,
|
|
fontFamily: fontFamily,
|
|
extensions: const <ThemeExtension<dynamic>>{ConnectionButtonTheme.light},
|
|
);
|
|
}
|
|
|
|
ThemeData darkTheme(ColorScheme? darkColorScheme) {
|
|
final ColorScheme scheme =
|
|
darkColorScheme ?? ColorScheme.fromSeed(seedColor: const Color(0xFF293CA0), brightness: Brightness.dark);
|
|
return ThemeData(
|
|
useMaterial3: true,
|
|
colorScheme: scheme,
|
|
scaffoldBackgroundColor: mode.trueBlack ? Colors.black : scheme.background,
|
|
fontFamily: fontFamily,
|
|
extensions: const <ThemeExtension<dynamic>>{ConnectionButtonTheme.light},
|
|
);
|
|
}
|
|
|
|
CupertinoThemeData cupertinoThemeData(bool sysDark, ColorScheme? lightColorScheme, ColorScheme? darkColorScheme) {
|
|
final bool isDark = switch (mode) {
|
|
AppThemeMode.system => sysDark,
|
|
AppThemeMode.light => false,
|
|
AppThemeMode.dark => true,
|
|
AppThemeMode.black => true,
|
|
};
|
|
final def = CupertinoThemeData(brightness: isDark ? Brightness.dark : Brightness.light);
|
|
// final def = CupertinoThemeData(brightness: Brightness.dark);
|
|
|
|
// return def;
|
|
final defaultMaterialTheme = isDark ? darkTheme(darkColorScheme) : lightTheme(lightColorScheme);
|
|
return MaterialBasedCupertinoThemeData(
|
|
materialTheme: defaultMaterialTheme.copyWith(
|
|
cupertinoOverrideTheme: def.copyWith(
|
|
textTheme: CupertinoTextThemeData(
|
|
textStyle: def.textTheme.textStyle.copyWith(fontFamily: fontFamily),
|
|
actionTextStyle: def.textTheme.actionTextStyle.copyWith(fontFamily: fontFamily),
|
|
navActionTextStyle: def.textTheme.navActionTextStyle.copyWith(fontFamily: fontFamily),
|
|
navTitleTextStyle: def.textTheme.navTitleTextStyle.copyWith(fontFamily: fontFamily),
|
|
navLargeTitleTextStyle: def.textTheme.navLargeTitleTextStyle.copyWith(fontFamily: fontFamily),
|
|
pickerTextStyle: def.textTheme.pickerTextStyle.copyWith(fontFamily: fontFamily),
|
|
dateTimePickerTextStyle: def.textTheme.dateTimePickerTextStyle.copyWith(fontFamily: fontFamily),
|
|
tabLabelTextStyle: def.textTheme.tabLabelTextStyle.copyWith(fontFamily: fontFamily),
|
|
).copyWith(),
|
|
barBackgroundColor: def.barBackgroundColor,
|
|
scaffoldBackgroundColor: def.scaffoldBackgroundColor,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|