feat(theme): 重构颜色系统为双主题设计并添加渐变组件

- 引入 "The Kinetic Vault"(深色)和 "The Ethereal Terminal"(浅色)双主题系统
- 重构颜色方案,使用层次化 surface 容器替代边框,遵循无边框设计规则
- 添加渐变预设(CTA、买入/卖出、资产卡片)和渐变按钮组件
- 更新圆角系统,明确按钮、卡片、输入框和标签的圆角规范
- 统一文本样式系统,使用 Space Grotesk(标题)和 Manrope(正文)字体
- 更新现有组件(AssetCard、CoinCard、TradeButton)以遵循新设计规范
- 添加向后兼容的已废弃常量,确保现有代码正常运行
This commit is contained in:
2026-03-23 22:11:26 +08:00
parent e01f3330a2
commit a7bec4cfde
7 changed files with 775 additions and 266 deletions

View File

@@ -1,8 +1,16 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:flutter_animate/flutter_animate.dart';
import '../../core/theme/app_color_scheme.dart';
import '../../core/theme/app_spacing.dart';
/// 资产卡片组件 - 用于显示资产总览
///
/// 设计规则 ("The Kinetic Vault"):
/// - 渐变背景: Neon Blue → Electric Purple
/// - 圆角: xl (16px)
/// - 无边框,使用渐变层次
/// - 微妙阴影: 10% black, blur 10px
class AssetCard extends StatelessWidget {
final String title;
final String balance;
@@ -13,16 +21,16 @@ class AssetCard extends StatelessWidget {
final Gradient? gradient;
final VoidCallback? onTap;
// 默认渐变色 - 使用品牌青绿色
/// 默认渐变色 - Neon Blue → Electric Purple
static const defaultGradient = LinearGradient(
colors: [AppColorScheme.primaryDark, Color(0xFF00B894)],
colors: [AppColorScheme.darkPrimary, AppColorScheme.darkSecondary],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
// 深色渐变
static const darkGradient = LinearGradient(
colors: [Color(0xFF1E3A5F), Color(0xFF0D253F)],
/// 翡翠渐变 - 用于盈利展示
static const emeraldGradient = LinearGradient(
colors: [AppColorScheme.darkTertiary, Color(0xFF7de8b8)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
@@ -48,10 +56,10 @@ class AssetCard extends StatelessWidget {
onTap: onTap,
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
padding: const EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
gradient: cardGradient,
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(AppRadius.xl),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
@@ -79,18 +87,19 @@ class AssetCard extends StatelessWidget {
),
],
),
const SizedBox(height: 8),
// 余额
const SizedBox(height: AppSpacing.sm),
// 余额 - 大标题
Text(
balance,
style: theme.textTheme.h1.copyWith(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 32,
),
),
// 盈亏信息
if (profit != null) ...[
const SizedBox(height: 12),
const SizedBox(height: AppSpacing.md),
Row(
children: [
Icon(
@@ -108,7 +117,7 @@ class AssetCard extends StatelessWidget {
],
// 子项
if (items != null && items!.isNotEmpty) ...[
const SizedBox(height: 20),
const SizedBox(height: AppSpacing.lg),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: items!.map((item) => _buildItem(item)).toList(),
@@ -154,6 +163,11 @@ class AssetItem {
}
/// 简洁资产卡片 - 用于列表中显示
///
/// 设计规则:
/// - 使用 surface 层次而非边框
/// - 圆角: xl (16px)
/// - 涨跌标签: 15% 透明度背景
class AssetCardCompact extends StatelessWidget {
final String title;
final String balance;
@@ -176,7 +190,7 @@ class AssetCardCompact extends StatelessWidget {
final isValueUp = isUp ?? true;
return ShadCard(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
onTap: onTap,
child: Row(
@@ -204,7 +218,7 @@ class AssetCardCompact extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: getChangeBackgroundColor(isValueUp),
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
change!,

View File

@@ -1,8 +1,14 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../core/theme/app_color_scheme.dart';
import '../../core/theme/app_spacing.dart';
/// 币种卡片组件 - 用于显示币种信息
///
/// 设计规则:
/// - 使用 surface 层次而非边框
/// - 圆角: xl (16px) 卡片, sm (4px) 涨跌标签
/// - 涨跌标签: 15% 透明度背景
class CoinCard extends StatelessWidget {
final String code;
final String name;
@@ -28,12 +34,12 @@ class CoinCard extends StatelessWidget {
final theme = ShadTheme.of(context);
return ShadCard(
padding: const EdgeInsets.all(16),
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
onTap: onTap,
child: Row(
children: [
// 图标
// 图标 - 圆形
Container(
width: 44,
height: 44,
@@ -52,7 +58,7 @@ class CoinCard extends StatelessWidget {
),
),
),
const SizedBox(width: 12),
const SizedBox(width: AppSpacing.sm),
// 名称
Expanded(
child: Column(
@@ -71,12 +77,12 @@ class CoinCard extends StatelessWidget {
],
),
),
// 涨跌幅
// 涨跌幅 - Dynamic Chip
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: getChangeBackgroundColor(isUp),
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
change,

View File

@@ -0,0 +1,223 @@
import 'package:flutter/material.dart';
import '../../core/theme/app_color_scheme.dart';
import '../../core/theme/app_spacing.dart';
/// 渐变按钮组件 - 支持 CTA 渐变效果
///
/// 设计规则:
/// - 渐变方向: 135度 (primary → primary_container)
/// - 圆角: xxl (24px / 1.5rem)
/// - 无边框
class GradientButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool isLoading;
final bool isFullWidth;
final LinearGradient? gradient;
final IconData? icon;
final double height;
const GradientButton({
super.key,
required this.text,
this.onPressed,
this.isLoading = false,
this.isFullWidth = true,
this.gradient,
this.icon,
this.height = 48,
});
/// CTA 按钮 - 使用主题渐变
factory GradientButton.cta({
Key? key,
required String text,
VoidCallback? onPressed,
bool isLoading = false,
bool isFullWidth = true,
IconData? icon,
bool isDark = true,
}) {
return GradientButton(
key: key,
text: text,
onPressed: onPressed,
isLoading: isLoading,
isFullWidth: isFullWidth,
icon: icon,
gradient: isDark ? AppColorScheme.darkCtaGradient : AppColorScheme.lightCtaGradient,
);
}
/// 买入按钮 - 翡翠绿渐变
factory GradientButton.buy({
Key? key,
required String text,
VoidCallback? onPressed,
bool isLoading = false,
bool isFullWidth = true,
IconData? icon,
}) {
return GradientButton(
key: key,
text: text,
onPressed: onPressed,
isLoading: isLoading,
isFullWidth: isFullWidth,
icon: icon ?? Icons.arrow_downward_rounded,
gradient: AppColorScheme.buyGradient,
);
}
/// 卖出按钮 - 红色渐变
factory GradientButton.sell({
Key? key,
required String text,
VoidCallback? onPressed,
bool isLoading = false,
bool isFullWidth = true,
IconData? icon,
}) {
return GradientButton(
key: key,
text: text,
onPressed: onPressed,
isLoading: isLoading,
isFullWidth: isFullWidth,
icon: icon ?? Icons.arrow_upward_rounded,
gradient: AppColorScheme.sellGradient,
);
}
@override
Widget build(BuildContext context) {
final buttonGradient = gradient ?? AppColorScheme.darkCtaGradient;
return Container(
width: isFullWidth ? double.infinity : null,
height: height,
decoration: BoxDecoration(
gradient: buttonGradient,
borderRadius: BorderRadius.circular(AppRadius.xxl),
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: isLoading ? null : onPressed,
borderRadius: BorderRadius.circular(AppRadius.xxl),
child: Center(
child: Row(
mainAxisSize: isFullWidth ? MainAxisSize.max : MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
else ...[
if (icon != null) ...[
Icon(icon, size: 18, color: Colors.white),
SizedBox(width: AppSpacing.sm),
],
Text(
text,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
],
),
),
),
),
);
}
}
/// Ghost 按钮 - 次要操作
///
/// 设计规则:
/// - Ghost Border: 15% opacity outline-variant
/// - 圆角: xxl (24px)
/// - 主色文字
class GhostButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool isLoading;
final bool isFullWidth;
final IconData? icon;
const GhostButton({
super.key,
required this.text,
this.onPressed,
this.isLoading = false,
this.isFullWidth = true,
this.icon,
});
@override
Widget build(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final textColor = isDark ? AppColorScheme.darkPrimary : AppColorScheme.lightPrimary;
final borderColor = isDark
? AppColorScheme.darkOutlineVariant.withValues(alpha: 0.15)
: AppColorScheme.lightOutlineVariant.withValues(alpha: 0.3);
return Container(
width: isFullWidth ? double.infinity : null,
height: 48,
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(color: borderColor, width: 1),
borderRadius: BorderRadius.circular(AppRadius.xxl),
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: isLoading ? null : onPressed,
borderRadius: BorderRadius.circular(AppRadius.xxl),
child: Center(
child: Row(
mainAxisSize: isFullWidth ? MainAxisSize.max : MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: textColor,
),
)
else ...[
if (icon != null) ...[
Icon(icon, size: 18, color: textColor),
SizedBox(width: AppSpacing.sm),
],
Text(
text,
style: TextStyle(
color: textColor,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
],
),
),
),
),
);
}
}

View File

@@ -1,8 +1,14 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../core/theme/app_color_scheme.dart';
import '../../core/theme/app_spacing.dart';
/// 交易按钮组件 - 买入/卖出按钮
///
/// 设计规则:
/// - 渐变按钮: 135度渐变
/// - 圆角: xxl (24px / 1.5rem)
/// - 买入: 翡翠绿渐变
/// - 卖出: 红色渐变
class TradeButton extends StatelessWidget {
final bool isBuy;
final String? coinCode;
@@ -39,44 +45,57 @@ class TradeButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = isBuy ? AppColorScheme.up : AppColorScheme.down;
final text = isBuy ? '买入${coinCode != null ? ' $coinCode' : ''}' : '卖出${coinCode != null ? ' $coinCode' : ''}';
final icon = isBuy ? LucideIcons.arrowDownToLine : LucideIcons.arrowUpFromLine;
final gradient = isBuy ? AppColorScheme.buyGradient : AppColorScheme.sellGradient;
final text = isBuy
? '买入${coinCode != null ? ' $coinCode' : ''}'
: '卖出${coinCode != null ? ' $coinCode' : ''}';
final button = ShadButton(
backgroundColor: color,
onPressed: isLoading ? null : onPressed,
child: Row(
mainAxisSize: fullWidth ? MainAxisSize.max : MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
const SizedBox.square(
dimension: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
else
Icon(icon, size: 18, color: Colors.white),
const SizedBox(width: 8),
Text(
text,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
return Container(
width: fullWidth ? double.infinity : null,
height: 48,
decoration: BoxDecoration(
gradient: gradient,
borderRadius: BorderRadius.circular(AppRadius.xxl),
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: isLoading ? null : onPressed,
borderRadius: BorderRadius.circular(AppRadius.xxl),
child: Center(
child: Row(
mainAxisSize: fullWidth ? MainAxisSize.max : MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isLoading)
const SizedBox.square(
dimension: 16,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
else
Icon(
isBuy ? Icons.arrow_downward_rounded : Icons.arrow_upward_rounded,
size: 18,
color: Colors.white,
),
const SizedBox(width: 8),
Text(
text,
style: const TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
),
),
],
),
),
);
if (fullWidth) {
return SizedBox(width: double.infinity, child: button);
}
return button;
}
}
@@ -108,7 +127,7 @@ class TradeButtonGroup extends StatelessWidget {
isLoading: isBuyLoading,
),
),
const SizedBox(width: 12),
const SizedBox(width: AppSpacing.sm),
Expanded(
child: TradeButton.sell(
coinCode: coinCode,