refactor(theme): 迁移主题感知颜色至 ThemeExtension

- 创建 AppThemeColors ThemeExtension 类,统一管理主题感知颜色(涨跌色、卡片背景、渐变等)
- 从 AppColorScheme 移除主题感知辅助函数,仅保留静态颜色常量
- 在 AppTheme 中注册 ThemeExtension,支持深色/浅色主题工厂
- 重构所有 UI 组件使用 context.appColors 访问主题颜色,替代硬编码的 AppColorScheme 方法调用
- 移除组件中重复的 isDark 判断逻辑,简化颜色获取方式
- 保持向后兼容性,所有现有功能不变
This commit is contained in:
2026-04-06 01:58:08 +08:00
parent 396668aa43
commit 7ed2435a4c
36 changed files with 658 additions and 810 deletions

View File

@@ -77,7 +77,7 @@ class MyApp extends StatelessWidget {
colorScheme: AppColorScheme.darkShad,
brightness: Brightness.dark,
),
appBuilder: _buildMaterialApp,
appBuilder: (context) => _buildMaterialApp(context, themeProvider.themeMode),
);
},
),
@@ -123,10 +123,12 @@ class MyApp extends StatelessWidget {
];
}
Widget _buildMaterialApp(BuildContext context) {
Widget _buildMaterialApp(BuildContext context, ThemeMode themeMode) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: Theme.of(context),
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
themeMode: themeMode,
localizationsDelegates: const [
GlobalShadLocalizations.delegate,
GlobalMaterialLocalizations.delegate,