fix(theme): 修复亮色模式绿色对比度不足问题
- 添加主题感知颜色函数: getUpColor/getUpBackgroundColor - app_color_scheme: 新增 getBuyGradient/getEmeraldGradient - asset_card: emeraldGradient 支持主题切换 - neon_glow: 按钮颜色主题感知 - home_page: 涨跌颜色动态适配 - asset_page: 资产涨跌颜色适配 - trade_page: 交易涨跌颜色适配 - mine_page: 我的页面颜色适配 修复: 亮色模式下绿色 (#00a878) 与浅色背景对比度不足 效果: 亮色模式使用深绿色,深色模式使用亮绿色
This commit is contained in:
@@ -153,7 +153,7 @@ class AppColorScheme {
|
||||
// 语义色 - 明暗通用
|
||||
// ============================================
|
||||
|
||||
/// 涨/买入/成功
|
||||
/// 涨/买入/成功 (深色主题色,亮色模式下请使用 getUpColor)
|
||||
static const Color up = darkTertiary;
|
||||
static const Color success = darkTertiary;
|
||||
|
||||
@@ -170,6 +170,42 @@ class AppColorScheme {
|
||||
/// 信息
|
||||
static const Color info = Color(0xFF2196F3);
|
||||
|
||||
// ============================================
|
||||
// 主题感知辅助函数 - 根据明暗模式选择正确的颜色
|
||||
// ============================================
|
||||
|
||||
/// 获取涨跌颜色(主题感知)
|
||||
///
|
||||
/// 在深色模式下使用亮绿色 (#afffd1),在亮色模式下使用深绿色 (#00a878) 以确保对比度
|
||||
static Color getUpColor(bool isDark) => isDark ? darkTertiary : lightTertiary;
|
||||
|
||||
/// 获取涨跌背景色(主题感知)
|
||||
///
|
||||
/// 带透明度的背景色,用于标签、徽章等
|
||||
static Color getUpBackgroundColor(bool isDark, {double opacity = 0.15}) {
|
||||
return isDark
|
||||
? darkTertiary.withValues(alpha: opacity)
|
||||
: lightTertiary.withValues(alpha: opacity);
|
||||
}
|
||||
|
||||
/// 获取买入按钮渐变(主题感知)
|
||||
static LinearGradient getBuyGradient(bool isDark) => LinearGradient(
|
||||
colors: isDark
|
||||
? [darkTertiary, darkTertiaryContainer]
|
||||
: [lightTertiary, lightTertiaryContainer],
|
||||
begin: const Alignment(-0.7, -0.7),
|
||||
end: const Alignment(0.7, 0.7),
|
||||
);
|
||||
|
||||
/// 获取翡翠渐变(主题感知)- 用于盈利展示
|
||||
static LinearGradient getEmeraldGradient(bool isDark) => LinearGradient(
|
||||
colors: isDark
|
||||
? [darkTertiary, const Color(0xFF7de8b8)]
|
||||
: [lightTertiary, const Color(0xFF00c987)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
);
|
||||
|
||||
// ============================================
|
||||
// 渐变预设
|
||||
// ============================================
|
||||
@@ -434,12 +470,25 @@ ShadThemeData createLightShadTheme() {
|
||||
);
|
||||
}
|
||||
|
||||
/// 获取涨跌颜色(明暗通用)
|
||||
/// 获取涨跌颜色(明暗通用)- 已废弃,请使用带主题感知的版本
|
||||
@Deprecated('Use AppColorScheme.getUpColor(isDark) instead')
|
||||
Color getChangeColor(bool isUp) => isUp ? AppColorScheme.up : AppColorScheme.down;
|
||||
|
||||
/// 获取涨跌背景色(带透明度)
|
||||
/// 获取涨跌背景色(带透明度)- 已废弃,请使用带主题感知的版本
|
||||
@Deprecated('Use AppColorScheme.getUpBackgroundColor(isDark, opacity: opacity) instead')
|
||||
Color getChangeBackgroundColor(bool isUp, {double opacity = 0.15}) {
|
||||
return isUp
|
||||
? AppColorScheme.up.withValues(alpha: opacity)
|
||||
: AppColorScheme.down.withValues(alpha: opacity);
|
||||
}
|
||||
|
||||
/// 获取涨跌颜色(主题感知)
|
||||
Color getChangeColorThemeAware(bool isUp, bool isDark) =>
|
||||
isUp ? AppColorScheme.getUpColor(isDark) : AppColorScheme.down;
|
||||
|
||||
/// 获取涨跌背景色(主题感知)
|
||||
Color getChangeBackgroundColorThemeAware(bool isUp, bool isDark, {double opacity = 0.15}) {
|
||||
return isUp
|
||||
? AppColorScheme.getUpBackgroundColor(isDark, opacity: opacity)
|
||||
: AppColorScheme.down.withValues(alpha: opacity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user