feat(mining-app): 分离发送/接收记录 + 隐藏买入待开启
- 发送页右上角"转出记录"只显示转出明细 - 接收页右上角新增"接收记录"只显示转入明细 - P2pTransferRecordsPage 支持 filterDirection 参数过滤方向 - 兑换页隐藏"买入待开启" Tab(_showBuyTab=false,保留代码备启用) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
99dbce2053
commit
830d99a504
|
|
@ -170,7 +170,9 @@ final appRouterProvider = Provider<GoRouter>((ref) {
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: Routes.p2pTransferRecords,
|
path: Routes.p2pTransferRecords,
|
||||||
builder: (context, state) => const P2pTransferRecordsPage(),
|
builder: (context, state) => P2pTransferRecordsPage(
|
||||||
|
filterDirection: state.uri.queryParameters['filter'],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: Routes.helpCenter,
|
path: Routes.helpCenter,
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,11 @@ import '../../providers/transfer_providers.dart';
|
||||||
import '../../providers/user_providers.dart';
|
import '../../providers/user_providers.dart';
|
||||||
|
|
||||||
/// P2P转账记录页面
|
/// P2P转账记录页面
|
||||||
|
/// [filterDirection] - 过滤方向: 'send' 只显示转出, 'receive' 只显示转入, null 显示全部
|
||||||
class P2pTransferRecordsPage extends ConsumerWidget {
|
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 _orange = Color(0xFFFF6B00);
|
||||||
static const Color _green = Color(0xFF10B981);
|
static const Color _green = Color(0xFF10B981);
|
||||||
|
|
@ -18,6 +21,28 @@ class P2pTransferRecordsPage extends ConsumerWidget {
|
||||||
static const Color _darkText = Color(0xFF1F2937);
|
static const Color _darkText = Color(0xFF1F2937);
|
||||||
static const Color _bgGray = Color(0xFFF3F4F6);
|
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
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final user = ref.watch(userNotifierProvider);
|
final user = ref.watch(userNotifierProvider);
|
||||||
|
|
@ -27,9 +52,9 @@ class P2pTransferRecordsPage extends ConsumerWidget {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: _bgGray,
|
backgroundColor: _bgGray,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text(
|
title: Text(
|
||||||
'转账记录',
|
_title,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: _darkText,
|
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) {
|
if (records.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
@ -76,9 +109,9 @@ class P2pTransferRecordsPage extends ConsumerWidget {
|
||||||
color: _grayText.withOpacity(0.5),
|
color: _grayText.withOpacity(0.5),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
const Text(
|
Text(
|
||||||
'暂无转账记录',
|
_emptyText,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: _grayText,
|
color: _grayText,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
import '../../../core/router/routes.dart';
|
||||||
import '../../providers/user_providers.dart';
|
import '../../providers/user_providers.dart';
|
||||||
|
|
||||||
class ReceiveSharesPage extends ConsumerWidget {
|
class ReceiveSharesPage extends ConsumerWidget {
|
||||||
|
|
@ -38,6 +39,20 @@ class ReceiveSharesPage extends ConsumerWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => context.push(
|
||||||
|
'${Routes.p2pTransferRecords}?filter=receive',
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'接收记录',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: _orange,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,11 @@ class _SendSharesPageState extends ConsumerState<SendSharesPage> {
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => context.push(Routes.p2pTransferRecords),
|
onPressed: () => context.push(
|
||||||
|
'${Routes.p2pTransferRecords}?filter=send',
|
||||||
|
),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
'转账记录',
|
'转出记录',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: _orange,
|
color: _orange,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ class _TradingPageState extends ConsumerState<TradingPage> {
|
||||||
static const Color _green = AppColors.up;
|
static const Color _green = AppColors.up;
|
||||||
static const Color _red = AppColors.down;
|
static const Color _red = AppColors.down;
|
||||||
|
|
||||||
|
// 买入功能暂时隐藏,未来启用时改为 true
|
||||||
|
static const bool _showBuyTab = false;
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
int _selectedTab = 1; // 0: 买入, 1: 卖出
|
int _selectedTab = 1; // 0: 买入, 1: 卖出
|
||||||
int _selectedTimeRange = 4; // 时间周期选择,默认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((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (mounted && _selectedTab == 0) {
|
if (mounted && _selectedTab == 0) {
|
||||||
setState(() => _selectedTab = 1);
|
setState(() => _selectedTab = 1);
|
||||||
|
|
@ -432,92 +435,95 @@ class _TradingPageState extends ConsumerState<TradingPage> {
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
// 买入/卖出 Tab 切换(买入功能隐藏时不显示 Tab 栏)
|
||||||
decoration: BoxDecoration(
|
if (_showBuyTab) ...[
|
||||||
border: Border(bottom: BorderSide(color: bgGray)),
|
Container(
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
child: Row(
|
border: Border(bottom: BorderSide(color: bgGray)),
|
||||||
children: [
|
),
|
||||||
Expanded(
|
child: Row(
|
||||||
child: GestureDetector(
|
children: [
|
||||||
onTap: buyEnabled ? () => setState(() => _selectedTab = 0) : null,
|
Expanded(
|
||||||
child: Container(
|
child: GestureDetector(
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
onTap: buyEnabled ? () => setState(() => _selectedTab = 0) : null,
|
||||||
decoration: BoxDecoration(
|
child: Container(
|
||||||
border: Border(
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
bottom: BorderSide(
|
decoration: BoxDecoration(
|
||||||
color: _selectedTab == 0 && buyEnabled ? _orange : Colors.transparent,
|
border: Border(
|
||||||
width: 2,
|
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),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!buyEnabled) ...[
|
),
|
||||||
const SizedBox(width: 4),
|
child: Row(
|
||||||
Container(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),
|
children: [
|
||||||
decoration: BoxDecoration(
|
Text(
|
||||||
color: grayText.withValues(alpha: 0.1),
|
'买入',
|
||||||
borderRadius: BorderRadius.circular(4),
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: buyEnabled
|
||||||
|
? (_selectedTab == 0 ? _orange : grayText)
|
||||||
|
: grayText.withValues(alpha: 0.5),
|
||||||
),
|
),
|
||||||
child: Text(
|
),
|
||||||
'待开启',
|
if (!buyEnabled) ...[
|
||||||
style: TextStyle(
|
const SizedBox(width: 4),
|
||||||
fontSize: 10,
|
Container(
|
||||||
color: grayText.withValues(alpha: 0.7),
|
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(
|
||||||
Expanded(
|
child: GestureDetector(
|
||||||
child: GestureDetector(
|
onTap: () => setState(() => _selectedTab = 1),
|
||||||
onTap: () => setState(() => _selectedTab = 1),
|
child: Container(
|
||||||
child: Container(
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
border: Border(
|
||||||
border: Border(
|
bottom: BorderSide(
|
||||||
bottom: BorderSide(
|
color: _selectedTab == 1 ? _orange : Colors.transparent,
|
||||||
color: _selectedTab == 1 ? _orange : Colors.transparent,
|
width: 2,
|
||||||
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(
|
Container(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue