refactor: 批量替换 shadcn_ui 为 Material Design 组件

## 样式主题重点优化

### 颜色映射(注重主题一致性)
- 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 组件层,业务逻辑完全保留
This commit is contained in:
2026-04-08 12:24:24 +08:00
parent 5ee87136a7
commit 658f49e280
24 changed files with 281 additions and 455 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../core/theme/app_theme.dart';
import 'package:flutter_animate/flutter_animate.dart';
import '../../core/theme/app_spacing.dart';
import '../../core/theme/app_theme_extension.dart';
@@ -35,8 +36,8 @@ class AssetCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final colorScheme = context.colors;
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final appColors = context.appColors;
final cardGradient = gradient ?? appColors.assetGradient;
@@ -68,7 +69,7 @@ class AssetCard extends StatelessWidget {
children: [
Text(
title,
style: theme.textTheme.small.copyWith(color: secondaryTextColor),
style: AppTextStyles.bodySmall(context).copyWith(color: secondaryTextColor),
),
const Spacer(),
if (onTap != null)
@@ -83,7 +84,7 @@ class AssetCard extends StatelessWidget {
// 餘額 - 大標題
Text(
balance,
style: theme.textTheme.h1.copyWith(
style: AppTextStyles.headlineLarge(context).copyWith(
fontWeight: FontWeight.bold,
color: primaryTextColor,
fontSize: 20,
@@ -102,7 +103,7 @@ class AssetCard extends StatelessWidget {
const SizedBox(width: 6),
Text(
'盈虧: $profit',
style: theme.textTheme.small.copyWith(color: secondaryTextColor),
style: AppTextStyles.bodySmall(context).copyWith(color: secondaryTextColor),
),
],
),
@@ -178,15 +179,16 @@ class AssetCardCompact extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
final appColors = context.appColors;
final isValueUp = isUp ?? true;
return ShadCard(
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
onTap: onTap,
child: Row(
return Card(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
onTap: onTap,
child: Row(
children: [
Expanded(
child: Column(
@@ -194,12 +196,12 @@ class AssetCardCompact extends StatelessWidget {
children: [
Text(
title,
style: theme.textTheme.muted,
style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant),
),
const SizedBox(height: 4),
Text(
balance,
style: theme.textTheme.h3.copyWith(
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.bold,
),
),
@@ -224,6 +226,7 @@ class AssetCardCompact extends StatelessWidget {
],
),
),
),
);
}
}

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import '../../core/theme/app_theme.dart';
import '../../core/theme/app_spacing.dart';
import '../../core/theme/app_theme_extension.dart';
@@ -31,11 +31,12 @@ class CoinCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return ShadCard(
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
return Card(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.md),
child: InkWell(
onTap: onTap,
child: Row(
children: [
@@ -66,13 +67,13 @@ class CoinCard extends StatelessWidget {
children: [
Text(
'$code/USDT',
style: theme.textTheme.large.copyWith(
style: AppTextStyles.headlineMedium(context).copyWith(
fontWeight: FontWeight.bold,
),
),
Text(
name,
style: theme.textTheme.muted,
style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant),
),
],
),
@@ -95,6 +96,7 @@ class CoinCard extends StatelessWidget {
],
),
),
),
);
}
}