2026-04-05 22:38:56 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import '../../../../core/theme/app_color_scheme.dart';
|
|
|
|
|
|
import '../../../../core/theme/app_spacing.dart';
|
2026-04-05 23:37:27 +08:00
|
|
|
|
import '../../../../core/theme/app_theme.dart';
|
2026-04-05 22:38:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// 交易按钮组件
|
|
|
|
|
|
///
|
|
|
|
|
|
/// CTA 买入/卖出按钮。profit-green底 / sell-red底,圆角lg,高48,白字16px bold。
|
|
|
|
|
|
class TradeButton extends StatelessWidget {
|
|
|
|
|
|
final bool isBuy;
|
|
|
|
|
|
final String? coinCode;
|
|
|
|
|
|
final bool enabled;
|
|
|
|
|
|
final bool isLoading;
|
|
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
|
|
|
|
|
|
|
|
const TradeButton({
|
|
|
|
|
|
super.key,
|
|
|
|
|
|
required this.isBuy,
|
|
|
|
|
|
required this.coinCode,
|
|
|
|
|
|
required this.enabled,
|
|
|
|
|
|
required this.isLoading,
|
|
|
|
|
|
required this.onPressed,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
|
final fillColor =
|
|
|
|
|
|
isBuy ? AppColorScheme.buyButtonFill : AppColorScheme.sellButtonFill;
|
|
|
|
|
|
|
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
onTap: enabled ? onPressed : null,
|
|
|
|
|
|
child: AnimatedContainer(
|
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
|
height: 48,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: enabled ? fillColor : colorScheme.onSurface.withOpacity(0.08),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Center(
|
|
|
|
|
|
child: isLoading
|
|
|
|
|
|
? const SizedBox(
|
|
|
|
|
|
width: 20,
|
|
|
|
|
|
height: 20,
|
|
|
|
|
|
child: CircularProgressIndicator(
|
|
|
|
|
|
strokeWidth: 2,
|
2026-04-05 23:37:27 +08:00
|
|
|
|
color: AppColorScheme.darkOnPrimary,
|
2026-04-05 22:38:56 +08:00
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
: Text(
|
|
|
|
|
|
'${isBuy ? '买入' : '卖出'} ${coinCode ?? ""}',
|
2026-04-05 23:37:27 +08:00
|
|
|
|
style: AppTextStyles.headlineLarge(context).copyWith(
|
2026-04-05 22:38:56 +08:00
|
|
|
|
color: enabled
|
2026-04-05 23:37:27 +08:00
|
|
|
|
? AppColorScheme.darkOnPrimary
|
2026-04-05 22:38:56 +08:00
|
|
|
|
: colorScheme.onSurface.withOpacity(0.3),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|