This commit is contained in:
sion
2026-04-07 01:05:05 +08:00
parent edad10ff06
commit 5ca1274607
83 changed files with 1561 additions and 1241 deletions

View File

@@ -9,7 +9,7 @@ import '../../../data/models/account_models.dart';
import '../../../data/services/bonus_service.dart';
import '../../../providers/asset_provider.dart';
/// 账单页面 — 代币盈亏账单 + 新人福利账单 + 推广福利账单
/// 賬單頁面 — 代幣盈虧賬單 + 新人福利賬單 + 推福利賬單
class BillsPage extends StatefulWidget {
const BillsPage({super.key});
@@ -42,7 +42,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
final provider = context.read<AssetProvider>();
final bonusService = context.read<BonusService>();
// 行加载持仓和福利记录
// 行加載持倉和福利記錄
await provider.loadTradeAccount(force: true);
final welfareResponse = await bonusService.getWelfareStatus();
@@ -73,7 +73,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
if (newUser != null) {
final claimed = newUser['claimed'] as bool? ?? false;
final eligible = newUser['eligible'] as bool? ?? false;
// 状态: 1=已取, 0=可取(待取), 2=不可用(未解)
// 狀態: 1=已取, 0=可取(待取), 2=不可用(未解)
final int status;
if (claimed) {
status = 1;
@@ -91,15 +91,15 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
});
}
// 推广福利列表
// 推福利列表
final referralRewards = data['referralRewards'] as List<dynamic>? ?? [];
for (var r in referralRewards) {
final map = r as Map<String, dynamic>;
final username = map['username'] as String? ?? '';
final username = map['username'] as String? ?? '';
final milestones = map['milestones'] as List<dynamic>? ?? [];
final claimableCount = map['claimableCount'] as int? ?? 0;
// 每 milestone 生成一条记录
// 每 milestone 生成一條記錄
for (var m in milestones) {
final ms = m as Map<String, dynamic>;
final earned = ms['earned'] as bool? ?? false;
@@ -108,26 +108,26 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
final int status;
if (earned) {
status = 1; // 已
status = 1; // 已
} else if (claimable) {
status = 0; // 可
status = 0; // 可
} else {
status = 2; // 未达标
status = 2; // 未達標
}
records.add({
'type': 'referral',
'title': '广福利 - $username (${milestoneVal}000)',
'title': '福利 - $username (${milestoneVal}000)',
'amount': '100.00',
'status': status,
'time': ms['claimTime'] ?? ms['createTime'],
});
}
// 如果有 milestone 但有 claimableCount也生成记录
// 如果有 milestone 但有 claimableCount也生成記錄
if (milestones.isEmpty && claimableCount > 0) {
records.add({
'type': 'referral',
'title': '广福利 - $username',
'title': '福利 - $username',
'amount': '${claimableCount * 100}',
'status': 0,
'time': null,
@@ -150,7 +150,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
icon: const Icon(LucideIcons.arrowLeft, size: 20),
onPressed: () => Navigator.of(context).pop(),
),
title: Text('我的账单', style: AppTextStyles.headlineLarge(context)),
title: Text('我的賬單', style: AppTextStyles.headlineLarge(context)),
backgroundColor: _isDark ? AppColorScheme.darkBackground : AppColorScheme.lightBackground,
elevation: 0,
scrolledUnderElevation: 0,
@@ -163,9 +163,9 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
labelStyle: AppTextStyles.headlineMedium(context).copyWith(fontWeight: FontWeight.w600),
unselectedLabelStyle: AppTextStyles.headlineMedium(context),
tabs: const [
Tab(text: '币盈亏'),
Tab(text: '幣盈虧'),
Tab(text: '新人福利'),
Tab(text: '广福利'),
Tab(text: '福利'),
],
),
),
@@ -183,16 +183,16 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
}
// ============================================
// 代币盈亏账单
// 代幣盈虧賬單
// ============================================
Widget _buildCoinProfitTab() {
final colorScheme = Theme.of(context).colorScheme;
if (_holdings.isEmpty) {
return _buildEmptyState(LucideIcons.wallet, '暂无持仓记录');
return _buildEmptyState(LucideIcons.wallet, '暫無持倉記錄');
}
// 汇总统计
// 彙總統計
double totalCost = 0;
double totalValue = 0;
double totalProfit = 0;
@@ -210,7 +210,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
child: ListView(
padding: const EdgeInsets.all(AppSpacing.md),
children: [
// 汇总卡片
// 彙總卡片
Container(
padding: const EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
@@ -224,7 +224,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
),
child: Column(
children: [
Text('总盈亏 (USDT)', style: AppTextStyles.bodyMedium(context).copyWith(
Text('總盈虧 (USDT)', style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
)),
const SizedBox(height: AppSpacing.xs),
@@ -239,9 +239,9 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildSummaryItem('成本', totalCost.toStringAsFixed(2)),
_buildSummaryItem('成本', totalCost.toStringAsFixed(2)),
Container(width: 1, height: 16, color: colorScheme.outlineVariant.withValues(alpha: 0.3)),
_buildSummaryItem('市值', totalValue.toStringAsFixed(2)),
_buildSummaryItem('市值', totalValue.toStringAsFixed(2)),
Container(width: 1, height: 16, color: colorScheme.outlineVariant.withValues(alpha: 0.3)),
_buildSummaryItem('收益率', '${profitRate >= 0 ? '+' : ''}${profitRate.toStringAsFixed(2)}%'),
],
@@ -251,7 +251,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
),
const SizedBox(height: AppSpacing.md),
// 各币种盈亏明细
// 各幣種盈虧明細
..._holdings.map((h) => _buildCoinProfitCard(h)),
],
),
@@ -296,7 +296,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
),
child: Column(
children: [
// 名 + 盈亏金额
// 名 + 盈虧金額
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -333,11 +333,11 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
],
),
const SizedBox(height: AppSpacing.sm),
// 明
// 明
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(': ${h.avgPrice}', style: AppTextStyles.bodySmall(context).copyWith(
Text(': ${h.avgPrice}', style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
)),
Text('市值: ${h.currentValue} USDT', style: AppTextStyles.bodySmall(context).copyWith(
@@ -355,7 +355,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
}
// ============================================
// 福利账单
// 福利賬單
// ============================================
Widget _buildWelfareTab(String type) {
final records = _welfareRecords.where((r) => r['type'] == type).toList();
@@ -363,7 +363,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
if (records.isEmpty) {
return _buildEmptyState(
LucideIcons.gift,
type == 'new_user' ? '暂无新人福利记录' : '暂无推广福利记录',
type == 'new_user' ? '暫無新人福利記錄' : '暫無推廣福利記錄',
);
}
@@ -382,20 +382,20 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
final amount = double.tryParse(record['amount']?.toString() ?? '0') ?? 0;
final status = record['status'] as int? ?? 0;
// status: 0=待取, 1=已取, 2=未达标
// status: 0=待取, 1=已取, 2=未達標
String statusText;
Color statusColor;
switch (status) {
case 1:
statusText = '';
statusText = '';
statusColor = context.appColors.up;
break;
case 2:
statusText = '达标';
statusText = '達標';
statusColor = colorScheme.onSurfaceVariant;
break;
default:
statusText = '';
statusText = '';
statusColor = AppColorScheme.warning;
}
@@ -463,7 +463,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
}
// ============================================
// 通用
// 通用
// ============================================
Widget _buildEmptyState(IconData icon, String text) {
final colorScheme = Theme.of(context).colorScheme;

View File

@@ -6,7 +6,7 @@ import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../providers/auth_provider.dart';
/// 首页顶栏 - Logo + 搜索/通知/
/// 首頁頂欄 - Logo + 搜索/通知/
class HeaderBar extends StatelessWidget {
const HeaderBar({super.key});

View File

@@ -20,7 +20,7 @@ import 'hot_coins_section.dart';
import 'profit_analysis_page.dart';
import 'bills_page.dart';
/// 首
/// 首
class HomePage extends StatefulWidget {
const HomePage({super.key});
@@ -105,13 +105,13 @@ class _HomePageState extends State<HomePage>
// Header
HeaderBar(),
SizedBox(height: AppSpacing.md),
// 资产卡片(含估盈
// 資產卡片(含估盈
_AssetCard(
overview: provider.overview,
onDeposit: _showDeposit,
),
SizedBox(height: AppSpacing.md),
// 快捷操作
// 快捷操作
QuickActionsRow(
onDeposit: _showDeposit,
onWithdraw: _showWithdraw,
@@ -129,10 +129,10 @@ class _HomePageState extends State<HomePage>
),
),
SizedBox(height: AppSpacing.lg),
// 热门币种
// 熱門幣種
HotCoinsSection(),
SizedBox(height: AppSpacing.lg),
// 持
// 持
_HoldingsSection(holdings: provider.holdings),
],
),
@@ -174,7 +174,7 @@ class _HomePageState extends State<HomePage>
}
}
/// 资产卡片(含估盈
/// 資產卡片(含估盈
class _AssetCard extends StatefulWidget {
final AssetOverview? overview;
final VoidCallback onDeposit;
@@ -197,7 +197,7 @@ class _AssetCardState extends State<_AssetCard> {
@override
void didUpdateWidget(covariant _AssetCard oldWidget) {
super.didUpdateWidget(oldWidget);
// overview 更新重新加载盈亏数据
// overview 更新重新加載盈虧數據
if (widget.overview != oldWidget.overview) {
_loadProfit();
}
@@ -239,7 +239,7 @@ class _AssetCardState extends State<_AssetCard> {
final upColor = context.appColors.up;
final downColor = context.appColors.down;
// 总资产
// 總資產
final totalAsset = widget.overview?.totalAsset ?? '0.00';
final displayAsset = _formatAsset(totalAsset);
@@ -249,12 +249,12 @@ class _AssetCardState extends State<_AssetCard> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 部行:总资产标签 + 充值按
// 部行:總資產標籤 + 充值按
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'预估总资产(USDT)',
'預估總資產(USDT)',
style: AppTextStyles.bodyLarge(context),
),
GestureDetector(
@@ -284,7 +284,7 @@ class _AssetCardState extends State<_AssetCard> {
),
SizedBox(height: AppSpacing.sm),
// 总资产金额
// 總資產金額
Text(
displayAsset,
style: AppTextStyles.displayLarge(context).copyWith(
@@ -293,13 +293,13 @@ class _AssetCardState extends State<_AssetCard> {
),
SizedBox(height: AppSpacing.md),
// 盈亏统计区:预估今日盈 | 预估总盈亏
// 盈虧統計區:預估今日盈 | 預估總盈虧
Row(
children: [
// 估今日盈
// 估今日盈
Expanded(
child: _ProfitStatCard(
label: '估今日盈',
label: '估今日盈',
value: _todayProfit,
upColor: upColor,
downColor: downColor,
@@ -310,10 +310,10 @@ class _AssetCardState extends State<_AssetCard> {
),
),
SizedBox(width: AppSpacing.sm),
// 预估总盈亏
// 預估總盈虧
Expanded(
child: _ProfitStatCard(
label: '预估总盈亏',
label: '預估總盈虧',
value: _totalProfit,
upColor: upColor,
downColor: downColor,
@@ -357,7 +357,7 @@ class _WelfareCard extends StatelessWidget {
),
child: Row(
children: [
// 左侧图标
// 左側圖標
Container(
width: 48,
height: 48,
@@ -372,7 +372,7 @@ class _WelfareCard extends StatelessWidget {
),
),
SizedBox(width: AppSpacing.md),
// 中文字
// 中文字
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -386,14 +386,14 @@ class _WelfareCard extends StatelessWidget {
SizedBox(height: AppSpacing.xs),
Text(
totalClaimable > 0
? '您有 $totalClaimable 个奖励待领'
: '首充奖励 + 推广奖励',
? '您有 $totalClaimable 個獎勵待領'
: '首充獎勵 + 推廣獎勵',
style: AppTextStyles.bodyMedium(context),
),
],
),
),
// 右侧按钮
// 右側按鈕
Container(
padding: EdgeInsets.symmetric(
horizontal: AppSpacing.md,
@@ -440,7 +440,7 @@ class _WelfareCard extends StatelessWidget {
}
}
/// 持部分
/// 持部分
class _HoldingsSection extends StatelessWidget {
final List<AccountTrade> holdings;
@@ -454,7 +454,7 @@ class _HoldingsSection extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'我的持',
'我的持',
style: AppTextStyles.headlineLarge(context).copyWith(
fontWeight: FontWeight.bold,
),
@@ -467,7 +467,7 @@ class _HoldingsSection extends StatelessWidget {
),
child: Row(
children: [
Text('资产详',
Text('資產詳',
style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.bold,
)),
@@ -486,7 +486,7 @@ class _HoldingsSection extends StatelessWidget {
}
}
/// 空持
/// 空持
class _EmptyHoldings extends StatelessWidget {
const _EmptyHoldings();
@@ -505,7 +505,7 @@ class _EmptyHoldings extends StatelessWidget {
Icon(LucideIcons.wallet, size: 48, color: context.colors.onSurfaceVariant),
SizedBox(height: AppSpacing.md),
Text(
'暂无持仓',
'暫無持倉',
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.w600,
),
@@ -521,7 +521,7 @@ class _EmptyHoldings extends StatelessWidget {
}
}
/// 持列表
/// 持列表
class _HoldingsList extends StatelessWidget {
final List<AccountTrade> holdings;
@@ -554,7 +554,7 @@ class _HoldingsList extends StatelessWidget {
}
}
/// 持仓项
/// 持倉項
class _HoldingItem extends StatelessWidget {
final AccountTrade holding;
@@ -615,7 +615,7 @@ class _HoldingItem extends StatelessWidget {
}
}
/// 盈亏统计小卡片
/// 盈虧統計小卡片
class _ProfitStatCard extends StatelessWidget {
final String label;
final double value;

View File

@@ -4,7 +4,7 @@ import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme_extension.dart';
/// 首页热门币种区块
/// 首頁熱門幣種區塊
class HotCoinsSection extends StatelessWidget {
const HotCoinsSection({super.key});
@@ -19,7 +19,7 @@ class HotCoinsSection extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'热门币种',
'熱門幣種',
style: AppTextStyles.headlineLarge(context),
),
Text(

View File

@@ -6,7 +6,7 @@ import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme_extension.dart';
import '../../../data/services/asset_service.dart';
/// 盈分析面 - 月度盈亏日历
/// 盈分析面 - 月度盈虧日曆
class ProfitAnalysisPage extends StatefulWidget {
const ProfitAnalysisPage({super.key});
@@ -27,7 +27,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
}
// ============================================
// 数据加载
// 數據加載
// ============================================
Future<void> _loadProfit() async {
@@ -64,7 +64,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
}
// ============================================
// 盈亏数据解析
// 盈虧數據解析
// ============================================
double? _getDayProfit(int day) {
@@ -86,7 +86,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
}
// ============================================
// 建 UI
// 建 UI
// ============================================
@override
@@ -98,7 +98,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
return Scaffold(
backgroundColor: context.colors.surface,
appBar: AppBar(
title: const Text('分析'),
title: const Text('分析'),
backgroundColor: context.colors.surface,
elevation: 0,
scrolledUnderElevation: 0,
@@ -116,19 +116,19 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// 月度盈摘要
// 月度盈摘要
_buildSummarySection(),
SizedBox(height: AppSpacing.md),
// 月份
// 月份
_buildMonthNavigation(isCurrentMonth),
SizedBox(height: AppSpacing.sm),
// 星期标题
// 星期標題
_buildWeekdayHeaders(),
SizedBox(height: AppSpacing.xs),
// 日历网
// 日曆網
if (_isLoading)
_buildLoadingIndicator()
else
@@ -143,7 +143,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
);
}
/// 月度盈摘要
/// 月度盈摘要
Widget _buildSummarySection() {
final upColor = context.appColors.up;
final downColor = context.appColors.down;
@@ -153,7 +153,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
return Column(
children: [
Text(
'月度盈',
'月度盈',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
),
@@ -172,7 +172,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
);
}
/// 月份航行
/// 月份航行
Widget _buildMonthNavigation(bool isCurrentMonth) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -193,14 +193,14 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
),
),
),
// 前年月
// 前年月
Text(
'${_currentMonth.year}${_currentMonth.month}',
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.bold,
),
),
// 下一月(前月禁用)
// 下一月(前月禁用)
GestureDetector(
onTap: isCurrentMonth ? null : _nextMonth,
child: Container(
@@ -224,7 +224,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
);
}
/// 星期标题
/// 星期標題
Widget _buildWeekdayHeaders() {
return Row(
children: ['', '', '', '', '', '', ''].map((d) {
@@ -243,7 +243,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
);
}
/// 加指示器
/// 加指示器
Widget _buildLoadingIndicator() {
return Padding(
padding: EdgeInsets.symmetric(vertical: AppSpacing.xxl),
@@ -260,7 +260,7 @@ class _ProfitAnalysisPageState extends State<ProfitAnalysisPage> {
);
}
/// 日历网
/// 日曆網
List<Widget> _buildCalendarGrid(
DateTime now,
bool isCurrentMonth,

View File

@@ -3,7 +3,7 @@ import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_spacing.dart';
/// 首快捷操作 - 充值/提现/划转/盈亏/账单
/// 首快捷操作 - 充值/提現/劃轉/盈虧/賬單
class QuickActionsRow extends StatelessWidget {
const QuickActionsRow({
super.key,
@@ -56,25 +56,25 @@ class QuickActionsRow extends StatelessWidget {
),
_ActionItem(
icon: LucideIcons.arrowDownLeft,
label: '',
label: '',
colorScheme: colorScheme,
onTap: onWithdraw,
),
_ActionItem(
icon: LucideIcons.repeat,
label: '划转',
label: '劃轉',
colorScheme: colorScheme,
onTap: onTransfer,
),
_ActionItem(
icon: LucideIcons.chartPie,
label: '',
label: '',
colorScheme: colorScheme,
onTap: onProfit,
),
_ActionItem(
icon: LucideIcons.fileText,
label: '账单',
label: '賬單',
colorScheme: colorScheme,
onTap: onBills,
),
@@ -105,7 +105,7 @@ class _ActionItem extends StatelessWidget {
? const Color(0xFF1E293B)
: const Color(0xFFF3F4F6);
// Light: #4B5563, Dark: 根据主题
// Light: #4B5563, Dark: 根據主題
final iconColor = isDark
? colorScheme.onSurfaceVariant
: const Color(0xFF4B5563);