- 引入 "The Kinetic Vault"(深色)和 "The Ethereal Terminal"(浅色)双主题系统 - 重构颜色方案,使用层次化 surface 容器替代边框,遵循无边框设计规则 - 添加渐变预设(CTA、买入/卖出、资产卡片)和渐变按钮组件 - 更新圆角系统,明确按钮、卡片、输入框和标签的圆角规范 - 统一文本样式系统,使用 Space Grotesk(标题)和 Manrope(正文)字体 - 更新现有组件(AssetCard、CoinCard、TradeButton)以遵循新设计规范 - 添加向后兼容的已废弃常量,确保现有代码正常运行
142 lines
3.7 KiB
Dart
142 lines
3.7 KiB
Dart
import 'package:flutter/material.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;
|
|
final VoidCallback? onPressed;
|
|
final bool isLoading;
|
|
final bool fullWidth;
|
|
|
|
const TradeButton({
|
|
super.key,
|
|
this.isBuy = true,
|
|
this.coinCode,
|
|
this.onPressed,
|
|
this.isLoading = false,
|
|
this.fullWidth = false,
|
|
});
|
|
|
|
/// 买入按钮
|
|
const TradeButton.buy({
|
|
super.key,
|
|
this.coinCode,
|
|
this.onPressed,
|
|
this.isLoading = false,
|
|
this.fullWidth = false,
|
|
}) : isBuy = true;
|
|
|
|
/// 卖出按钮
|
|
const TradeButton.sell({
|
|
super.key,
|
|
this.coinCode,
|
|
this.onPressed,
|
|
this.isLoading = false,
|
|
this.fullWidth = false,
|
|
}) : isBuy = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final gradient = isBuy ? AppColorScheme.buyGradient : AppColorScheme.sellGradient;
|
|
final text = isBuy
|
|
? '买入${coinCode != null ? ' $coinCode' : ''}'
|
|
: '卖出${coinCode != null ? ' $coinCode' : ''}';
|
|
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 交易按钮组 - 同时显示买入和卖出按钮
|
|
class TradeButtonGroup extends StatelessWidget {
|
|
final String? coinCode;
|
|
final VoidCallback? onBuyPressed;
|
|
final VoidCallback? onSellPressed;
|
|
final bool isBuyLoading;
|
|
final bool isSellLoading;
|
|
|
|
const TradeButtonGroup({
|
|
super.key,
|
|
this.coinCode,
|
|
this.onBuyPressed,
|
|
this.onSellPressed,
|
|
this.isBuyLoading = false,
|
|
this.isSellLoading = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
children: [
|
|
Expanded(
|
|
child: TradeButton.buy(
|
|
coinCode: coinCode,
|
|
onPressed: onBuyPressed,
|
|
isLoading: isBuyLoading,
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.sm),
|
|
Expanded(
|
|
child: TradeButton.sell(
|
|
coinCode: coinCode,
|
|
onPressed: onSellPressed,
|
|
isLoading: isSellLoading,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|