Files
monisuo/flutter_monisuo/lib/ui/components/coin_card.dart
sion ed25bb2da4 refactor: 优化字号主题体系,参考成熟交易平台标准
- 重构主题字号体系 (h1-h4, body, amount等)
- 修复16个页面文件中的硬编码字号
- 新字号层级参考币安/OKX标准
- Display: 22/20/18px (总资产、价格)
- Headline: 15/14/13px (标题、副标题)
- Body: 13/12/11px (正文、辅助文字)
- Label: 11/10/9px (标签)
- Number: 22/16/13px (数字)
2026-04-01 12:49:17 +08:00

101 lines
2.8 KiB
Dart

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;
final String price;
final String change;
final bool isUp;
final String? icon;
final VoidCallback? onTap;
const CoinCard({
super.key,
required this.code,
required this.name,
required this.price,
required this.change,
this.isUp = true,
this.icon,
this.onTap,
});
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
return ShadCard(
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
onTap: onTap,
child: Row(
children: [
// 图标 - 圆形
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: theme.colorScheme.primary.withValues(alpha: 0.1),
shape: BoxShape.circle,
),
child: Center(
child: Text(
icon ?? code.substring(0, 1),
style: TextStyle(
fontSize: 16,
color: theme.colorScheme.primary,
fontWeight: FontWeight.bold,
),
),
),
),
const SizedBox(width: AppSpacing.sm),
// 名称
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'$code/USDT',
style: theme.textTheme.large.copyWith(
fontWeight: FontWeight.bold,
),
),
Text(
name,
style: theme.textTheme.muted,
),
],
),
),
// 涨跌幅 - Dynamic Chip
Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: getChangeBackgroundColor(isUp),
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Text(
change,
style: TextStyle(
color: getChangeColor(isUp),
fontWeight: FontWeight.w600,
),
),
),
],
),
),
);
}
}