- 所有 AlertDialog 替换为 ModernDialog - ConfirmDialog/AssetDialogs 去掉 GlassPanel,统一 surfaceContainer 背景 - 按钮统一 FilledButton + TextButton - 修复 import 路径
109 lines
3.5 KiB
Dart
109 lines
3.5 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';
|
|
|
|
/// 交易確認對話框
|
|
///
|
|
/// 顯示交易詳情(交易對、委託價格、交易金額、交易數量),
|
|
/// 用戶確認後執行交易。
|
|
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 theme = Theme.of(context);
|
|
final actionColor = isBuy
|
|
? context.appColors.up
|
|
: context.appColors.down;
|
|
|
|
return Dialog(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(AppRadius.xl),
|
|
),
|
|
backgroundColor: theme.colorScheme.surfaceContainer,
|
|
child: Container(
|
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
|
constraints: const BoxConstraints(maxWidth: 400),
|
|
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: TextButton(
|
|
onPressed: () => Navigator.of(context).pop(false),
|
|
style: TextButton.styleFrom(
|
|
minimumSize: const Size.fromHeight(44),
|
|
),
|
|
child: const Text('取消'),
|
|
),
|
|
),
|
|
SizedBox(width: AppSpacing.sm),
|
|
Expanded(
|
|
child: FilledButton(
|
|
onPressed: () => Navigator.of(context).pop(true),
|
|
style: FilledButton.styleFrom(
|
|
backgroundColor: actionColor,
|
|
minimumSize: const Size.fromHeight(44),
|
|
),
|
|
child: Text('確認${isBuy ? '買入' : '賣出'}'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
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,
|
|
)),
|
|
],
|
|
);
|
|
}
|
|
}
|