2026-04-05 22:38:56 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import '../../../../core/theme/app_spacing.dart';
|
2026-04-05 23:37:27 +08:00
|
|
|
|
import '../../../../core/theme/app_theme.dart';
|
2026-04-06 01:58:08 +08:00
|
|
|
|
import '../../../../core/theme/app_theme_extension.dart';
|
2026-04-05 22:38:56 +08:00
|
|
|
|
import '../../../../data/models/coin.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// 价格卡片组件
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 显示当前币种价格和 24h 涨跌幅。
|
|
|
|
|
|
/// 布局:大号价格(32px bold) + 涨跌幅徽章(圆角sm,涨绿背景) + "24h 变化" 副标题。
|
|
|
|
|
|
class PriceCard extends StatelessWidget {
|
|
|
|
|
|
final Coin coin;
|
|
|
|
|
|
const PriceCard({super.key, required this.coin});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final isUp = coin.isUp;
|
|
|
|
|
|
final changeColor =
|
2026-04-06 01:58:08 +08:00
|
|
|
|
isUp ? context.appColors.up : context.appColors.down;
|
2026-04-05 22:38:56 +08:00
|
|
|
|
final changeBgColor = isUp
|
2026-04-06 01:58:08 +08:00
|
|
|
|
? context.appColors.upBackground
|
|
|
|
|
|
: context.appColors.downBackground;
|
2026-04-05 22:38:56 +08:00
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
width: double.infinity,
|
2026-04-05 23:37:27 +08:00
|
|
|
|
padding: const EdgeInsets.all(AppSpacing.md + AppSpacing.sm),
|
2026-04-05 22:38:56 +08:00
|
|
|
|
decoration: BoxDecoration(
|
2026-04-06 01:58:08 +08:00
|
|
|
|
color: context.appColors.surfaceCard,
|
2026-04-05 22:38:56 +08:00
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
|
|
|
|
border: Border.all(
|
2026-04-06 01:58:08 +08:00
|
|
|
|
color: context.appColors.ghostBorder,
|
2026-04-05 22:38:56 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: [
|
|
|
|
|
|
// 价格行:大号价格 + 涨跌幅徽章
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: [
|
|
|
|
|
|
Text(
|
|
|
|
|
|
coin.formattedPrice,
|
2026-04-05 23:37:27 +08:00
|
|
|
|
style: AppTextStyles.numberLarge(context).copyWith(fontSize: 32),
|
2026-04-05 22:38:56 +08:00
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: AppSpacing.sm),
|
|
|
|
|
|
// 涨跌幅徽章 - 圆角sm,涨绿背景
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
|
horizontal: AppSpacing.sm, vertical: AppSpacing.xs),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: changeBgColor,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
coin.formattedChange,
|
2026-04-05 23:37:27 +08:00
|
|
|
|
style: AppTextStyles.numberSmall(context).copyWith(
|
2026-04-05 22:38:56 +08:00
|
|
|
|
color: changeColor,
|
2026-04-05 23:37:27 +08:00
|
|
|
|
fontWeight: FontWeight.w600,
|
2026-04-05 22:38:56 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: AppSpacing.sm),
|
|
|
|
|
|
// 副标题
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'24h 变化',
|
2026-04-05 23:37:27 +08:00
|
|
|
|
style: AppTextStyles.bodySmall(context),
|
2026-04-05 22:38:56 +08:00
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|