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:
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../../core/theme/app_spacing.dart';
|
||||
import '../../core/theme/app_theme.dart';
|
||||
|
||||
/// 現代彈窗模板 - 基於 modernization-v2.md 規範
|
||||
///
|
||||
@@ -102,13 +102,13 @@ class ModernDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ShadTheme.of(context);
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.xl),
|
||||
),
|
||||
backgroundColor: theme.colorScheme.card,
|
||||
backgroundColor: theme.colorScheme.surfaceContainer,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(AppSpacing.lg),
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
@@ -122,7 +122,7 @@ class ModernDialog extends StatelessWidget {
|
||||
else if (title != null)
|
||||
Text(
|
||||
title!,
|
||||
style: theme.textTheme.h3.copyWith(
|
||||
style: AppTextStyles.headlineSmall(context).copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
@@ -132,7 +132,7 @@ class ModernDialog extends StatelessWidget {
|
||||
if (description != null) ...[
|
||||
Text(
|
||||
description!,
|
||||
style: theme.textTheme.muted,
|
||||
style: AppTextStyles.bodyMedium(context).copyWith(color: theme.colorScheme.onSurfaceVariant),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
],
|
||||
@@ -166,11 +166,13 @@ class ModernDialog extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildActionButton(BuildContext context, ModernDialogAction action) {
|
||||
final theme = ShadTheme.of(context);
|
||||
final theme = Theme.of(context);
|
||||
|
||||
if (action.isPrimary) {
|
||||
return ShadButton(
|
||||
backgroundColor: action.isDestructive ? theme.colorScheme.destructive : theme.colorScheme.primary,
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: action.isDestructive ? theme.colorScheme.error : theme.colorScheme.primary,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(action.returnValue);
|
||||
action.onPressed?.call();
|
||||
@@ -179,7 +181,7 @@ class ModernDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return ShadButton.outline(
|
||||
return OutlinedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(action.returnValue);
|
||||
action.onPressed?.call();
|
||||
|
||||
Reference in New Issue
Block a user