feat(mining-app): 分离发送/接收记录 + 隐藏买入待开启

- 发送页右上角"转出记录"只显示转出明细
- 接收页右上角新增"接收记录"只显示转入明细
- P2pTransferRecordsPage 支持 filterDirection 参数过滤方向
- 兑换页隐藏"买入待开启" Tab(_showBuyTab=false,保留代码备启用)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-29 22:10:47 -08:00
parent 99dbce2053
commit 830d99a504
5 changed files with 140 additions and 82 deletions

View File

@ -170,7 +170,9 @@ final appRouterProvider = Provider<GoRouter>((ref) {
),
GoRoute(
path: Routes.p2pTransferRecords,
builder: (context, state) => const P2pTransferRecordsPage(),
builder: (context, state) => P2pTransferRecordsPage(
filterDirection: state.uri.queryParameters['filter'],
),
),
GoRoute(
path: Routes.helpCenter,

View File

@ -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,
),

View File

@ -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(

View File

@ -68,9 +68,11 @@ class _SendSharesPageState extends ConsumerState<SendSharesPage> {
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,

View File

@ -29,6 +29,9 @@ class _TradingPageState extends ConsumerState<TradingPage> {
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<TradingPage> {
}
//
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<TradingPage> {
),
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(