docs(theme): update documentation and clean up deprecated color scheme definitions

Removed outdated compatibility aliases and deprecated methods from AppColorScheme,
and updated CLAUDE.md to reflect new theme system requirements with centralized
color management and no hard-coded values in UI components.
This commit is contained in:
2026-04-05 23:37:27 +08:00
parent 189609f337
commit f5ac578892
39 changed files with 20289 additions and 1260 deletions

View File

@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../../core/theme/app_theme.dart';
import '../../../core/theme/app_color_scheme.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../providers/asset_provider.dart';
import '../../../data/models/account_models.dart';
@@ -81,17 +82,6 @@ class _TransferPageState extends State<TransferPage> {
bool get _isDark => Theme.of(context).brightness == Brightness.dark;
/// 一次性获取所有主题感知颜色
_TransferColors get _colors => _TransferColors(_isDark);
TextStyle _inter({
required double fontSize,
required FontWeight fontWeight,
required Color color,
}) {
return GoogleFonts.inter(fontSize: fontSize, fontWeight: fontWeight, color: color);
}
// ============================================
// 业务逻辑
// ============================================
@@ -162,37 +152,37 @@ class _TransferPageState extends State<TransferPage> {
@override
Widget build(BuildContext context) {
final c = _colors;
final colorScheme = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: c.bgSecondary,
backgroundColor: colorScheme.surface,
appBar: AppBar(
backgroundColor: c.surfaceCard,
backgroundColor: colorScheme.surfaceContainer,
elevation: 0,
scrolledUnderElevation: 0,
leading: IconButton(
icon: Icon(LucideIcons.arrowLeft, color: c.textPrimary, size: 20),
icon: Icon(LucideIcons.arrowLeft, color: colorScheme.onSurface, size: 20),
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
'账户划转',
style: _inter(fontSize: 16, fontWeight: FontWeight.w600, color: c.textPrimary),
style: AppTextStyles.headlineLarge(context),
),
centerTitle: true,
),
body: Consumer<AssetProvider>(
builder: (context, provider, _) {
return SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 32),
padding: const EdgeInsets.fromLTRB(AppSpacing.md, AppSpacing.md, AppSpacing.md, AppSpacing.xl),
child: Column(
children: [
_buildTransferDirectionCard(c),
const SizedBox(height: 24),
_buildAmountSection(c),
const SizedBox(height: 24),
_buildTipsCard(c),
const SizedBox(height: 24),
_buildConfirmButton(c),
_buildTransferDirectionCard(),
const SizedBox(height: AppSpacing.lg),
_buildAmountSection(),
const SizedBox(height: AppSpacing.lg),
_buildTipsCard(),
const SizedBox(height: AppSpacing.lg),
_buildConfirmButton(),
],
),
);
@@ -205,14 +195,16 @@ class _TransferPageState extends State<TransferPage> {
// Transfer direction card
// ============================================
Widget _buildTransferDirectionCard(_TransferColors c) {
Widget _buildTransferDirectionCard() {
final colorScheme = Theme.of(context).colorScheme;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
padding: const EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
color: c.surfaceCard,
color: colorScheme.surfaceContainer,
borderRadius: BorderRadius.circular(AppRadius.xl),
border: Border.all(color: c.borderDefault.withValues(alpha: 0.6)),
border: Border.all(color: colorScheme.outlineVariant.withValues(alpha: 0.6)),
),
child: Column(
children: [
@@ -224,7 +216,6 @@ class _TransferPageState extends State<TransferPage> {
label: '',
accountName: _fromLabel,
balance: _fromBalance,
c: c,
),
),
@@ -234,13 +225,13 @@ class _TransferPageState extends State<TransferPage> {
child: Container(
width: 36,
height: 36,
margin: const EdgeInsets.symmetric(vertical: 16),
margin: const EdgeInsets.symmetric(vertical: AppSpacing.md),
decoration: BoxDecoration(
color: c.accentPrimary,
color: colorScheme.secondary,
shape: BoxShape.circle,
),
child: Center(
child: Icon(LucideIcons.arrowUpDown, size: 18, color: c.textInverse),
child: Icon(LucideIcons.arrowUpDown, size: 18, color: colorScheme.onSecondary),
),
),
),
@@ -253,7 +244,6 @@ class _TransferPageState extends State<TransferPage> {
label: '',
accountName: _toLabel,
balance: _toBalance,
c: c,
),
),
],
@@ -286,15 +276,16 @@ class _TransferPageState extends State<TransferPage> {
required String label,
required String accountName,
required String balance,
required _TransferColors c,
}) {
final colorScheme = Theme.of(context).colorScheme;
return SizedBox(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: _inter(fontSize: 11, fontWeight: FontWeight.normal, color: c.textMuted)),
const SizedBox(height: 8),
Text(label, style: AppTextStyles.bodySmall(context)),
const SizedBox(height: AppSpacing.sm),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -303,15 +294,15 @@ class _TransferPageState extends State<TransferPage> {
Icon(
label == '' ? LucideIcons.wallet : LucideIcons.repeat,
size: 18,
color: c.textSecondary,
color: colorScheme.onSurfaceVariant,
),
const SizedBox(width: 10),
Text(accountName, style: _inter(fontSize: 14, fontWeight: FontWeight.w600, color: c.textPrimary)),
const SizedBox(width: AppSpacing.sm + 2),
Text(accountName, style: AppTextStyles.headlineMedium(context)),
],
),
Text(
'\u00A5 ${_formatBalance(balance)}',
style: _inter(fontSize: 14, fontWeight: FontWeight.w600, color: c.textPrimary),
style: AppTextStyles.headlineMedium(context),
),
],
),
@@ -324,7 +315,9 @@ class _TransferPageState extends State<TransferPage> {
// Amount input section
// ============================================
Widget _buildAmountSection(_TransferColors c) {
Widget _buildAmountSection() {
final colorScheme = Theme.of(context).colorScheme;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -332,10 +325,13 @@ class _TransferPageState extends State<TransferPage> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('划转金额', style: _inter(fontSize: 14, fontWeight: FontWeight.w500, color: c.textSecondary)),
Text('划转金额', style: AppTextStyles.headlineSmall(context).copyWith(color: colorScheme.onSurfaceVariant)),
GestureDetector(
onTap: () => _setQuickAmount(1.0),
child: Text('全部划转', style: _inter(fontSize: 12, fontWeight: FontWeight.w600, color: c.goldAccent)),
child: Text('全部划转', style: AppTextStyles.labelLarge(context).copyWith(
color: colorScheme.secondary,
fontWeight: FontWeight.w600,
)),
),
],
),
@@ -347,9 +343,9 @@ class _TransferPageState extends State<TransferPage> {
child: Container(
width: double.infinity,
height: 56,
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
decoration: BoxDecoration(
color: c.bgTertiary,
color: colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: Row(
@@ -363,10 +359,12 @@ class _TransferPageState extends State<TransferPage> {
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d{0,8}')),
],
style: _inter(fontSize: 28, fontWeight: FontWeight.w700, color: c.textPrimary),
style: AppTextStyles.numberLarge(context),
decoration: InputDecoration(
hintText: '0.00',
hintStyle: _inter(fontSize: 28, fontWeight: FontWeight.w700, color: c.textMuted),
hintStyle: AppTextStyles.numberLarge(context).copyWith(
color: AppColorScheme.darkOnSurfaceMuted,
),
border: InputBorder.none,
contentPadding: EdgeInsets.zero,
isDense: true,
@@ -374,8 +372,11 @@ class _TransferPageState extends State<TransferPage> {
),
),
Padding(
padding: const EdgeInsets.only(left: 8),
child: Text('USDT', style: _inter(fontSize: 14, fontWeight: FontWeight.normal, color: c.textMuted)),
padding: const EdgeInsets.only(left: AppSpacing.sm),
child: Text('USDT', style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.w400,
color: AppColorScheme.darkOnSurfaceMuted,
)),
),
],
),
@@ -390,8 +391,8 @@ class _TransferPageState extends State<TransferPage> {
final percent = entry.value;
final label = '${(percent * 100).toInt()}%';
return Padding(
padding: EdgeInsets.only(left: index > 0 ? 8 : 0),
child: _buildPercentButton(label, percent, c),
padding: EdgeInsets.only(left: index > 0 ? AppSpacing.sm : 0),
child: _buildPercentButton(label, percent),
);
}).toList(),
),
@@ -399,18 +400,20 @@ class _TransferPageState extends State<TransferPage> {
);
}
Widget _buildPercentButton(String label, double percent, _TransferColors c) {
Widget _buildPercentButton(String label, double percent) {
final colorScheme = Theme.of(context).colorScheme;
return Expanded(
child: GestureDetector(
onTap: () => _setQuickAmount(percent),
child: Container(
height: 36,
decoration: BoxDecoration(
color: c.bgTertiary,
color: colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(AppRadius.sm),
),
child: Center(
child: Text(label, style: _inter(fontSize: 13, fontWeight: FontWeight.w500, color: c.textSecondary)),
child: Text(label, style: AppTextStyles.headlineSmall(context)),
),
),
),
@@ -421,22 +424,24 @@ class _TransferPageState extends State<TransferPage> {
// Tips card & Confirm button
// ============================================
Widget _buildTipsCard(_TransferColors c) {
Widget _buildTipsCard() {
final upColor = AppColorScheme.getUpColor(_isDark);
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md, vertical: 12),
decoration: BoxDecoration(
color: c.profitGreenBg,
color: AppColorScheme.getUpBackgroundColor(_isDark),
borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: Row(
children: [
Icon(LucideIcons.info, size: 16, color: c.profitGreen),
const SizedBox(width: 8),
Icon(LucideIcons.info, size: 16, color: upColor),
const SizedBox(width: AppSpacing.sm),
Expanded(
child: Text(
'划转即时到账,无需手续费',
style: _inter(fontSize: 12, fontWeight: FontWeight.normal, color: c.profitGreen),
style: AppTextStyles.bodyMedium(context).copyWith(color: upColor),
),
),
],
@@ -444,7 +449,9 @@ class _TransferPageState extends State<TransferPage> {
);
}
Widget _buildConfirmButton(_TransferColors c) {
Widget _buildConfirmButton() {
final colorScheme = Theme.of(context).colorScheme;
return SizedBox(
width: double.infinity,
height: 52,
@@ -452,7 +459,7 @@ class _TransferPageState extends State<TransferPage> {
onTap: _isLoading ? null : _doTransfer,
child: Container(
decoration: BoxDecoration(
color: c.accentPrimary,
color: colorScheme.secondary,
borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: Center(
@@ -462,12 +469,15 @@ class _TransferPageState extends State<TransferPage> {
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(c.textInverse),
valueColor: AlwaysStoppedAnimation<Color>(colorScheme.onSecondary),
),
)
: Text(
'确认划转',
style: _inter(fontSize: 16, fontWeight: FontWeight.w700, color: c.textInverse),
style: AppTextStyles.displayMedium(context).copyWith(
color: colorScheme.onSecondary,
fontSize: 16,
),
),
),
),
@@ -485,33 +495,3 @@ class _TransferPageState extends State<TransferPage> {
return val.toStringAsFixed(2);
}
}
/// 主题感知颜色集合,避免在 build() 中重复定义大量局部变量
class _TransferColors {
final Color bgSecondary;
final Color surfaceCard;
final Color bgTertiary;
final Color borderDefault;
final Color textPrimary;
final Color textSecondary;
final Color textMuted;
final Color textInverse;
final Color accentPrimary;
final Color goldAccent;
final Color profitGreen;
final Color profitGreenBg;
_TransferColors(bool isDark)
: bgSecondary = isDark ? const Color(0xFF0B1120) : const Color(0xFFF8FAFC),
surfaceCard = isDark ? const Color(0xFF0F172A) : const Color(0xFFFFFFFF),
bgTertiary = isDark ? const Color(0xFF1E293B) : const Color(0xFFF1F5F9),
borderDefault = isDark ? const Color(0xFF334155) : const Color(0xFFE2E8F0),
textPrimary = isDark ? const Color(0xFFF8FAFC) : const Color(0xFF0F172A),
textSecondary = isDark ? const Color(0xFF94A3B8) : const Color(0xFF475569),
textMuted = isDark ? const Color(0xFF64748B) : const Color(0xFF94A3B8),
textInverse = isDark ? const Color(0xFF0F172A) : const Color(0xFFFFFFFF),
accentPrimary = isDark ? const Color(0xFFD4AF37) : const Color(0xFF1F2937),
goldAccent = isDark ? const Color(0xFFD4AF37) : const Color(0xFFF59E0B),
profitGreen = isDark ? const Color(0xFF4ADE80) : const Color(0xFF16A34A),
profitGreenBg = isDark ? const Color(0xFF052E16) : const Color(0xFFF0FDF4);
}