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,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../../core/theme/app_spacing.dart';
import '../../core/theme/app_theme.dart';
/// 現代底部抽屜模板 - 基於 modernization-v2.md 規範
///
@@ -100,17 +101,19 @@ class ModernBottomSheet extends StatelessWidget {
Row(
children: [
Expanded(
child: ShadButton.outline(
child: OutlinedButton(
onPressed: () => Navigator.of(context).pop(0),
child: Text(cancelText),
),
),
const SizedBox(width: AppSpacing.md),
Expanded(
child: ShadButton(
backgroundColor: isDestructive
? ShadTheme.of(context).colorScheme.destructive
: null,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: isDestructive
? Theme.of(context).colorScheme.error
: null,
),
onPressed: () => Navigator.of(context).pop(1),
child: Text(confirmText),
),
@@ -125,12 +128,12 @@ class ModernBottomSheet extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
final bottomPadding = MediaQuery.of(context).padding.bottom;
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.card,
color: theme.colorScheme.surfaceContainer,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(AppRadius.xxl),
),
@@ -164,21 +167,21 @@ class ModernBottomSheet extends StatelessWidget {
);
}
Widget _buildDragHandle(ShadThemeData theme) {
Widget _buildDragHandle(ThemeData theme) {
return Center(
child: Container(
width: 40,
height: 4,
margin: const EdgeInsets.only(bottom: AppSpacing.md),
decoration: BoxDecoration(
color: theme.colorScheme.muted,
color: theme.colorScheme.outline,
borderRadius: BorderRadius.circular(2),
),
),
);
}
Widget _buildHeader(BuildContext context, ShadThemeData theme) {
Widget _buildHeader(BuildContext context, ThemeData theme) {
return Padding(
padding: const EdgeInsets.only(bottom: AppSpacing.md),
child: Row(
@@ -187,7 +190,7 @@ class ModernBottomSheet extends StatelessWidget {
Expanded(
child: titleWidget ?? Text(
title!,
style: theme.textTheme.h3.copyWith(
style: AppTextStyles.headlineSmall(context).copyWith(
fontWeight: FontWeight.w600,
),
),
@@ -202,7 +205,7 @@ class ModernBottomSheet extends StatelessWidget {
child: Icon(
LucideIcons.x,
size: 20,
color: theme.colorScheme.mutedForeground,
color: theme.colorScheme.onSurfaceVariant,
),
),
],
@@ -219,7 +222,7 @@ class _ActionList extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return Column(
children: actions.asMap().entries.map((entry) {
@@ -229,7 +232,7 @@ class _ActionList extends StatelessWidget {
return Column(
children: [
if (index > 0 && actions[index - 1].isDivider)
Divider(color: theme.colorScheme.border, height: 1),
Divider(color: theme.colorScheme.outline, height: 1),
_ActionTile(action: action),
],
);
@@ -246,7 +249,7 @@ class _ActionTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ShadTheme.of(context);
final theme = Theme.of(context);
return InkWell(
onTap: () {
@@ -266,8 +269,8 @@ class _ActionTile extends StatelessWidget {
action.icon,
size: 20,
color: action.isDestructive
? theme.colorScheme.destructive
: theme.colorScheme.foreground,
? theme.colorScheme.error
: theme.colorScheme.onSurface,
),
const SizedBox(width: AppSpacing.md),
],
@@ -277,8 +280,8 @@ class _ActionTile extends StatelessWidget {
style: TextStyle(
fontSize: 16,
color: action.isDestructive
? theme.colorScheme.destructive
: theme.colorScheme.foreground,
? theme.colorScheme.error
: theme.colorScheme.onSurface,
),
),
),