fix(mobile-app): 优化数字显示组件防止自动换行

使用 FittedBox(fit: BoxFit.scaleDown) 包装所有可变数字显示组件,
确保当数字位数多时自动缩小字号而不是换行,提升用户视觉体验。

优化的页面和组件:
- stickman_race_widget: 火柴人标签、排名列表数量、进度百分比
- team_tree_widget: 节点认种数、省略节点数量、详情弹窗
- ranking_page: 龙虎榜团队认种量
- trading_page: DST余额、绿积分余额
- profile_page: 各类收益金额、奖励项金额
- withdraw_usdt_page: 提款页余额
- deposit_usdt_page: 充值页余额
- ledger_detail_page: 净收益、收支概览、流水金额
- authorization_apply_page: 累计认种数
- planting_quantity_page: 可用余额
- mining_page: 用户序列号
- account_switch_page: 账号用户名、序列号
- wallet_created_page: 钱包地址信息

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-23 18:33:51 -08:00
parent 65e9422fe5
commit 6f8eaa8e92
13 changed files with 462 additions and 290 deletions

View File

@ -273,7 +273,11 @@ class _AccountSwitchPageState extends ConsumerState<AccountSwitchPage> {
children: [
Row(
children: [
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
account.username,
style: const TextStyle(
fontSize: 16,
@ -282,6 +286,8 @@ class _AccountSwitchPageState extends ConsumerState<AccountSwitchPage> {
color: Color(0xFF5D4037),
),
),
),
),
if (isCurrent) ...[
const SizedBox(width: 8),
Container(
@ -306,7 +312,10 @@ class _AccountSwitchPageState extends ConsumerState<AccountSwitchPage> {
],
),
const SizedBox(height: 4),
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
account.userSerialNum,
style: const TextStyle(
fontSize: 12,
@ -314,6 +323,7 @@ class _AccountSwitchPageState extends ConsumerState<AccountSwitchPage> {
color: Color(0x995D4037),
),
),
),
],
),
),

View File

@ -304,6 +304,9 @@ class WalletCreatedPage extends ConsumerWidget {
const SizedBox(width: 14),
// - "标签: 值"
Expanded(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
'$label: $displayValue',
style: const TextStyle(
@ -315,6 +318,7 @@ class WalletCreatedPage extends ConsumerWidget {
),
),
),
),
//
GestureDetector(
onTap: () => _copyToClipboard(context, value, label),

View File

@ -832,7 +832,10 @@ class _AuthorizationApplyPageState
),
),
const SizedBox(height: 4),
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_hasPlanted ? '累计认种 $_plantedCount' : '请先完成认种后再申请授权',
style: const TextStyle(
fontSize: 14,
@ -840,6 +843,7 @@ class _AuthorizationApplyPageState
color: Color(0xFF745D43),
),
),
),
],
),
),

View File

@ -248,6 +248,7 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
children: [
//
Container(
constraints: const BoxConstraints(maxWidth: 60),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: data.isCurrentUser
@ -255,6 +256,8 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
: const Color(0xFF8B5A2B),
borderRadius: BorderRadius.circular(8),
),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'${_formatNumber(data.completedCount)}',
style: const TextStyle(
@ -265,6 +268,7 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
),
),
),
),
const SizedBox(height: 2),
//
@ -481,7 +485,10 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
],
),
const SizedBox(height: 2),
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
'本月收益: ${_formatCurrency(data.monthlyEarnings)} 绿积分',
style: const TextStyle(
fontSize: 11,
@ -489,15 +496,21 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
color: Color(0xFF8B5A2B),
),
),
),
],
),
),
//
Column(
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 100),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
'${_formatNumber(data.completedCount)}',
style: const TextStyle(
fontSize: 16,
@ -506,8 +519,12 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
color: Color(0xFFD4AF37),
),
),
),
const SizedBox(height: 2),
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
'${(data.progress * 100).toStringAsFixed(1)}%',
style: const TextStyle(
fontSize: 11,
@ -515,8 +532,10 @@ class _StickmanRaceWidgetState extends State<StickmanRaceWidget>
color: Color(0xFF8B5A2B),
),
),
),
],
),
),
],
),
);

View File

@ -378,6 +378,9 @@ class _DepositUsdtPageState extends ConsumerState<DepositUsdtPage> {
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
'可用余额: $_balance 绿积分',
style: TextStyle(
@ -387,6 +390,7 @@ class _DepositUsdtPageState extends ConsumerState<DepositUsdtPage> {
color: const Color(0xFF5D4037).withValues(alpha: 0.8),
),
),
),
);
}

View File

@ -420,7 +420,10 @@ class _MiningPageState extends ConsumerState<MiningPage> {
],
)
else if (_walletStatus == WalletCreationStatus.ready)
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
'序列号$_serialNumber',
style: const TextStyle(
fontSize: 20,
@ -430,6 +433,7 @@ class _MiningPageState extends ConsumerState<MiningPage> {
letterSpacing: -0.3,
color: Color(0xFF5D4037),
),
),
)
else
// unknown "创建账号审核中..."

View File

@ -423,7 +423,9 @@ class _PlantingQuantityPageState extends ConsumerState<PlantingQuantityPage> {
),
),
)
: Text(
: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
_formatNumber(_availableBalance),
style: const TextStyle(
fontSize: 36,
@ -434,6 +436,7 @@ class _PlantingQuantityPageState extends ConsumerState<PlantingQuantityPage> {
color: Color(0xFF5D4037),
),
),
),
],
),
);

View File

@ -2029,7 +2029,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xCC5D4037),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_formatNumber(_pendingUsdt),
style: const TextStyle(
fontSize: 16,
@ -2039,6 +2043,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
),
],
),
// TODO:
@ -2183,7 +2189,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(height: 8),
//
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
amountText,
style: const TextStyle(
fontSize: 16,
@ -2192,6 +2201,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
//
if (item.memo.isNotEmpty) ...[
const SizedBox(height: 4),
@ -2310,7 +2320,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(height: 8),
//
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
amountText,
style: const TextStyle(
fontSize: 16,
@ -2319,6 +2332,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
//
if (item.memo.isNotEmpty) ...[
const SizedBox(height: 4),
@ -2366,7 +2380,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xCC5D4037),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_formatNumber(_settleableUsdt),
style: const TextStyle(
fontSize: 14,
@ -2376,6 +2394,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
),
],
),
//
@ -2432,7 +2452,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xCC5D4037),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_formatNumber(_settledUsdt),
style: const TextStyle(
fontSize: 14,
@ -2442,6 +2466,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
),
],
),
GestureDetector(
@ -2539,7 +2565,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(height: 8),
//
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
amountText,
style: const TextStyle(
fontSize: 16,
@ -2548,6 +2577,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
],
),
);
@ -2622,7 +2652,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(height: 8),
//
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
amountText,
style: const TextStyle(
fontSize: 16,
@ -2631,6 +2664,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
],
),
)
@ -2649,7 +2683,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
amountText,
style: const TextStyle(
fontSize: 13,
@ -2658,6 +2696,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF4CAF50),
),
),
),
),
],
),
),
@ -2705,7 +2745,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xCC5D4037),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_formatNumber(_expiredUsdt),
style: const TextStyle(
fontSize: 14,
@ -2715,6 +2759,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF5D4037),
),
),
),
),
],
),
// TODO:
@ -2853,7 +2899,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(height: 8),
//
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
amountText,
style: const TextStyle(
fontSize: 16,
@ -2862,6 +2911,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF999999), //
),
),
),
],
),
);
@ -2935,7 +2985,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
),
const SizedBox(height: 8),
//
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
amountText,
style: const TextStyle(
fontSize: 16,
@ -2944,6 +2997,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF999999),
),
),
),
],
),
)
@ -2962,7 +3016,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFF999999),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
amountText,
style: const TextStyle(
fontSize: 13,
@ -2971,6 +3029,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
color: Color(0xFFE57373),
),
),
),
),
],
),
),

View File

@ -240,7 +240,9 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
),
const SizedBox(height: 2),
// /
Text(
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'${node.personalPlantingCount}/${node.teamPlantingCount}',
style: const TextStyle(
fontSize: 11,
@ -249,6 +251,7 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
color: Color(0xCC5D4037),
),
),
),
const SizedBox(height: 4),
// /
if (node.hasChildren)
@ -303,7 +306,9 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
color: Color(0xFF666666),
),
),
Text(
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'+${hiddenNodes.length}',
style: const TextStyle(
fontSize: 11,
@ -312,6 +317,7 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
color: Color(0xFF666666),
),
),
),
],
),
),
@ -534,7 +540,10 @@ class _HiddenNodesSheet extends StatelessWidget {
color: Color(0xFF5D4037),
),
),
subtitle: Text(
subtitle: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
'个人/团队: ${node.personalPlantingCount}/${node.teamPlantingCount}',
style: const TextStyle(
fontSize: 12,
@ -542,6 +551,7 @@ class _HiddenNodesSheet extends StatelessWidget {
color: Color(0xCC5D4037),
),
),
),
trailing: node.hasChildren
? Text(
'${node.directReferralCount}',
@ -740,7 +750,11 @@ class _NodeDetailsSheet extends StatelessWidget {
color: Color(0xFF8B5A2B),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
value,
style: const TextStyle(
fontSize: 14,
@ -749,6 +763,8 @@ class _NodeDetailsSheet extends StatelessWidget {
color: Color(0xFF5D4037),
),
),
),
),
],
);
}

View File

@ -381,10 +381,15 @@ class _RankingPageState extends ConsumerState<RankingPage> {
),
),
//
Column(
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 100),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
_formatNumber(item.teamPlantingAmount),
style: const TextStyle(
fontSize: 16,
@ -394,6 +399,7 @@ class _RankingPageState extends ConsumerState<RankingPage> {
color: Color(0xFFD4AF37),
),
),
),
const Text(
'团队认种量',
style: TextStyle(
@ -405,6 +411,7 @@ class _RankingPageState extends ConsumerState<RankingPage> {
),
],
),
),
],
),
);

View File

@ -440,7 +440,11 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
color: Color(0xFF5D4037),
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
'${(stats?.netAmount ?? 0) >= 0 ? '+' : ''}${_formatAmount(stats?.netAmount ?? 0)} 绿积分',
style: TextStyle(
fontSize: 18,
@ -450,6 +454,8 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
: const Color(0xFFE53935),
),
),
),
),
],
),
),
@ -485,7 +491,9 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
],
),
const SizedBox(height: 8),
Text(
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
_formatAmount(amount),
style: TextStyle(
fontSize: 20,
@ -493,6 +501,7 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
color: color,
),
),
),
const Text(
'绿积分',
style: TextStyle(
@ -662,7 +671,9 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
),
),
const SizedBox(height: 4),
Text(
FittedBox(
fit: BoxFit.scaleDown,
child: Text(
_formatAmount(amount),
style: TextStyle(
fontSize: 12,
@ -670,6 +681,7 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
color: color,
),
),
),
],
);
}
@ -760,7 +772,11 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
],
),
),
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
'${isIncome ? '+' : ''}${_formatAmount(item.totalAmount)}',
style: TextStyle(
fontSize: 14,
@ -768,6 +784,8 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
color: isIncome ? const Color(0xFF4CAF50) : const Color(0xFFE53935),
),
),
),
),
],
),
);
@ -978,10 +996,15 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
),
),
//
Column(
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 120),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
'${isIncome ? '+' : ''}${_formatAmount(entry.amount)}',
style: TextStyle(
fontSize: 16,
@ -989,18 +1012,24 @@ class _LedgerDetailPageState extends ConsumerState<LedgerDetailPage>
color: isIncome ? const Color(0xFF4CAF50) : const Color(0xFFE53935),
),
),
),
if (entry.balanceAfter != null) ...[
const SizedBox(height: 4),
Text(
FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerRight,
child: Text(
'余额: ${_formatAmount(entry.balanceAfter!)}',
style: const TextStyle(
fontSize: 10,
color: Color(0x995D4037),
),
),
),
],
],
),
),
],
),
);

View File

@ -534,7 +534,9 @@ class _TradingPageState extends ConsumerState<TradingPage> {
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
),
)
: Text(
: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'DST 余额: ${_formatNumber(_dstBalance)}',
style: const TextStyle(
fontSize: 14,
@ -542,6 +544,7 @@ class _TradingPageState extends ConsumerState<TradingPage> {
height: 1.5,
color: Color(0x995D4037),
),
),
);
}
@ -616,7 +619,9 @@ class _TradingPageState extends ConsumerState<TradingPage> {
valueColor: AlwaysStoppedAnimation<Color>(Color(0xFFD4AF37)),
),
)
: Text(
: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
'绿积分 余额: ${_formatNumber(_usdtBalance)}',
style: const TextStyle(
fontSize: 14,
@ -624,6 +629,7 @@ class _TradingPageState extends ConsumerState<TradingPage> {
height: 1.5,
color: Color(0x995D4037),
),
),
);
}
}

View File

@ -568,7 +568,11 @@ class _WithdrawUsdtPageState extends ConsumerState<WithdrawUsdtPage> {
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
Flexible(
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
_formatNumber(_usdtBalance),
style: const TextStyle(
fontSize: 32,
@ -578,6 +582,8 @@ class _WithdrawUsdtPageState extends ConsumerState<WithdrawUsdtPage> {
color: Color(0xFF5D4037),
),
),
),
),
const SizedBox(width: 8),
const Padding(
padding: EdgeInsets.only(bottom: 4),