- 新增管理员角色(手机号12345678910),管理员可增删医生、查看患者 - 注册页重构:去掉角色选择+审核码,改为选医生+填姓名 - 医生端点按DoctorId过滤患者,Patient↔Doctor关系建立 - Doctor/DoctorProfile/User实体新增关联字段 - JSON循环引用修复(IgnoreCycles) - /api/doctors改为公开接口 - 登录闪屏修复+原生Android启动页 - 输入框全局白底+灰框 - 蓝牙重连同步修复 - Web端(doctor_web+health_app/web)全部删除 - 全局UI改版:白底企业风,新配色和组件系统 - 新品牌图标和启动图
173 lines
5.6 KiB
Dart
173 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../core/app_colors.dart';
|
|
import '../core/navigation_provider.dart';
|
|
import '../pages/admin/admin_home_page.dart' show adminPageProvider;
|
|
import '../providers/auth_provider.dart';
|
|
|
|
class AdminDrawer extends ConsumerWidget {
|
|
const AdminDrawer({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final currentPage = ref.watch(adminPageProvider);
|
|
|
|
return Drawer(
|
|
width: MediaQuery.of(context).size.width * 0.8,
|
|
child: Container(
|
|
color: AppColors.background,
|
|
child: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
margin: const EdgeInsets.all(14),
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20),
|
|
border: Border.all(color: AppColors.border),
|
|
boxShadow: AppColors.cardShadowLight,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: 52,
|
|
height: 52,
|
|
decoration: BoxDecoration(
|
|
gradient: AppColors.primaryGradient,
|
|
borderRadius: BorderRadius.circular(18),
|
|
),
|
|
child: const Icon(
|
|
Icons.admin_panel_settings,
|
|
size: 28,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
const Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'系统管理员',
|
|
style: TextStyle(
|
|
fontSize: 17,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
SizedBox(height: 3),
|
|
Text(
|
|
'医生与患者管理',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
_MenuItem(
|
|
icon: Icons.local_hospital,
|
|
label: '医生管理',
|
|
selected: currentPage == 'doctors',
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
ref.read(adminPageProvider.notifier).set('doctors');
|
|
},
|
|
),
|
|
_MenuItem(
|
|
icon: Icons.people_outline,
|
|
label: '患者列表',
|
|
selected: currentPage == 'patients',
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
ref.read(adminPageProvider.notifier).set('patients');
|
|
},
|
|
),
|
|
const Spacer(),
|
|
const Divider(height: 1, color: AppColors.divider),
|
|
const SizedBox(height: 8),
|
|
_MenuItem(
|
|
icon: Icons.logout,
|
|
label: '退出登录',
|
|
danger: true,
|
|
onTap: () async {
|
|
Navigator.pop(context);
|
|
await ref.read(authProvider.notifier).logout();
|
|
goRoute(ref, 'login');
|
|
},
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MenuItem extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
final bool selected;
|
|
final bool danger;
|
|
const _MenuItem({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.selected = false,
|
|
this.danger = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final color = danger
|
|
? AppColors.error
|
|
: selected
|
|
? AppColors.primary
|
|
: AppColors.textPrimary;
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
|
|
child: Material(
|
|
color: selected ? AppColors.primarySoft : Colors.white,
|
|
borderRadius: BorderRadius.circular(14),
|
|
child: InkWell(
|
|
borderRadius: BorderRadius.circular(14),
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(14),
|
|
border: Border.all(
|
|
color: selected ? AppColors.primaryLight : AppColors.border,
|
|
),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(icon, color: color, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w700,
|
|
color: color,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|