- Convert instance methods to static methods in AppColorScheme for getChangeColor and getChangeBackgroundColor - Update main.dart to use ShadThemeData with AppColorScheme color schemes instead of createLight/DarkShadTheme functions - Add app_theme.dart import to main.dart - Refactor asset_card.dart and coin_card.dart to call static methods via AppColorScheme class - Add app_spacing.dart import to action_buttons_row.dart - Replace SizedBox with proper spacing constants in action buttons row
101 lines
2.8 KiB
Dart
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: AppColorScheme.getChangeBackgroundColor(isUp),
|
|
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
),
|
|
child: Text(
|
|
change,
|
|
style: TextStyle(
|
|
color: AppColorScheme.getChangeColor(isUp),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|