- 新增管理员角色(手机号12345678910),管理员可增删医生、查看患者 - 注册页重构:去掉角色选择+审核码,改为选医生+填姓名 - 医生端点按DoctorId过滤患者,Patient↔Doctor关系建立 - Doctor/DoctorProfile/User实体新增关联字段 - JSON循环引用修复(IgnoreCycles) - /api/doctors改为公开接口 - 登录闪屏修复+原生Android启动页 - 输入框全局白底+灰框 - 蓝牙重连同步修复 - Web端(doctor_web+health_app/web)全部删除 - 全局UI改版:白底企业风,新配色和组件系统 - 新品牌图标和启动图
471 lines
13 KiB
Dart
471 lines
13 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../core/app_colors.dart';
|
|
import '../core/app_theme.dart';
|
|
import '../core/navigation_provider.dart';
|
|
import '../providers/auth_provider.dart';
|
|
import '../providers/data_providers.dart';
|
|
import 'service_package_card.dart';
|
|
|
|
class HealthDrawer extends ConsumerWidget {
|
|
const HealthDrawer({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final auth = ref.watch(authProvider);
|
|
final user = auth.user;
|
|
final latestHealth = ref.watch(latestHealthProvider);
|
|
|
|
return Drawer(
|
|
width: MediaQuery.of(context).size.width * 0.85,
|
|
child: Container(
|
|
color: AppColors.background,
|
|
child: SafeArea(
|
|
child: ListView(
|
|
padding: const EdgeInsets.fromLTRB(14, 14, 14, 18),
|
|
children: [
|
|
_ProfileCard(user: user, ref: ref),
|
|
const SizedBox(height: 12),
|
|
_QuickEntryGrid(ref: ref),
|
|
const SizedBox(height: 12),
|
|
_HealthSection(latestHealth: latestHealth, ref: ref),
|
|
const SizedBox(height: 12),
|
|
_FeatureSection(ref: ref),
|
|
const SizedBox(height: 12),
|
|
_Panel(
|
|
title: 'VIP服务',
|
|
icon: Icons.workspace_premium_rounded,
|
|
child: const ServicePackageCard(compact: true),
|
|
),
|
|
const SizedBox(height: 12),
|
|
_Panel(
|
|
title: '保险',
|
|
icon: Icons.shield_rounded,
|
|
child: const Padding(
|
|
padding: EdgeInsets.fromLTRB(16, 4, 16, 16),
|
|
child: Text(
|
|
'即将上线,敬请期待',
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ProfileCard extends StatelessWidget {
|
|
final dynamic user;
|
|
final WidgetRef ref;
|
|
const _ProfileCard({required this.user, required this.ref});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final name = user?.name ?? '未设置昵称';
|
|
final phone = user?.phone ?? '未登录';
|
|
return Container(
|
|
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: [
|
|
GestureDetector(
|
|
onTap: () => pushRoute(ref, 'profile'),
|
|
child: Container(
|
|
width: 52,
|
|
height: 52,
|
|
decoration: BoxDecoration(
|
|
gradient: AppColors.primaryGradient,
|
|
borderRadius: BorderRadius.circular(18),
|
|
),
|
|
child: const Icon(
|
|
Icons.person_outline,
|
|
color: Colors.white,
|
|
size: 28,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
name,
|
|
style: const TextStyle(
|
|
fontSize: 17,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
const SizedBox(height: 3),
|
|
Text(
|
|
phone,
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
IconButton(
|
|
onPressed: () => pushRoute(ref, 'settings'),
|
|
icon: const Icon(
|
|
Icons.settings_outlined,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _QuickEntryGrid extends StatelessWidget {
|
|
final WidgetRef ref;
|
|
const _QuickEntryGrid({required this.ref});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
children: [
|
|
Expanded(
|
|
child: _QuickEntry(
|
|
icon: Icons.bluetooth_rounded,
|
|
label: '蓝牙设备',
|
|
onTap: () => pushRoute(ref, 'devices'),
|
|
),
|
|
),
|
|
const SizedBox(width: 10),
|
|
Expanded(
|
|
child: _QuickEntry(
|
|
icon: Icons.folder_outlined,
|
|
label: '健康档案',
|
|
onTap: () => pushRoute(ref, 'healthArchive'),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _QuickEntry extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
const _QuickEntry({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppColors.border),
|
|
boxShadow: AppColors.cardShadowLight,
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Icon(icon, size: 25, color: AppColors.primary),
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
label,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w700,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _HealthSection extends StatelessWidget {
|
|
final AsyncValue<Map<String, dynamic>> latestHealth;
|
|
final WidgetRef ref;
|
|
const _HealthSection({required this.latestHealth, required this.ref});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return _Panel(
|
|
title: '健康仪表盘',
|
|
icon: Icons.dashboard_rounded,
|
|
trailing: GestureDetector(
|
|
onTap: () => pushRoute(ref, 'trend'),
|
|
child: const Text(
|
|
'详情',
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
color: AppColors.primary,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
child: latestHealth.when(
|
|
data: (data) => Padding(
|
|
padding: const EdgeInsets.fromLTRB(12, 4, 12, 14),
|
|
child: Row(
|
|
children: [
|
|
_MiniMetric(
|
|
Icons.favorite_rounded,
|
|
'血压',
|
|
_bpText(data['BloodPressure']),
|
|
() =>
|
|
pushRoute(ref, 'trend', params: {'type': 'blood_pressure'}),
|
|
),
|
|
_MiniMetric(
|
|
Icons.monitor_heart_outlined,
|
|
'心率',
|
|
_metricVal(data['HeartRate']),
|
|
() => pushRoute(ref, 'trend', params: {'type': 'heart_rate'}),
|
|
),
|
|
_MiniMetric(
|
|
Icons.bloodtype_outlined,
|
|
'血糖',
|
|
_metricVal(data['Glucose']),
|
|
() => pushRoute(ref, 'trend', params: {'type': 'glucose'}),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
loading: () => const Padding(
|
|
padding: EdgeInsets.all(20),
|
|
child: Center(child: CircularProgressIndicator(strokeWidth: 2)),
|
|
),
|
|
error: (_, __) => Padding(
|
|
padding: const EdgeInsets.fromLTRB(12, 4, 12, 14),
|
|
child: Row(
|
|
children: [
|
|
_MiniMetric(Icons.favorite_rounded, '血压', '--'),
|
|
_MiniMetric(Icons.monitor_heart_outlined, '心率', '--'),
|
|
_MiniMetric(Icons.bloodtype_outlined, '血糖', '--'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
String _bpText(dynamic bp) {
|
|
if (bp is Map)
|
|
return '${bp['systolic'] ?? '--'}/${bp['diastolic'] ?? '--'}';
|
|
return '--';
|
|
}
|
|
|
|
String _metricVal(dynamic val) {
|
|
if (val == null) return '--';
|
|
if (val is num) return val.toStringAsFixed(val is double ? 1 : 0);
|
|
if (val is Map) return val['value']?.toString() ?? '--';
|
|
return '--';
|
|
}
|
|
}
|
|
|
|
class _FeatureSection extends StatelessWidget {
|
|
final WidgetRef ref;
|
|
const _FeatureSection({required this.ref});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return _Panel(
|
|
title: '功能',
|
|
icon: Icons.apps_rounded,
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(12, 4, 12, 14),
|
|
child: Wrap(
|
|
spacing: 8,
|
|
runSpacing: 8,
|
|
children: [
|
|
_FeatureChip(
|
|
icon: Icons.description_outlined,
|
|
label: '报告管理',
|
|
onTap: () => pushRoute(ref, 'reports'),
|
|
),
|
|
_FeatureChip(
|
|
icon: Icons.calendar_today_outlined,
|
|
label: '健康日历',
|
|
onTap: () => pushRoute(ref, 'calendar'),
|
|
),
|
|
_FeatureChip(
|
|
icon: Icons.restaurant_outlined,
|
|
label: '饮食记录',
|
|
onTap: () => pushRoute(ref, 'dietRecords'),
|
|
),
|
|
_FeatureChip(
|
|
icon: Icons.event_note_outlined,
|
|
label: '复查随访',
|
|
onTap: () => pushRoute(ref, 'followups'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Panel extends StatelessWidget {
|
|
final String title;
|
|
final IconData icon;
|
|
final Widget child;
|
|
final Widget? trailing;
|
|
const _Panel({
|
|
required this.title,
|
|
required this.icon,
|
|
required this.child,
|
|
this.trailing,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(AppTheme.rLg),
|
|
border: Border.all(color: AppColors.border),
|
|
boxShadow: AppColors.cardShadowLight,
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(14, 14, 14, 6),
|
|
child: Row(
|
|
children: [
|
|
Container(
|
|
width: 30,
|
|
height: 30,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.iconBg,
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: Icon(icon, size: 17, color: AppColors.primary),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
const Spacer(),
|
|
if (trailing != null) trailing!,
|
|
],
|
|
),
|
|
),
|
|
child,
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _MiniMetric extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final String value;
|
|
final VoidCallback? onTap;
|
|
const _MiniMetric(this.icon, this.label, this.value, [this.onTap]);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 3),
|
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.cardInner,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: AppColors.borderLight),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 22, color: AppColors.primary),
|
|
const SizedBox(height: 5),
|
|
Text(
|
|
value,
|
|
style: const TextStyle(
|
|
fontSize: 15,
|
|
fontWeight: FontWeight.w800,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
Text(
|
|
label,
|
|
style: const TextStyle(fontSize: 11, color: AppColors.textHint),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FeatureChip extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final VoidCallback onTap;
|
|
const _FeatureChip({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
width: 92,
|
|
padding: const EdgeInsets.symmetric(vertical: 11),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.cardInner,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: AppColors.borderLight),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 21, color: AppColors.primary),
|
|
const SizedBox(height: 5),
|
|
Text(
|
|
label,
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w700,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|