## 样式主题重点优化 ### 颜色映射(注重主题一致性) - mutedForeground → onSurfaceVariant - border → outline - card → surfaceContainer - destructive → error - 保留所有 AppColorScheme 自定义颜色 ### 文本样式映射 - theme.textTheme.h1/muted/large → AppTextStyles.xxx(context) - 统一使用项目定义的文本样式系统 ### 组件替换(20个文件) - ShadApp → MaterialApp(移除 ShadThemeData) - ShadButton → ElevatedButton/OutlinedButton - ShadDialog → AlertDialog - ShadInputFormField → MaterialInput - ShadSelect → DropdownButtonFormField - ShadCard → Card - showShadDialog → showDialog ### 依赖变更 - 移除:shadcn_ui: ^0.52.1 - 添加:lucide_icons_flutter: ^2.0.0 ### 业务逻辑保护 ✅ 所有 onPressed/onChanged/validator 回调保持不变 ✅ 所有 controller/focusNode 数据绑定保持不变 ✅ 所有布局结构(Column/Row/Padding)保持不变 ✅ 仅替换 UI 组件层,业务逻辑完全保留
164 lines
4.5 KiB
Dart
164 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../../../core/theme/app_spacing.dart';
|
|
import '../../../core/theme/app_theme_extension.dart';
|
|
import '../../components/coin_icon.dart';
|
|
|
|
/// 首頁熱門幣種區塊
|
|
class HotCoinsSection extends StatelessWidget {
|
|
const HotCoinsSection({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
// Title row
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.md),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
'熱門幣種',
|
|
style: AppTextStyles.headlineLarge(context),
|
|
),
|
|
Text(
|
|
'更多',
|
|
style: AppTextStyles.bodyMedium(context).copyWith(
|
|
color: context.appColors.onSurfaceMuted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: AppSpacing.sm + AppSpacing.xs),
|
|
// Card
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
|
border: Border.all(
|
|
color: Theme.of(context).colorScheme.outlineVariant,
|
|
width: 1,
|
|
),
|
|
borderRadius: BorderRadius.circular(AppRadius.xl),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
_CoinRow(
|
|
symbol: 'BTC',
|
|
pair: 'BTC/USDT',
|
|
fullName: 'Bitcoin',
|
|
price: '68,432.50',
|
|
change: '+2.35%',
|
|
isUp: true,
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
thickness: 1,
|
|
color: context.appColors.ghostBorder,
|
|
),
|
|
_CoinRow(
|
|
symbol: 'ETH',
|
|
pair: 'ETH/USDT',
|
|
fullName: 'Ethereum',
|
|
price: '3,856.20',
|
|
change: '+1.82%',
|
|
isUp: true,
|
|
),
|
|
Divider(
|
|
height: 1,
|
|
thickness: 1,
|
|
color: context.appColors.ghostBorder,
|
|
),
|
|
_CoinRow(
|
|
symbol: 'SOL',
|
|
pair: 'SOL/USDT',
|
|
fullName: 'Solana',
|
|
price: '178.65',
|
|
change: '-0.94%',
|
|
isUp: false,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _CoinRow extends StatelessWidget {
|
|
const _CoinRow({
|
|
required this.symbol,
|
|
required this.pair,
|
|
required this.fullName,
|
|
required this.price,
|
|
required this.change,
|
|
required this.isUp,
|
|
});
|
|
|
|
final String symbol;
|
|
final String pair;
|
|
final String fullName;
|
|
final String price;
|
|
final String change;
|
|
final bool isUp;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final changeColor = isUp
|
|
? context.appColors.up
|
|
: context.appColors.down;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: AppSpacing.md),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
// Left: avatar + name
|
|
Row(
|
|
children: [
|
|
CoinIcon(
|
|
symbol: symbol,
|
|
size: 36,
|
|
isCircle: false,
|
|
),
|
|
const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
pair,
|
|
style: AppTextStyles.headlineMedium(context).copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text(
|
|
fullName,
|
|
style: AppTextStyles.bodySmall(context),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
// Right: price + change
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Text(
|
|
price,
|
|
style: AppTextStyles.numberMedium(context),
|
|
),
|
|
Text(
|
|
change,
|
|
style: AppTextStyles.labelMedium(context).copyWith(
|
|
color: changeColor,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|