80 lines
2.6 KiB
Dart
80 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
||
import '../../../../core/theme/app_spacing.dart';
|
||
import '../../../../core/theme/app_theme.dart';
|
||
import '../../../../core/theme/app_theme_extension.dart';
|
||
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 =
|
||
isUp ? context.appColors.up : context.appColors.down;
|
||
final changeBgColor = isUp
|
||
? context.appColors.upBackground
|
||
: context.appColors.downBackground;
|
||
|
||
return Container(
|
||
width: double.infinity,
|
||
padding: const EdgeInsets.all(20), // 24px → 20px
|
||
decoration: BoxDecoration(
|
||
color: context.appColors.surfaceCard,
|
||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||
border: Border.all(
|
||
color: context.appColors.ghostBorder,
|
||
),
|
||
),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
// 價格行:大號價格 + 漲跌幅徽章
|
||
Row(
|
||
children: [
|
||
Flexible(
|
||
child: FittedBox(
|
||
fit: BoxFit.scaleDown,
|
||
alignment: Alignment.centerLeft,
|
||
child: Text(
|
||
coin.formattedPrice,
|
||
style: AppTextStyles.numberLarge(context).copyWith(fontSize: 24),
|
||
),
|
||
),
|
||
),
|
||
const SizedBox(width: AppSpacing.sm),
|
||
// 漲跌幅徽章 - 圓角sm,漲綠背景
|
||
Container(
|
||
padding: const EdgeInsets.symmetric(
|
||
horizontal: 8, vertical: 4), // 調整 padding
|
||
decoration: BoxDecoration(
|
||
color: changeBgColor,
|
||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||
),
|
||
child: Text(
|
||
coin.formattedChange,
|
||
style: AppTextStyles.numberSmall(context).copyWith(
|
||
color: changeColor,
|
||
fontWeight: FontWeight.w600,
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
const SizedBox(height: AppSpacing.sm),
|
||
// 副標題
|
||
Text(
|
||
'24h 變化',
|
||
style: AppTextStyles.bodySmall(context),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|