Files
monisuo/flutter_monisuo/lib/ui/pages/trade/components/confirm_dialog.dart
sion123 7ed2435a4c refactor(theme): 迁移主题感知颜色至 ThemeExtension
- 创建 AppThemeColors ThemeExtension 类,统一管理主题感知颜色(涨跌色、卡片背景、渐变等)
- 从 AppColorScheme 移除主题感知辅助函数,仅保留静态颜色常量
- 在 AppTheme 中注册 ThemeExtension,支持深色/浅色主题工厂
- 重构所有 UI 组件使用 context.appColors 访问主题颜色,替代硬编码的 AppColorScheme 方法调用
- 移除组件中重复的 isDark 判断逻辑,简化颜色获取方式
- 保持向后兼容性,所有现有功能不变
2026-04-06 01:58:08 +08:00

106 lines
3.4 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 '../../../components/glass_panel.dart';
import '../../../components/neon_glow.dart';
/// 交易确认对话框
///
/// 显示交易详情(交易对、委托价格、交易金额、交易数量),
/// 用户确认后执行交易。
class ConfirmDialog extends StatelessWidget {
final bool isBuy;
final String coinCode;
final String price;
final String quantity;
final String amount;
const ConfirmDialog({
super.key,
required this.isBuy,
required this.coinCode,
required this.price,
required this.quantity,
required this.amount,
});
@override
Widget build(BuildContext context) {
final actionColor = isBuy
? context.appColors.up
: context.appColors.down;
return Dialog(
backgroundColor: const Color(0x00000000),
child: GlassPanel(
borderRadius: BorderRadius.circular(AppRadius.lg),
padding: EdgeInsets.all(AppSpacing.lg),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Text(
'确认${isBuy ? '买入' : '卖出'}',
style: AppTextStyles.headlineLarge(context),
),
),
SizedBox(height: AppSpacing.lg),
_dialogRow(context, '交易对', '$coinCode/USDT'),
SizedBox(height: AppSpacing.sm),
_dialogRow(context, '委托价格', '$price USDT'),
SizedBox(height: AppSpacing.sm),
_dialogRow(context, '交易金额', '$amount USDT',
valueColor: actionColor),
SizedBox(height: AppSpacing.sm),
_dialogRow(context, '交易数量', '$quantity $coinCode'),
SizedBox(height: AppSpacing.lg),
Row(
children: [
Expanded(
child: NeonButton(
text: '取消',
type: NeonButtonType.outline,
onPressed: () => Navigator.of(context).pop(false),
height: 44,
showGlow: false,
),
),
SizedBox(width: AppSpacing.sm),
Expanded(
child: NeonButton(
text: '确认${isBuy ? '买入' : '卖出'}',
type: isBuy ? NeonButtonType.tertiary : NeonButtonType.error,
onPressed: () => Navigator.of(context).pop(true),
height: 44,
showGlow: true,
),
),
],
),
],
),
),
);
}
Widget _dialogRow(BuildContext context, String label, String value,
{Color? valueColor}) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(label,
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.w400,
color: context.colors.onSurfaceVariant,
)),
Text(value,
style: AppTextStyles.numberMedium(context).copyWith(
color: valueColor ?? context.colors.onSurface,
)),
],
);
}
}