111
This commit is contained in:
@@ -6,6 +6,7 @@ import '../../../core/theme/app_spacing.dart';
|
||||
import '../../../core/theme/app_theme.dart';
|
||||
import '../../../core/theme/app_theme_extension.dart';
|
||||
import '../../../providers/asset_provider.dart';
|
||||
import '../../../data/models/order_models.dart';
|
||||
import 'fund_orders_list.dart';
|
||||
|
||||
/// 訂單管理頁面
|
||||
@@ -29,7 +30,9 @@ class _OrdersPageState extends State<OrdersPage> with AutomaticKeepAliveClientMi
|
||||
}
|
||||
|
||||
void _loadData() {
|
||||
context.read<AssetProvider>().refreshAll();
|
||||
final provider = context.read<AssetProvider>();
|
||||
provider.refreshAll();
|
||||
provider.loadTradeOrders();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -138,16 +141,151 @@ class TradeOrdersList extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final orders = provider.tradeOrders;
|
||||
|
||||
return Center(
|
||||
if (orders.isEmpty) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(AppSpacing.xl),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(LucideIcons.receipt, size: 48, color: theme.colorScheme.onSurfaceVariant),
|
||||
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
||||
Text('暫無交易記錄', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () => provider.loadTradeOrders(),
|
||||
color: theme.colorScheme.primary,
|
||||
child: ListView.separated(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
padding: AppSpacing.pagePadding,
|
||||
itemCount: orders.length,
|
||||
separatorBuilder: (_, __) => Divider(color: theme.colorScheme.outline, height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final order = orders[index];
|
||||
return _TradeOrderCard(order: order);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TradeOrderCard extends StatelessWidget {
|
||||
final OrderTrade order;
|
||||
|
||||
const _TradeOrderCard({required this.order});
|
||||
|
||||
Color _directionColor() => order.isBuy ? AppColorScheme.up : AppColorScheme.down;
|
||||
|
||||
Color _statusColor() {
|
||||
switch (order.status) {
|
||||
case 0: return AppColorScheme.warning;
|
||||
case 1: return AppColorScheme.success;
|
||||
case 2: return AppColorScheme.error;
|
||||
case 3: return AppColorScheme.muted;
|
||||
default: return AppColorScheme.muted;
|
||||
}
|
||||
}
|
||||
|
||||
String _formatTime(DateTime? time) {
|
||||
if (time == null) return '';
|
||||
return '${time.year}-${time.month.toString().padLeft(2, '0')}-${time.day.toString().padLeft(2, '0')} '
|
||||
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final dirColor = _directionColor();
|
||||
final statusColor = _statusColor();
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(AppSpacing.xl),
|
||||
padding: AppSpacing.cardPadding,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(LucideIcons.receipt, size: 48, color: theme.colorScheme.onSurfaceVariant),
|
||||
SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
||||
Text('暫無交易記錄', style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: dirColor.withValues(alpha: 0.1),
|
||||
borderRadius: AppRadius.radiusSm,
|
||||
),
|
||||
child: Text(
|
||||
order.directionText,
|
||||
style: AppTextStyles.labelMedium(context).copyWith(color: dirColor, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
order.coinCode,
|
||||
style: AppTextStyles.headlineMedium(context),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
if (order.orderType != null)
|
||||
Text(
|
||||
order.orderTypeText,
|
||||
style: AppTextStyles.bodySmall(context).copyWith(color: theme.colorScheme.onSurfaceVariant),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: statusColor.withValues(alpha: 0.1),
|
||||
borderRadius: AppRadius.radiusSm,
|
||||
),
|
||||
child: Text(
|
||||
order.statusText,
|
||||
style: AppTextStyles.labelMedium(context).copyWith(color: statusColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('價格', style: AppTextStyles.bodySmall(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
Text('${order.price} USDT', style: AppTextStyles.numberSmall(context)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('數量', style: AppTextStyles.bodySmall(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
Text(order.quantity, style: AppTextStyles.numberSmall(context)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('金額', style: AppTextStyles.bodySmall(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
Text('${order.amount} USDT', style: AppTextStyles.numberSmall(context).copyWith(fontWeight: FontWeight.w600)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text('時間', style: AppTextStyles.bodySmall(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
Text(_formatTime(order.createTime), style: AppTextStyles.bodySmall(context).copyWith(color: theme.colorScheme.onSurfaceVariant)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user