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,7 +1,7 @@
import 'dart:typed_data';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import 'package:image_picker/image_picker.dart';
import '../../../core/theme/app_color_scheme.dart';
@@ -431,9 +431,9 @@ class _KycPageState extends State<KycPage> {
if (!mounted) return;
if (response.success) {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: Row(
children: [
NeonIcon(
@@ -445,9 +445,9 @@ class _KycPageState extends State<KycPage> {
const Text('認證成功'),
],
),
description: const Text('您的實名認證已通過,現在可以進行提現操作'),
content: const Text('您的實名認證已通過,現在可以進行提現操作'),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () {
Navigator.of(ctx).pop();
@@ -458,13 +458,13 @@ class _KycPageState extends State<KycPage> {
),
);
} else {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: const Text('認證失敗'),
description: Text(response.message ?? '請稍後重試'),
content: Text(response.message ?? '請稍後重試'),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () => Navigator.of(ctx).pop(),
),
@@ -474,13 +474,13 @@ class _KycPageState extends State<KycPage> {
}
} catch (e) {
if (mounted) {
showShadDialog(
showDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
builder: (ctx) => AlertDialog(
title: const Text('認證失敗'),
description: Text(e.toString()),
content: Text(e.toString()),
actions: [
ShadButton(
TextButton(
child: const Text('確定'),
onPressed: () => Navigator.of(ctx).pop(),
),

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:provider/provider.dart';
import '../../../core/theme/app_spacing.dart';
import '../../../core/theme/app_theme.dart';
@@ -145,9 +145,9 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
final goldAccent = context.appColors.accentPrimary;
return Scaffold(
backgroundColor: context.colors.surface,
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
backgroundColor: context.colors.surface,
backgroundColor: Theme.of(context).colorScheme.surface,
elevation: 0,
scrolledUnderElevation: 0,
centerTitle: false,
@@ -157,7 +157,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
style: AppTextStyles.headlineLarge(context),
),
leading: IconButton(
icon: Icon(LucideIcons.arrowLeft, color: context.colors.onSurface, size: 24),
icon: Icon(LucideIcons.arrowLeft, color: Theme.of(context).colorScheme.onSurface, size: 24),
onPressed: () => Navigator.of(context).pop(),
),
),
@@ -242,7 +242,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
},
style: ElevatedButton.styleFrom(
backgroundColor: goldAccent,
foregroundColor: context.colors.onPrimary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
@@ -251,7 +251,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
),
child: Text(
'複製邀請碼',
style: AppTextStyles.headlineMedium(context).copyWith(color: context.colors.onPrimary),
style: AppTextStyles.headlineMedium(context).copyWith(color: Theme.of(context).colorScheme.onPrimary),
),
),
),
@@ -325,21 +325,21 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
'+100 USDT',
style: AppTextStyles.displayLarge(context).copyWith(
fontWeight: FontWeight.w800,
color: claimed ? context.colors.onSurfaceVariant : profitGreen,
color: claimed ? Theme.of(context).colorScheme.onSurfaceVariant : profitGreen,
),
),
const SizedBox(height: 8),
Text(
description,
style: AppTextStyles.bodyLarge(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: 16),
_fullWidthButton(
text: buttonText,
backgroundColor: profitGreen,
foregroundColor: context.colors.onPrimary,
foregroundColor: Theme.of(context).colorScheme.onPrimary,
onPressed: canClaim ? () => _claimNewUserBonus() : null,
),
],
@@ -425,12 +425,12 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
child: Column(
children: [
Text(label, style: AppTextStyles.bodySmall(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
)),
const SizedBox(height: 2),
Text(value, style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.w700,
color: highlight ? context.appColors.up : context.colors.onSurface,
color: highlight ? context.appColors.up : Theme.of(context).colorScheme.onSurface,
)),
],
),
@@ -452,7 +452,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
Text(
'暫無推廣用戶',
style: AppTextStyles.bodyLarge(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
@@ -592,7 +592,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
label = '${threshold}';
} else {
bgColor = context.appColors.surfaceCardHigh;
textColor = context.colors.onSurfaceVariant;
textColor = Theme.of(context).colorScheme.onSurfaceVariant;
label = '${threshold}';
}
@@ -631,7 +631,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
child: Text(
username.isNotEmpty ? username[0].toUpperCase() : '?',
style: AppTextStyles.headlineSmall(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
@@ -719,7 +719,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
Text(
'已推廣 $indirectRefCount',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
if (indirectClaimableCount > 0) ...[
@@ -773,7 +773,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
label = '50\u{1F381}';
} else {
bgColor = context.appColors.surfaceCardHigh;
textColor = context.colors.onSurfaceVariant;
textColor = Theme.of(context).colorScheme.onSurfaceVariant;
label = '50';
}
@@ -841,7 +841,7 @@ class _WelfareCenterPageState extends State<WelfareCenterPage> {
child: Text(
'\u2022 $text',
style: AppTextStyles.bodyMedium(context).copyWith(
color: context.colors.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
);