Move skills system documentation from bottom to top of CLAUDE.md for better organization. Refactor Flutter asset page by extracting UI components into separate files and updating import structure for improved modularity.
85 lines
2.6 KiB
Dart
85 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../../../../core/theme/app_color_scheme.dart';
|
|
import '../../../../core/theme/app_spacing.dart';
|
|
import '../../../../providers/asset_provider.dart';
|
|
import '../../../components/glass_panel.dart';
|
|
|
|
/// 余额卡片 — .pen node 59637
|
|
/// cornerRadius: lg, fill: $surface-card, padding: 20, stroke: $border-default 1px, gap: 12
|
|
/// balLabel: "USDT 余额" 12px normal $text-secondary
|
|
/// balAmount: "25,680.50" 28px w700 $text-primary
|
|
/// balSubRow: "≈ $25,680.50 USD" 12px normal $text-muted
|
|
class BalanceCard extends StatelessWidget {
|
|
final AssetProvider provider;
|
|
final int activeTab;
|
|
|
|
const BalanceCard({
|
|
super.key,
|
|
required this.provider,
|
|
required this.activeTab,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
final isDark = Theme.of(context).brightness == Brightness.dark;
|
|
|
|
final displayBalance = activeTab == 0
|
|
? (provider.fundAccount?.balance ?? provider.overview?.fundBalance ?? '0.00')
|
|
: _calculateTradeTotal();
|
|
|
|
return GlassPanel(
|
|
padding: const EdgeInsets.all(20),
|
|
borderRadius: BorderRadius.circular(AppRadius.lg),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'USDT 余额',
|
|
style: GoogleFonts.inter(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.normal,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
_formatBalance(displayBalance),
|
|
style: GoogleFonts.inter(
|
|
fontSize: 28,
|
|
fontWeight: FontWeight.w700,
|
|
color: colorScheme.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
'\u2248 \$${_formatBalance(displayBalance)} USD',
|
|
style: GoogleFonts.inter(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.normal,
|
|
color: isDark ? AppColorScheme.darkOnSurfaceMuted : colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
String _calculateTradeTotal() {
|
|
double total = 0;
|
|
for (var h in provider.holdings) {
|
|
total += double.tryParse(h.currentValue?.toString() ?? '0') ?? 0;
|
|
}
|
|
return total.toStringAsFixed(2);
|
|
}
|
|
|
|
String _formatBalance(String balance) {
|
|
final d = double.tryParse(balance) ?? 0;
|
|
return d.toStringAsFixed(2).replaceAllMapped(
|
|
RegExp(r'\B(?=(\d{3})+(?!\d))'),
|
|
(Match m) => ',',
|
|
);
|
|
}
|
|
}
|