From 830d99a5047f869751a95d9bbe594bf1d92b4797 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 29 Jan 2026 22:10:47 -0800 Subject: [PATCH] =?UTF-8?q?feat(mining-app):=20=E5=88=86=E7=A6=BB=E5=8F=91?= =?UTF-8?q?=E9=80=81/=E6=8E=A5=E6=94=B6=E8=AE=B0=E5=BD=95=20+=20=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E4=B9=B0=E5=85=A5=E5=BE=85=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 发送页右上角"转出记录"只显示转出明细 - 接收页右上角新增"接收记录"只显示转入明细 - P2pTransferRecordsPage 支持 filterDirection 参数过滤方向 - 兑换页隐藏"买入待开启" Tab(_showBuyTab=false,保留代码备启用) Co-Authored-By: Claude Opus 4.5 --- .../lib/core/router/app_router.dart | 4 +- .../asset/p2p_transfer_records_page.dart | 49 +++++- .../pages/asset/receive_shares_page.dart | 15 ++ .../pages/asset/send_shares_page.dart | 6 +- .../pages/trading/trading_page.dart | 148 +++++++++--------- 5 files changed, 140 insertions(+), 82 deletions(-) diff --git a/frontend/mining-app/lib/core/router/app_router.dart b/frontend/mining-app/lib/core/router/app_router.dart index 0a5956b5..9ba37902 100644 --- a/frontend/mining-app/lib/core/router/app_router.dart +++ b/frontend/mining-app/lib/core/router/app_router.dart @@ -170,7 +170,9 @@ final appRouterProvider = Provider((ref) { ), GoRoute( path: Routes.p2pTransferRecords, - builder: (context, state) => const P2pTransferRecordsPage(), + builder: (context, state) => P2pTransferRecordsPage( + filterDirection: state.uri.queryParameters['filter'], + ), ), GoRoute( path: Routes.helpCenter, diff --git a/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart b/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart index b91b8480..83f42072 100644 --- a/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart +++ b/frontend/mining-app/lib/presentation/pages/asset/p2p_transfer_records_page.dart @@ -8,8 +8,11 @@ import '../../providers/transfer_providers.dart'; import '../../providers/user_providers.dart'; /// P2P转账记录页面 +/// [filterDirection] - 过滤方向: 'send' 只显示转出, 'receive' 只显示转入, null 显示全部 class P2pTransferRecordsPage extends ConsumerWidget { - const P2pTransferRecordsPage({super.key}); + final String? filterDirection; + + const P2pTransferRecordsPage({super.key, this.filterDirection}); static const Color _orange = Color(0xFFFF6B00); static const Color _green = Color(0xFF10B981); @@ -18,6 +21,28 @@ class P2pTransferRecordsPage extends ConsumerWidget { static const Color _darkText = Color(0xFF1F2937); static const Color _bgGray = Color(0xFFF3F4F6); + String get _title { + switch (filterDirection) { + case 'send': + return '转出记录'; + case 'receive': + return '转入记录'; + default: + return '转账记录'; + } + } + + String get _emptyText { + switch (filterDirection) { + case 'send': + return '暂无转出记录'; + case 'receive': + return '暂无转入记录'; + default: + return '暂无转账记录'; + } + } + @override Widget build(BuildContext context, WidgetRef ref) { final user = ref.watch(userNotifierProvider); @@ -27,9 +52,9 @@ class P2pTransferRecordsPage extends ConsumerWidget { return Scaffold( backgroundColor: _bgGray, appBar: AppBar( - title: const Text( - '转账记录', - style: TextStyle( + title: Text( + _title, + style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: _darkText, @@ -64,7 +89,15 @@ class P2pTransferRecordsPage extends ConsumerWidget { ], ), ), - data: (records) { + data: (allRecords) { + // 按方向过滤 + final records = filterDirection == null + ? allRecords + : allRecords.where((r) { + final isSend = r.fromAccountSequence == accountSequence; + return filterDirection == 'send' ? isSend : !isSend; + }).toList(); + if (records.isEmpty) { return Center( child: Column( @@ -76,9 +109,9 @@ class P2pTransferRecordsPage extends ConsumerWidget { color: _grayText.withOpacity(0.5), ), const SizedBox(height: 16), - const Text( - '暂无转账记录', - style: TextStyle( + Text( + _emptyText, + style: const TextStyle( fontSize: 16, color: _grayText, ), diff --git a/frontend/mining-app/lib/presentation/pages/asset/receive_shares_page.dart b/frontend/mining-app/lib/presentation/pages/asset/receive_shares_page.dart index 338d5bed..23678415 100644 --- a/frontend/mining-app/lib/presentation/pages/asset/receive_shares_page.dart +++ b/frontend/mining-app/lib/presentation/pages/asset/receive_shares_page.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:qr_flutter/qr_flutter.dart'; +import '../../../core/router/routes.dart'; import '../../providers/user_providers.dart'; class ReceiveSharesPage extends ConsumerWidget { @@ -38,6 +39,20 @@ class ReceiveSharesPage extends ConsumerWidget { ), ), centerTitle: true, + actions: [ + TextButton( + onPressed: () => context.push( + '${Routes.p2pTransferRecords}?filter=receive', + ), + child: const Text( + '接收记录', + style: TextStyle( + fontSize: 14, + color: _orange, + ), + ), + ), + ], ), body: SingleChildScrollView( child: Column( diff --git a/frontend/mining-app/lib/presentation/pages/asset/send_shares_page.dart b/frontend/mining-app/lib/presentation/pages/asset/send_shares_page.dart index 033be0f3..0a8f83f9 100644 --- a/frontend/mining-app/lib/presentation/pages/asset/send_shares_page.dart +++ b/frontend/mining-app/lib/presentation/pages/asset/send_shares_page.dart @@ -68,9 +68,11 @@ class _SendSharesPageState extends ConsumerState { centerTitle: true, actions: [ TextButton( - onPressed: () => context.push(Routes.p2pTransferRecords), + onPressed: () => context.push( + '${Routes.p2pTransferRecords}?filter=send', + ), child: const Text( - '转账记录', + '转出记录', style: TextStyle( fontSize: 14, color: _orange, diff --git a/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart b/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart index 573e7ae5..cb30d06b 100644 --- a/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart +++ b/frontend/mining-app/lib/presentation/pages/trading/trading_page.dart @@ -29,6 +29,9 @@ class _TradingPageState extends ConsumerState { static const Color _green = AppColors.up; static const Color _red = AppColors.down; + // 买入功能暂时隐藏,未来启用时改为 true + static const bool _showBuyTab = false; + // 状态 int _selectedTab = 1; // 0: 买入, 1: 卖出 int _selectedTimeRange = 4; // 时间周期选择,默认1时 @@ -412,7 +415,7 @@ class _TradingPageState extends ConsumerState { } // 如果选中买入但买入功能未开启,强制切换到卖出 - if (_selectedTab == 0 && !buyEnabled) { + if (_showBuyTab && _selectedTab == 0 && !buyEnabled) { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted && _selectedTab == 0) { setState(() => _selectedTab = 1); @@ -432,92 +435,95 @@ class _TradingPageState extends ConsumerState { ), child: Column( children: [ - Container( - decoration: BoxDecoration( - border: Border(bottom: BorderSide(color: bgGray)), - ), - child: Row( - children: [ - Expanded( - child: GestureDetector( - onTap: buyEnabled ? () => setState(() => _selectedTab = 0) : null, - child: Container( - padding: const EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: _selectedTab == 0 && buyEnabled ? _orange : Colors.transparent, - width: 2, - ), - ), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '买入', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: buyEnabled - ? (_selectedTab == 0 ? _orange : grayText) - : grayText.withValues(alpha: 0.5), + // 买入/卖出 Tab 切换(买入功能隐藏时不显示 Tab 栏) + if (_showBuyTab) ...[ + Container( + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: bgGray)), + ), + child: Row( + children: [ + Expanded( + child: GestureDetector( + onTap: buyEnabled ? () => setState(() => _selectedTab = 0) : null, + child: Container( + padding: const EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: _selectedTab == 0 && buyEnabled ? _orange : Colors.transparent, + width: 2, ), ), - if (!buyEnabled) ...[ - const SizedBox(width: 4), - Container( - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1), - decoration: BoxDecoration( - color: grayText.withValues(alpha: 0.1), - borderRadius: BorderRadius.circular(4), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '买入', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: buyEnabled + ? (_selectedTab == 0 ? _orange : grayText) + : grayText.withValues(alpha: 0.5), ), - child: Text( - '待开启', - style: TextStyle( - fontSize: 10, - color: grayText.withValues(alpha: 0.7), + ), + if (!buyEnabled) ...[ + const SizedBox(width: 4), + Container( + padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1), + decoration: BoxDecoration( + color: grayText.withValues(alpha: 0.1), + borderRadius: BorderRadius.circular(4), + ), + child: Text( + '待开启', + style: TextStyle( + fontSize: 10, + color: grayText.withValues(alpha: 0.7), + ), ), ), - ), + ], ], - ], + ), ), ), ), - ), - Expanded( - child: GestureDetector( - onTap: () => setState(() => _selectedTab = 1), - child: Container( - padding: const EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: _selectedTab == 1 ? _orange : Colors.transparent, - width: 2, + Expanded( + child: GestureDetector( + onTap: () => setState(() => _selectedTab = 1), + child: Container( + padding: const EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: _selectedTab == 1 ? _orange : Colors.transparent, + width: 2, + ), + ), + ), + child: Text( + '卖出', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + color: _selectedTab == 1 ? _orange : grayText, ), ), ), - child: Text( - '卖出', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - color: _selectedTab == 1 ? _orange : grayText, - ), - ), ), ), - ), - ], + ], + ), ), - ), - const SizedBox(height: 24), + const SizedBox(height: 24), + ], // 买入功能未开启时显示提示 - if (_selectedTab == 0 && !buyEnabled) ...[ + if (_showBuyTab && _selectedTab == 0 && !buyEnabled) ...[ Container( padding: const EdgeInsets.all(24), child: Column(