所有一级页面和不分二级页面
This commit is contained in:
41
lib/features/v2/my/presentation/constants/my_constants.dart
Normal file
41
lib/features/v2/my/presentation/constants/my_constants.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
/// 我的页面全局常量
|
||||
/// 包含颜色、尺寸等全局配置
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 颜色常量
|
||||
class MyColors {
|
||||
/// 主色调
|
||||
static const Color primary = Color(0xFF165DFF);
|
||||
|
||||
/// 背景色
|
||||
static const Color background = Color(0xFFF5F7FA);
|
||||
|
||||
/// 卡片背景色
|
||||
static const Color cardBackground = Color(0xFFFFFFFF);
|
||||
|
||||
/// 主要文字色
|
||||
static const Color textPrimary = Color(0xFF1D2129);
|
||||
|
||||
/// 次要文字色
|
||||
static const Color textSecondary = Color(0xFF4E5969);
|
||||
|
||||
/// 辅助文字色
|
||||
static const Color textTertiary = Color(0xFF86909C);
|
||||
}
|
||||
|
||||
/// 尺寸常量
|
||||
class MyDimensions {
|
||||
/// 通用圆角
|
||||
static const double borderRadius = 12.0;
|
||||
|
||||
/// 水平边距
|
||||
static const double horizontalPadding = 16.0;
|
||||
|
||||
/// 模块间距
|
||||
static const double moduleSpacing = 16.0;
|
||||
|
||||
/// 卡片阴影模糊半径
|
||||
static const double cardShadowBlur = 8.0;
|
||||
}
|
||||
102
lib/features/v2/my/presentation/cubit/my_cubit.dart
Normal file
102
lib/features/v2/my/presentation/cubit/my_cubit.dart
Normal file
@@ -0,0 +1,102 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/usecases/clear_cache_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/usecases/get_menu_items_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/usecases/toggle_night_mode_usecase.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/states/my_state.dart';
|
||||
|
||||
/// 我的页面 Cubit
|
||||
class MyCubit extends Cubit<MyState> {
|
||||
MyCubit({
|
||||
required GetMenuItemsUseCase getMenuItemsUseCase,
|
||||
required ToggleNightModeUseCase toggleNightModeUseCase,
|
||||
required ClearCacheUseCase clearCacheUseCase,
|
||||
}) : _getMenuItemsUseCase = getMenuItemsUseCase,
|
||||
_toggleNightModeUseCase = toggleNightModeUseCase,
|
||||
_clearCacheUseCase = clearCacheUseCase,
|
||||
super(MyInitial());
|
||||
|
||||
final GetMenuItemsUseCase _getMenuItemsUseCase;
|
||||
final ToggleNightModeUseCase _toggleNightModeUseCase;
|
||||
final ClearCacheUseCase _clearCacheUseCase;
|
||||
|
||||
/// 加载数据
|
||||
Future<void> loadData() async {
|
||||
emit(MyLoading());
|
||||
|
||||
try {
|
||||
final menuResult = await _getMenuItemsUseCase();
|
||||
|
||||
final menuItems = menuResult.fold(
|
||||
(failure) => <MenuItemEntity>[],
|
||||
(items) => items,
|
||||
);
|
||||
|
||||
if (menuItems.isEmpty) {
|
||||
emit(const MyError('加载菜单失败'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 模拟用户信息(实际应从 Auth 模块获取)
|
||||
final userProfile = UserProfileEntity(
|
||||
name: '张工程师',
|
||||
role: '运维工程师',
|
||||
avatar: '',
|
||||
userId: 'ENG2024001',
|
||||
);
|
||||
|
||||
emit(MyLoaded(
|
||||
userProfile: userProfile,
|
||||
menuItems: menuItems,
|
||||
));
|
||||
} catch (e) {
|
||||
emit(MyError('加载数据失败: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
/// 切换夜间模式
|
||||
Future<void> toggleNightMode(bool enabled) async {
|
||||
final currentState = state;
|
||||
if (currentState is MyLoaded) {
|
||||
// 乐观更新 UI
|
||||
emit(currentState.copyWith(isNightMode: enabled));
|
||||
|
||||
final result = await _toggleNightModeUseCase(enabled);
|
||||
|
||||
result.fold(
|
||||
(failure) {
|
||||
// 如果失败,回滚状态
|
||||
emit(currentState.copyWith(isNightMode: !enabled));
|
||||
emit(MyError('切换夜间模式失败'));
|
||||
},
|
||||
(_) {
|
||||
// 成功,保持当前状态
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 清除缓存
|
||||
Future<void> clearCache() async {
|
||||
final currentState = state;
|
||||
if (currentState is! MyLoaded) return;
|
||||
|
||||
emit(MyLoading());
|
||||
|
||||
final result = await _clearCacheUseCase();
|
||||
|
||||
result.fold(
|
||||
(failure) {
|
||||
emit(MyError('清除缓存失败: ${failure.message}'));
|
||||
},
|
||||
(success) {
|
||||
emit(currentState.copyWith(cacheSize: '0 MB'));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 刷新数据
|
||||
Future<void> refresh() async {
|
||||
await loadData();
|
||||
}
|
||||
}
|
||||
173
lib/features/v2/my/presentation/pages/my_page.dart
Normal file
173
lib/features/v2/my/presentation/pages/my_page.dart
Normal file
@@ -0,0 +1,173 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/cubit/my_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/states/my_state.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/di/my_di.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/constants/my_constants.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/user_profile_card.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/quick_action_card.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/menu_item_card.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart';
|
||||
|
||||
/// 我的页面(100% 还原设计稿)
|
||||
class MyPage extends StatelessWidget {
|
||||
const MyPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => MyDependencyInjector.createMyCubit()..loadData(),
|
||||
child: _MyPageContent(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MyPageContent extends StatelessWidget {
|
||||
const _MyPageContent();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
backgroundColor: MyColors.background,
|
||||
body: BlocConsumer<MyCubit, MyState>(
|
||||
listener: (context, state) {
|
||||
if (state is MyError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(state.message)),
|
||||
);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
if (state is MyLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: MyColors.primary),
|
||||
);
|
||||
}
|
||||
|
||||
if (state is MyLoaded) {
|
||||
final cubit = context.read<MyCubit>();
|
||||
return Column(
|
||||
children: [
|
||||
// 用户信息卡片(延伸到状态栏)
|
||||
UserProfileCard(
|
||||
name: state.userProfile.name,
|
||||
role: state.userProfile.role,
|
||||
onTap: () {
|
||||
// TODO: 跳转到个人信息页面
|
||||
debugPrint('点击个人信息');
|
||||
},
|
||||
),
|
||||
// 快捷入口卡片(负margin向上重叠)
|
||||
Transform.translate(
|
||||
offset: const Offset(0, -15),
|
||||
child: QuickActionCard(
|
||||
onMessageTap: () {
|
||||
debugPrint('我的消息');
|
||||
},
|
||||
onFavoriteTap: () {
|
||||
debugPrint('我的收藏');
|
||||
},
|
||||
onWorkOrderTap: () {
|
||||
debugPrint('我的工单');
|
||||
},
|
||||
),
|
||||
),
|
||||
// 菜单列表(白色卡片)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 15, left: 16, right: 16, bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x0D000000),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.5,
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: state.menuItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = state.menuItems[index];
|
||||
return MenuItemCard(
|
||||
item: item,
|
||||
onTap: () => _handleMenuItemTap(context, cubit, item),
|
||||
onSwitchChanged: item.hasSwitch
|
||||
? (value) => cubit.toggleNightMode(value)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 处理菜单项点击
|
||||
void _handleMenuItemTap(BuildContext context, MyCubit cubit, dynamic item) {
|
||||
switch (item.id) {
|
||||
case 'offline_cache':
|
||||
_showClearCacheDialog(context, cubit);
|
||||
break;
|
||||
case 'night_mode':
|
||||
// 由 Switch 处理
|
||||
break;
|
||||
case 'system_settings':
|
||||
// 跳转到系统设置页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SystemSettingsPage(),
|
||||
),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
debugPrint('点击菜单: ${item.title}');
|
||||
// TODO: 根据 ID 跳转到对应页面
|
||||
}
|
||||
}
|
||||
|
||||
/// 显示清除缓存对话框
|
||||
void _showClearCacheDialog(BuildContext context, MyCubit cubit) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('清除缓存'),
|
||||
content: const Text('确定要清除所有缓存数据吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
cubit.clearCache();
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
284
lib/features/v2/my/presentation/pages/system_settings_page.dart
Normal file
284
lib/features/v2/my/presentation/pages/system_settings_page.dart
Normal file
@@ -0,0 +1,284 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/locale_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
|
||||
/// 系统设置综合页面
|
||||
class SystemSettingsPage extends StatefulWidget {
|
||||
const SystemSettingsPage({super.key});
|
||||
|
||||
@override
|
||||
State<SystemSettingsPage> createState() => _SystemSettingsPageState();
|
||||
}
|
||||
|
||||
class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F6F8),
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back, color: Color(0xFF1D2129)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('my.settings'),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Tab 设置
|
||||
_buildTabSettingsSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 语言设置
|
||||
_buildLanguageSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 退出登录
|
||||
_buildLogoutButton(context),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Tab 设置
|
||||
Widget _buildTabSettingsSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Tab 设置',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BlocBuilder<TabConfigCubit, dynamic>(
|
||||
builder: (context, state) {
|
||||
if (state.runtimeType.toString() != 'TabConfigLoaded') {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final tabs = state.config.items;
|
||||
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: tabs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final tab = tabs[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
tab.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: tab.isEnabled,
|
||||
onChanged: (value) {
|
||||
context.read<TabConfigCubit>().toggleTab(tab.id);
|
||||
},
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 语言设置
|
||||
Widget _buildLanguageSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).translate('my.language'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BlocBuilder<LocaleCubit, Locale>(
|
||||
builder: (context, locale) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildLanguageOption(
|
||||
AppLocalizations.of(context).translate('my.chinese'),
|
||||
'zh',
|
||||
locale.languageCode == 'zh',
|
||||
() => context.read<LocaleCubit>().setLocale(const Locale('zh', 'CN')),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildLanguageOption(
|
||||
AppLocalizations.of(context).translate('my.english'),
|
||||
'en',
|
||||
locale.languageCode == 'en',
|
||||
() => context.read<LocaleCubit>().setLocale(const Locale('en', 'US')),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLanguageOption(String label, String code, bool isSelected, VoidCallback onTap) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? const Color(0xFF165DFF).withOpacity(0.1) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: isSelected ? const Color(0xFF165DFF) : const Color(0xFFE5E6EB),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: isSelected ? const Color(0xFF165DFF) : const Color(0xFF1D2129),
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
const Icon(
|
||||
Icons.check_circle,
|
||||
color: Color(0xFF165DFF),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 退出登录按钮
|
||||
Widget _buildLogoutButton(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
_showLogoutDialog(context);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Color(0x0D000000),
|
||||
blurRadius: 8,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('login.logout'),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFFF53F3F),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示退出登录确认对话框
|
||||
void _showLogoutDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(AppLocalizations.of(context).translate('login.logout')),
|
||||
content: const Text('确定要退出登录吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
// 执行退出登录逻辑
|
||||
await GetIt.I<UserStorage>().deleteUser();
|
||||
GetIt.I<AuthCubit>().logout();
|
||||
context.go(RoutePaths.login);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
13
lib/features/v2/my/presentation/routes/my_routes.dart
Normal file
13
lib/features/v2/my/presentation/routes/my_routes.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/my_page.dart';
|
||||
|
||||
/// 我的页面路由配置
|
||||
class MyRoutes {
|
||||
static List<RouteBase> get routes => [
|
||||
GoRoute(
|
||||
path: 'my',
|
||||
name: 'my',
|
||||
builder: (context, state) => const MyPage(),
|
||||
),
|
||||
];
|
||||
}
|
||||
58
lib/features/v2/my/presentation/states/my_state.dart
Normal file
58
lib/features/v2/my/presentation/states/my_state.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||||
|
||||
/// 我的页面状态基类
|
||||
abstract class MyState extends Equatable {
|
||||
const MyState();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
/// 初始状态
|
||||
class MyInitial extends MyState {}
|
||||
|
||||
/// 加载中状态
|
||||
class MyLoading extends MyState {}
|
||||
|
||||
/// 加载成功状态
|
||||
class MyLoaded extends MyState {
|
||||
const MyLoaded({
|
||||
required this.userProfile,
|
||||
required this.menuItems,
|
||||
this.isNightMode = false,
|
||||
this.cacheSize = '1.26 GB',
|
||||
});
|
||||
|
||||
final UserProfileEntity userProfile;
|
||||
final List<MenuItemEntity> menuItems;
|
||||
final bool isNightMode;
|
||||
final String cacheSize;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [userProfile, menuItems, isNightMode, cacheSize];
|
||||
|
||||
MyLoaded copyWith({
|
||||
UserProfileEntity? userProfile,
|
||||
List<MenuItemEntity>? menuItems,
|
||||
bool? isNightMode,
|
||||
String? cacheSize,
|
||||
}) {
|
||||
return MyLoaded(
|
||||
userProfile: userProfile ?? this.userProfile,
|
||||
menuItems: menuItems ?? this.menuItems,
|
||||
isNightMode: isNightMode ?? this.isNightMode,
|
||||
cacheSize: cacheSize ?? this.cacheSize,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 加载失败状态
|
||||
class MyError extends MyState {
|
||||
const MyError(this.message);
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [message];
|
||||
}
|
||||
118
lib/features/v2/my/presentation/widgets/menu_item_card.dart
Normal file
118
lib/features/v2/my/presentation/widgets/menu_item_card.dart
Normal file
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||||
|
||||
/// 菜单项卡片组件(100% 还原设计稿)
|
||||
class MenuItemCard extends StatelessWidget {
|
||||
const MenuItemCard({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.onTap,
|
||||
this.onSwitchChanged,
|
||||
});
|
||||
|
||||
final MenuItemEntity item;
|
||||
final VoidCallback? onTap;
|
||||
final ValueChanged<bool>? onSwitchChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 56,
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// 图标
|
||||
Icon(
|
||||
_getIconData(item.icon),
|
||||
size: 20,
|
||||
color: const Color(0xFF4E5969),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// 标题
|
||||
Expanded(
|
||||
child: Text(
|
||||
item.title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFF1D2129),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 副标题或开关
|
||||
if (item.subTitle != null) ...[
|
||||
Text(
|
||||
item.subTitle!,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
if (item.hasSwitch) ...[
|
||||
Transform.scale(
|
||||
scale: 0.85,
|
||||
child: Switch(
|
||||
value: item.switchValue,
|
||||
onChanged: onSwitchChanged,
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
activeTrackColor: const Color(0xFF165DFF).withOpacity(0.3),
|
||||
inactiveThumbColor: const Color(0xFFC9CDD4),
|
||||
inactiveTrackColor: const Color(0xFFE5E6EB),
|
||||
),
|
||||
),
|
||||
],
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: const Color(0xFFC9CDD4),
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 分割线
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48),
|
||||
child: Divider(
|
||||
height: 1,
|
||||
thickness: 0.5,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 根据字符串获取 IconData
|
||||
IconData _getIconData(String iconName) {
|
||||
switch (iconName) {
|
||||
case 'person':
|
||||
return Icons.person_outline;
|
||||
case 'notifications':
|
||||
return Icons.notifications_outlined;
|
||||
case 'cloud_download':
|
||||
return Icons.cloud_download_outlined;
|
||||
case 'dark_mode':
|
||||
return Icons.dark_mode_outlined;
|
||||
case 'settings':
|
||||
return Icons.settings_outlined;
|
||||
case 'help':
|
||||
return Icons.help_outline;
|
||||
case 'info':
|
||||
return Icons.info_outline;
|
||||
default:
|
||||
return Icons.label_outline;
|
||||
}
|
||||
}
|
||||
}
|
||||
122
lib/features/v2/my/presentation/widgets/quick_action_card.dart
Normal file
122
lib/features/v2/my/presentation/widgets/quick_action_card.dart
Normal file
@@ -0,0 +1,122 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/constants/my_constants.dart';
|
||||
|
||||
/// 快捷入口卡片组件(我的消息、我的收藏、我的工单)
|
||||
class QuickActionCard extends StatelessWidget {
|
||||
const QuickActionCard({
|
||||
super.key,
|
||||
required this.onMessageTap,
|
||||
required this.onFavoriteTap,
|
||||
required this.onWorkOrderTap,
|
||||
});
|
||||
|
||||
final VoidCallback onMessageTap;
|
||||
final VoidCallback onFavoriteTap;
|
||||
final VoidCallback onWorkOrderTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0x0D000000),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
// 我的消息
|
||||
_buildQuickActionItem(
|
||||
icon: Icons.notifications_outlined,
|
||||
label: '我的消息',
|
||||
onTap: onMessageTap,
|
||||
showBadge: true,
|
||||
),
|
||||
// 分割线
|
||||
Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
),
|
||||
// 我的收藏
|
||||
_buildQuickActionItem(
|
||||
icon: Icons.favorite_border,
|
||||
label: '我的收藏',
|
||||
onTap: onFavoriteTap,
|
||||
),
|
||||
// 分割线
|
||||
Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
),
|
||||
// 我的工单
|
||||
_buildQuickActionItem(
|
||||
icon: Icons.assignment_outlined,
|
||||
label: '我的工单',
|
||||
onTap: onWorkOrderTap,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildQuickActionItem({
|
||||
required IconData icon,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
bool showBadge = false,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: SizedBox(
|
||||
width: 80,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 24,
|
||||
color: MyColors.primary,
|
||||
),
|
||||
if (showBadge)
|
||||
Positioned(
|
||||
right: -4,
|
||||
top: -4,
|
||||
child: Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFFF4D4F),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: MyColors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/constants/my_constants.dart';
|
||||
|
||||
/// 用户信息卡片组件(100% 还原设计稿)
|
||||
class UserProfileCard extends StatelessWidget {
|
||||
const UserProfileCard({
|
||||
super.key,
|
||||
required this.name,
|
||||
required this.role,
|
||||
this.onTap,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String role;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(20, 70, 20, 50),
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
Color(0xFF165DFF),
|
||||
Color(0xFF0E42CC),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// 头像
|
||||
Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: ClipOval(
|
||||
child: Image.asset(
|
||||
'assets/images/app_logo.png',
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
child: Icon(
|
||||
Icons.person,
|
||||
size: 32,
|
||||
color: const Color(0xFF165DFF),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
// 用户信息
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
name,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
role,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withOpacity(0.85),
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 箭头
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: Colors.white.withOpacity(0.9),
|
||||
size: 24,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user