generated from dellevin/template
适配深色模式
This commit is contained in:
@@ -51,6 +51,10 @@ class AppTheme {
|
||||
onSurface: _black,
|
||||
error: error,
|
||||
onError: _white,
|
||||
surfaceContainerHighest: _offWhite,
|
||||
surfaceContainerHigh: Color(0xFFFAFAFA),
|
||||
outline: _lighterGray,
|
||||
outlineVariant: Color(0xFFF0F0F0),
|
||||
),
|
||||
|
||||
// AppBar - 极简无边框
|
||||
@@ -262,6 +266,10 @@ class AppTheme {
|
||||
onSurface: _white,
|
||||
error: Color(0xFFEF4444),
|
||||
onError: _black,
|
||||
surfaceContainerHighest: _darkGray,
|
||||
surfaceContainerHigh: Color(0xFF2A2A2A),
|
||||
outline: _gray,
|
||||
outlineVariant: _darkGray,
|
||||
),
|
||||
|
||||
appBarTheme: const AppBarTheme(
|
||||
@@ -286,6 +294,12 @@ class AppTheme {
|
||||
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
|
||||
margin: EdgeInsets.zero,
|
||||
),
|
||||
|
||||
listTileTheme: const ListTileThemeData(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
minLeadingWidth: 0,
|
||||
dense: true,
|
||||
),
|
||||
|
||||
dividerTheme: DividerThemeData(
|
||||
color: _darkGray,
|
||||
@@ -304,6 +318,9 @@ class AppTheme {
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: _white, width: 1),
|
||||
),
|
||||
errorBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFFEF4444), width: 0.5),
|
||||
),
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 12),
|
||||
hintStyle: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
@@ -311,6 +328,12 @@ class AppTheme {
|
||||
fontWeight: _regular,
|
||||
color: _gray,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 13,
|
||||
fontWeight: _medium,
|
||||
color: _lightGray,
|
||||
),
|
||||
),
|
||||
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
@@ -327,6 +350,11 @@ class AppTheme {
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: _white,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
textStyle: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: _medium,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -335,6 +363,84 @@ class AppTheme {
|
||||
selectedItemColor: _white,
|
||||
unselectedItemColor: _gray,
|
||||
elevation: 0,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
selectedLabelStyle: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 11,
|
||||
fontWeight: _medium,
|
||||
),
|
||||
unselectedLabelStyle: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 11,
|
||||
fontWeight: _regular,
|
||||
),
|
||||
),
|
||||
|
||||
textTheme: const TextTheme(
|
||||
headlineLarge: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 32,
|
||||
fontWeight: _semibold,
|
||||
color: _white,
|
||||
letterSpacing: -0.5,
|
||||
height: 1.2,
|
||||
),
|
||||
headlineMedium: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 24,
|
||||
fontWeight: _semibold,
|
||||
color: _white,
|
||||
letterSpacing: -0.3,
|
||||
height: 1.3,
|
||||
),
|
||||
headlineSmall: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 20,
|
||||
fontWeight: _semibold,
|
||||
color: _white,
|
||||
letterSpacing: -0.2,
|
||||
height: 1.4,
|
||||
),
|
||||
bodyLarge: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 16,
|
||||
fontWeight: _regular,
|
||||
color: _offWhite,
|
||||
height: 1.6,
|
||||
),
|
||||
bodyMedium: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 15,
|
||||
fontWeight: _regular,
|
||||
color: _offWhite,
|
||||
height: 1.5,
|
||||
),
|
||||
bodySmall: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 13,
|
||||
fontWeight: _regular,
|
||||
color: _lightGray,
|
||||
height: 1.5,
|
||||
),
|
||||
labelLarge: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: _medium,
|
||||
color: _white,
|
||||
),
|
||||
labelMedium: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 12,
|
||||
fontWeight: _medium,
|
||||
color: _lightGray,
|
||||
),
|
||||
labelSmall: TextStyle(
|
||||
fontFamily: _fontFamily,
|
||||
fontSize: 11,
|
||||
fontWeight: _medium,
|
||||
color: _gray,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ class UsageStatsService with WidgetsBindingObserver {
|
||||
final UserPrefs _prefs = UserPrefs();
|
||||
|
||||
/// 统计服务器地址,发布前替换为实际地址,置空则禁用
|
||||
static String serverUrl = 'http://api.mooknote.iletter.top/';
|
||||
|
||||
// static String serverUrl = 'http://api.mooknote.iletter.top/';
|
||||
static String serverUrl = 'http://192.168.31.48:27050/';
|
||||
Timer? _heartbeatTimer;
|
||||
bool _started = false;
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ class UserPrefs {
|
||||
/// 初始化
|
||||
static Future<void> init() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
// 迁移旧版 isDarkMode 布尔值到新版 themeMode 三态值
|
||||
if (_prefs!.containsKey('isDarkMode') && !_prefs!.containsKey('themeMode')) {
|
||||
final oldValue = _prefs!.getBool('isDarkMode') ?? false;
|
||||
await _prefs!.setInt('themeMode', oldValue ? 2 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取实例
|
||||
@@ -38,9 +43,9 @@ class UserPrefs {
|
||||
|
||||
// ========== 应用设置 ==========
|
||||
|
||||
/// 是否暗黑模式
|
||||
bool get isDarkMode => prefs.getBool('isDarkMode') ?? false;
|
||||
Future<bool> setDarkMode(bool value) => prefs.setBool('isDarkMode', value);
|
||||
/// 主题模式: 0=跟随系统, 1=浅色, 2=深色
|
||||
int get themeMode => prefs.getInt('themeMode') ?? 0;
|
||||
Future<bool> setThemeMode(int value) => prefs.setInt('themeMode', value);
|
||||
|
||||
/// 是否首次启动
|
||||
bool get isFirstLaunch => prefs.getBool('isFirstLaunch') ?? true;
|
||||
|
||||
Reference in New Issue
Block a user