## 样式主题重点优化 ### 颜色映射(注重主题一致性) - 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 组件层,业务逻辑完全保留
107 lines
2.9 KiB
Dart
107 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
|
import '../../../core/theme/app_theme.dart';
|
|
import '../../../core/theme/app_color_scheme.dart';
|
|
import '../../../core/theme/app_spacing.dart';
|
|
import '../../../providers/auth_provider.dart';
|
|
|
|
/// 首頁頂欄 - Logo + 搜索/通知/頭像
|
|
class HeaderBar extends StatelessWidget {
|
|
const HeaderBar({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: AppSpacing.md,
|
|
vertical: AppSpacing.sm,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// Logo
|
|
Text(
|
|
'MONISUO',
|
|
style: AppTextStyles.headlineLarge(context).copyWith(
|
|
fontSize: 18,
|
|
letterSpacing: 1,
|
|
),
|
|
),
|
|
const Spacer(),
|
|
// Search button
|
|
_IconButton(
|
|
icon: LucideIcons.search,
|
|
colorScheme: colorScheme,
|
|
onTap: () {},
|
|
),
|
|
const SizedBox(width: AppSpacing.sm),
|
|
// Bell button
|
|
_IconButton(
|
|
icon: LucideIcons.bell,
|
|
colorScheme: colorScheme,
|
|
onTap: () {},
|
|
),
|
|
const SizedBox(width: AppSpacing.sm),
|
|
// Avatar
|
|
Consumer<AuthProvider>(
|
|
builder: (context, auth, _) {
|
|
final username = auth.user?.username ?? '';
|
|
final initial = username.isNotEmpty ? username[0].toUpperCase() : '?';
|
|
return Container(
|
|
width: 32,
|
|
height: 32,
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.primary,
|
|
shape: BoxShape.circle,
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
initial,
|
|
style: AppTextStyles.headlineMedium(context).copyWith(
|
|
color: AppColorScheme.darkOnPrimary,
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _IconButton extends StatelessWidget {
|
|
const _IconButton({
|
|
required this.icon,
|
|
required this.colorScheme,
|
|
required this.onTap,
|
|
});
|
|
|
|
final IconData icon;
|
|
final ColorScheme colorScheme;
|
|
final VoidCallback onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
width: 32,
|
|
height: 32,
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.surfaceContainerHigh,
|
|
borderRadius: BorderRadius.circular(AppRadius.xl),
|
|
),
|
|
alignment: Alignment.center,
|
|
child: Icon(
|
|
icon,
|
|
size: 16,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|