refactor(theme): 迁移主题感知颜色至 ThemeExtension
- 创建 AppThemeColors ThemeExtension 类,统一管理主题感知颜色(涨跌色、卡片背景、渐变等) - 从 AppColorScheme 移除主题感知辅助函数,仅保留静态颜色常量 - 在 AppTheme 中注册 ThemeExtension,支持深色/浅色主题工厂 - 重构所有 UI 组件使用 context.appColors 访问主题颜色,替代硬编码的 AppColorScheme 方法调用 - 移除组件中重复的 isDark 判断逻辑,简化颜色获取方式 - 保持向后兼容性,所有现有功能不变
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/theme/app_color_scheme.dart';
|
||||
import '../../../core/theme/app_theme_extension.dart';
|
||||
import '../../../core/theme/app_spacing.dart';
|
||||
import '../../../providers/asset_provider.dart';
|
||||
import '../../../data/models/account_models.dart';
|
||||
@@ -76,12 +76,6 @@ class _TransferPageState extends State<TransferPage> {
|
||||
String get _fromBalance => _direction == 1 ? _fundBalance : _tradeUsdtBalance;
|
||||
String get _toBalance => _direction == 1 ? _tradeUsdtBalance : _fundBalance;
|
||||
|
||||
// ============================================
|
||||
// 主题辅助
|
||||
// ============================================
|
||||
|
||||
bool get _isDark => Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
// ============================================
|
||||
// 业务逻辑
|
||||
// ============================================
|
||||
@@ -363,7 +357,7 @@ class _TransferPageState extends State<TransferPage> {
|
||||
decoration: InputDecoration(
|
||||
hintText: '0.00',
|
||||
hintStyle: AppTextStyles.numberLarge(context).copyWith(
|
||||
color: AppColorScheme.darkOnSurfaceMuted,
|
||||
color: context.appColors.onSurfaceMuted,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
@@ -375,7 +369,7 @@ class _TransferPageState extends State<TransferPage> {
|
||||
padding: const EdgeInsets.only(left: AppSpacing.sm),
|
||||
child: Text('USDT', style: AppTextStyles.headlineMedium(context).copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColorScheme.darkOnSurfaceMuted,
|
||||
color: context.appColors.onSurfaceMuted,
|
||||
)),
|
||||
),
|
||||
],
|
||||
@@ -425,13 +419,13 @@ class _TransferPageState extends State<TransferPage> {
|
||||
// ============================================
|
||||
|
||||
Widget _buildTipsCard() {
|
||||
final upColor = AppColorScheme.getUpColor(_isDark);
|
||||
final upColor = context.appColors.up;
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColorScheme.getUpBackgroundColor(_isDark),
|
||||
color: context.appColors.upBackground,
|
||||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||||
),
|
||||
child: Row(
|
||||
|
||||
Reference in New Issue
Block a user