feat: 饮食记录逻辑重构 + 通知管理分隔线修复 + 多页面 UI 调整
- 饮食: 新增 DietCommentaryPolicy + diet_record_logic, 饮食记录逻辑抽取复用 - 通知管理: 分隔线改为仿通知中心样式, 跳过图标区域只留文字下方 - 侧边栏: 对话记录操作栏浮层修复 + 常用功能间距收紧 - 智能体: 欢迎卡片去 400ms 延迟 + 胶囊去阴影 - 后端: AI 会话仓库新增方法 + 饮食评论策略 + 健康记录规则调整 - 其他: api_client IP 适配 + 多页面 UI 微调 + 新增测试
This commit is contained in:
@@ -4,6 +4,7 @@ import '../../core/app_colors.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
import '../../providers/data_providers.dart';
|
||||
import '../../widgets/app_gradient_widgets.dart';
|
||||
|
||||
class LoginPage extends ConsumerStatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
@@ -13,6 +14,11 @@ class LoginPage extends ConsumerStatefulWidget {
|
||||
|
||||
class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
static const _loginBg = 'assets/branding/login_background_v1.png';
|
||||
static const _loginActionGradient = AppColors.primaryGradient;
|
||||
|
||||
void _openStaticText(String type) {
|
||||
pushRoute(ref, 'staticText', params: {'type': type});
|
||||
}
|
||||
|
||||
final _phoneCtrl = TextEditingController();
|
||||
final _codeCtrl = TextEditingController();
|
||||
@@ -174,23 +180,51 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
const SizedBox(height: 18),
|
||||
RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: const TextSpan(
|
||||
style: TextStyle(
|
||||
text: TextSpan(
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
height: 1.55,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: '请阅读并同意'),
|
||||
TextSpan(
|
||||
text: '《服务协议》',
|
||||
style: TextStyle(color: AppColors.primary),
|
||||
const TextSpan(text: '请阅读并同意'),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.baseline,
|
||||
baseline: TextBaseline.alphabetic,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(ctx, false);
|
||||
_openStaticText('terms');
|
||||
},
|
||||
child: AppGradientText(
|
||||
'《服务协议》',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
height: 1.55,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
TextSpan(text: '和'),
|
||||
TextSpan(
|
||||
text: '《隐私政策》',
|
||||
style: TextStyle(color: AppColors.primary),
|
||||
const TextSpan(text: '和'),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.baseline,
|
||||
baseline: TextBaseline.alphabetic,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(ctx, false);
|
||||
_openStaticText('privacy');
|
||||
},
|
||||
child: AppGradientText(
|
||||
'《隐私政策》',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
height: 1.55,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -199,26 +233,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: OutlinedButton(
|
||||
onPressed: () => Navigator.pop(ctx, false),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: AppColors.primary,
|
||||
side: BorderSide(
|
||||
color: AppColors.primary.withValues(alpha: 0.62),
|
||||
width: 1.2,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
child: const Text('不同意'),
|
||||
),
|
||||
child: AppGradientOutlineButton(
|
||||
label: '不同意',
|
||||
onTap: () => Navigator.pop(ctx, false),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
@@ -229,7 +246,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.doctorGradient,
|
||||
gradient: _loginActionGradient,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
boxShadow: AppColors.buttonShadow,
|
||||
),
|
||||
@@ -328,9 +345,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
),
|
||||
),
|
||||
trailing: _selectedDoctorId == d['id']?.toString()
|
||||
? const Icon(
|
||||
Icons.check_circle,
|
||||
color: AppColors.primary,
|
||||
? const AppGradientIcon(
|
||||
icon: Icons.check_circle,
|
||||
size: 22,
|
||||
)
|
||||
: null,
|
||||
onTap: () {
|
||||
@@ -368,6 +385,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Colors.white,
|
||||
body: Stack(
|
||||
children: [
|
||||
@@ -475,6 +493,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
agreed: _agreed,
|
||||
onTap: () =>
|
||||
setState(() => _agreed = !_agreed),
|
||||
onTermsTap: () => _openStaticText('terms'),
|
||||
onPrivacyTap: () =>
|
||||
_openStaticText('privacy'),
|
||||
),
|
||||
if (_error != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
@@ -496,13 +517,13 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
_error = null;
|
||||
_successMsg = null;
|
||||
}),
|
||||
child: Text(
|
||||
_isLogin ? '没有账号?去注册' : '已有账号?去登录',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: AppColors.primary,
|
||||
child: Center(
|
||||
child: AppGradientText(
|
||||
_isLogin ? '没有账号?去注册' : '已有账号?去登录',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -645,7 +666,7 @@ class _TextField extends StatelessWidget {
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
borderSide: const BorderSide(color: AppColors.primary, width: 1.2),
|
||||
borderSide: const BorderSide(color: AppColors.auraIndigo, width: 1.2),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -657,10 +678,10 @@ class _GradientPrefixIcon extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ShaderMask(
|
||||
shaderCallback: AppColors.doctorGradient.createShader,
|
||||
blendMode: BlendMode.srcIn,
|
||||
child: Icon(icon, size: 23, color: Colors.white),
|
||||
return AppGradientIcon(
|
||||
icon: icon,
|
||||
size: 23,
|
||||
gradient: _LoginPageState._loginActionGradient,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -730,7 +751,7 @@ class _SmsButton extends StatelessWidget {
|
||||
height: 50,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
gradient: disabled ? null : AppColors.doctorGradient,
|
||||
gradient: disabled ? null : _LoginPageState._loginActionGradient,
|
||||
color: disabled ? AppColors.cardInner : null,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
@@ -757,64 +778,67 @@ class _SmsButton extends StatelessWidget {
|
||||
class _Agreement extends StatelessWidget {
|
||||
final bool agreed;
|
||||
final VoidCallback onTap;
|
||||
const _Agreement({required this.agreed, required this.onTap});
|
||||
final VoidCallback onTermsTap;
|
||||
final VoidCallback onPrivacyTap;
|
||||
const _Agreement({
|
||||
required this.agreed,
|
||||
required this.onTap,
|
||||
required this.onTermsTap,
|
||||
required this.onPrivacyTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
const textStyle = TextStyle(fontSize: 13, color: AppColors.textHint);
|
||||
const linkStyle = TextStyle(fontSize: 13, fontWeight: FontWeight.w700);
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(
|
||||
width: 18,
|
||||
height: 18,
|
||||
margin: const EdgeInsets.only(right: 7, top: 1),
|
||||
margin: const EdgeInsets.only(right: 7),
|
||||
decoration: BoxDecoration(
|
||||
color: agreed ? AppColors.primary : Colors.white,
|
||||
gradient: agreed ? _LoginPageState._loginActionGradient : null,
|
||||
color: agreed ? null : Colors.white,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: agreed ? AppColors.primary : AppColors.border,
|
||||
color: agreed ? Colors.transparent : AppColors.border,
|
||||
),
|
||||
),
|
||||
child: agreed
|
||||
? const Icon(Icons.check, size: 13, color: Colors.white)
|
||||
: null,
|
||||
),
|
||||
Flexible(
|
||||
child: RichText(
|
||||
text: const TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '已阅读并同意',
|
||||
style: TextStyle(fontSize: 12, color: AppColors.textHint),
|
||||
),
|
||||
TextSpan(
|
||||
text: '《服务协议》',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '和',
|
||||
style: TextStyle(fontSize: 12, color: AppColors.textHint),
|
||||
),
|
||||
TextSpan(
|
||||
text: '《隐私政策》',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.primary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const Text('已阅读并同意', style: textStyle),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: onTermsTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const AppGradientText('《服务协议》', style: linkStyle),
|
||||
),
|
||||
const Text('和', style: textStyle),
|
||||
GestureDetector(
|
||||
onTap: onPrivacyTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const AppGradientText('《隐私政策》', style: linkStyle),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -882,7 +906,7 @@ class _PrimaryButton extends StatelessWidget {
|
||||
height: 52,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.doctorGradient,
|
||||
gradient: _LoginPageState._loginActionGradient,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: AppColors.buttonShadow,
|
||||
),
|
||||
|
||||
@@ -814,6 +814,7 @@ class _TrendPageState extends ConsumerState<TrendPage> {
|
||||
_filtered.removeWhere((x) => x['id']?.toString() == id);
|
||||
_selectedIdx = null;
|
||||
});
|
||||
ref.invalidate(latestHealthProvider);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
||||
@@ -685,12 +685,12 @@ class _EmptyDevices extends StatelessWidget {
|
||||
width: 72,
|
||||
height: 72,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEFF6FF),
|
||||
color: AppColors.deviceLight,
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.bluetooth_disabled_rounded,
|
||||
color: Color(0xFF2563EB),
|
||||
color: AppColors.device,
|
||||
size: 36,
|
||||
),
|
||||
),
|
||||
@@ -747,7 +747,7 @@ class _ScanIndicator extends StatelessWidget {
|
||||
height: 78 * animation.value,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.10),
|
||||
color: AppColors.device.withValues(alpha: 0.10),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -758,7 +758,7 @@ class _ScanIndicator extends StatelessWidget {
|
||||
height: 64 * animation.value,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.18),
|
||||
color: AppColors.device.withValues(alpha: 0.18),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -767,11 +767,11 @@ class _ScanIndicator extends StatelessWidget {
|
||||
width: 58,
|
||||
height: 58,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF2563EB),
|
||||
color: AppColors.device,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF2563EB).withValues(alpha: 0.24),
|
||||
color: AppColors.device.withValues(alpha: 0.24),
|
||||
blurRadius: 18,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
|
||||
@@ -439,15 +439,13 @@ class _DeviceResultTile extends StatelessWidget {
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary.withValues(alpha: 0.10),
|
||||
color: AppColors.deviceLight,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
color: AppColors.primary.withValues(alpha: 0.10),
|
||||
),
|
||||
border: Border.all(color: AppColors.deviceBorder),
|
||||
),
|
||||
child: Icon(
|
||||
type?.icon ?? Icons.bluetooth_rounded,
|
||||
color: AppColors.primary,
|
||||
color: AppColors.device,
|
||||
size: 25,
|
||||
),
|
||||
),
|
||||
@@ -483,6 +481,10 @@ class _DeviceResultTile extends StatelessWidget {
|
||||
child: FilledButton(
|
||||
onPressed: connecting ? null : onConnect,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: AppColors.device,
|
||||
foregroundColor: Colors.white,
|
||||
disabledBackgroundColor: AppColors.cardInner,
|
||||
disabledForegroundColor: AppColors.textHint,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
@@ -526,7 +528,7 @@ class _ScanPulse extends StatelessWidget {
|
||||
height: 78 * animation.value,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: AppColors.primary.withValues(alpha: 0.08),
|
||||
color: AppColors.device.withValues(alpha: 0.08),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -541,7 +543,7 @@ class _ScanPulse extends StatelessWidget {
|
||||
child: const Icon(
|
||||
Icons.bluetooth_searching_rounded,
|
||||
size: 32,
|
||||
color: AppColors.primary,
|
||||
color: AppColors.device,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
15
health_app/lib/pages/diet/diet_record_logic.dart
Normal file
15
health_app/lib/pages/diet/diet_record_logic.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
List<DateTime> recentDietDates(DateTime now, {int count = 7}) {
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
return List.generate(
|
||||
count,
|
||||
(index) => today.subtract(Duration(days: count - 1 - index)),
|
||||
);
|
||||
}
|
||||
|
||||
bool isSavableFood({
|
||||
required String name,
|
||||
required String portion,
|
||||
required int calories,
|
||||
}) {
|
||||
return name.trim().isNotEmpty && portion.trim().isNotEmpty && calories > 0;
|
||||
}
|
||||
@@ -263,10 +263,10 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
const SizedBox(height: 9),
|
||||
Text(
|
||||
info.$2,
|
||||
style: AppTextStyles.chatTitle.copyWith(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
style: AppTextStyles.chatTitle.copyWith(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
@@ -473,6 +473,11 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
backendType != 'exercise');
|
||||
final isExercise = backendType == 'exercise';
|
||||
final isHealth = !isMedication && !isExercise;
|
||||
final visual = isMedication
|
||||
? AppModuleVisuals.medication
|
||||
: isExercise
|
||||
? AppModuleVisuals.exercise
|
||||
: AppModuleVisuals.health;
|
||||
|
||||
// 根据类型获取显示字段
|
||||
String title = '数据确认';
|
||||
@@ -585,7 +590,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF6366F1).withValues(alpha: 0.10),
|
||||
color: visual.color.withValues(alpha: 0.10),
|
||||
blurRadius: 28,
|
||||
offset: const Offset(0, 14),
|
||||
),
|
||||
@@ -604,11 +609,11 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 18),
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [Color(0xFFFFFFFF), Color(0xFFF7F4FF)],
|
||||
colors: [Colors.white, visual.lightColor],
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -618,11 +623,11 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.actionOutlineGradient,
|
||||
gradient: visual.gradient,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.auraIndigo.withValues(alpha: 0.18),
|
||||
color: visual.color.withValues(alpha: 0.18),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
@@ -674,7 +679,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(1.4),
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.actionOutlineGradient,
|
||||
gradient: visual.gradient,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Container(
|
||||
@@ -691,7 +696,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
width: 68,
|
||||
height: 68,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.lightGradient,
|
||||
color: visual.lightColor,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
child: Center(
|
||||
@@ -699,14 +704,14 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
? Icon(
|
||||
_getMetricIconData(backendType),
|
||||
size: 34,
|
||||
color: AppColors.primaryDark,
|
||||
color: visual.color,
|
||||
)
|
||||
: Icon(
|
||||
isMedication
|
||||
? Icons.medication_liquid_outlined
|
||||
: LucideIcons.footprints,
|
||||
size: 36,
|
||||
color: AppColors.iconColor,
|
||||
color: visual.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -745,7 +750,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
fontSize: 19,
|
||||
color: abnormal
|
||||
? AppColors.error
|
||||
: AppColors.iconColor,
|
||||
: visual.color,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
@@ -849,11 +854,11 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
height: 56,
|
||||
padding: const EdgeInsets.all(1.4),
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.actionOutlineGradient,
|
||||
gradient: visual.gradient,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.auraIndigo.withValues(alpha: 0.18),
|
||||
color: visual.color.withValues(alpha: 0.18),
|
||||
blurRadius: 18,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
@@ -913,7 +918,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.actionOutlineGradient,
|
||||
gradient: visual.gradient,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
@@ -1268,7 +1273,6 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
/// 处理 AI 回复里的 markdown 链接点击:
|
||||
/// - app://diet → 触发拍照/相册选择,跳到饮食拍照流程
|
||||
/// - app://report → 跳到报告列表(用户可在那里上传新报告)
|
||||
@@ -1504,27 +1508,58 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
wtText == null;
|
||||
|
||||
// ── 多指标异常检测 ──
|
||||
// 优先使用后端保存时计算出的 IsAbnormal,兜底规则必须和后端 HealthRecordRules 保持一致。
|
||||
final abnormals = <String>[];
|
||||
if (bp is Map && bp['systolic'] is int) {
|
||||
final s = bp['systolic'] as int;
|
||||
final d = bp['diastolic'] is int ? bp['diastolic'] as int : 0;
|
||||
if (s >= 140 || d >= 90) abnormals.add('血压 $s/$d 偏高');
|
||||
final bpAbnormal = _recordIsAbnormal(
|
||||
bp,
|
||||
fallback: () {
|
||||
if (bp is! Map) return false;
|
||||
final s = _numValue(bp['systolic'] ?? bp['Systolic']);
|
||||
final d = _numValue(bp['diastolic'] ?? bp['Diastolic']);
|
||||
return s != null &&
|
||||
d != null &&
|
||||
(s >= 140 || d >= 90 || s <= 89 || d <= 59);
|
||||
},
|
||||
);
|
||||
if (bpAbnormal && bp is Map) {
|
||||
final s = _numValue(bp['systolic'] ?? bp['Systolic']);
|
||||
final d = _numValue(bp['diastolic'] ?? bp['Diastolic']);
|
||||
abnormals.add(
|
||||
'血压 ${s?.toStringAsFixed(0) ?? '--'}/${d?.toStringAsFixed(0) ?? '--'} 异常',
|
||||
);
|
||||
}
|
||||
if (hr is Map && hr['value'] is num) {
|
||||
final v = (hr['value'] as num).toDouble();
|
||||
if (v > 100) {
|
||||
abnormals.add('心率 ${v.toStringAsFixed(0)} 偏快');
|
||||
} else if (v < 60) {
|
||||
abnormals.add('心率 ${v.toStringAsFixed(0)} 偏慢');
|
||||
}
|
||||
final hrAbnormal = _recordIsAbnormal(
|
||||
hr,
|
||||
fallback: () {
|
||||
final v = _numValue(hr is Map ? hr['value'] ?? hr['Value'] : null);
|
||||
return v != null && (v > 100 || v < 60);
|
||||
},
|
||||
);
|
||||
if (hrAbnormal && hr is Map) {
|
||||
final v = _numValue(hr['value'] ?? hr['Value']);
|
||||
abnormals.add('心率 ${v?.toStringAsFixed(0) ?? '--'} 异常');
|
||||
}
|
||||
if (bs is Map && bs['value'] is num) {
|
||||
final v = (bs['value'] as num).toDouble();
|
||||
if (v > 6.1) abnormals.add('血糖 ${v.toStringAsFixed(1)} 偏高');
|
||||
final bsAbnormal = _recordIsAbnormal(
|
||||
bs,
|
||||
fallback: () {
|
||||
final v = _numValue(bs is Map ? bs['value'] ?? bs['Value'] : null);
|
||||
return v != null && (v > 6.1 || v < 3.9);
|
||||
},
|
||||
);
|
||||
if (bsAbnormal && bs is Map) {
|
||||
final v = _numValue(bs['value'] ?? bs['Value']);
|
||||
abnormals.add('血糖 ${v?.toStringAsFixed(1) ?? '--'} 异常');
|
||||
}
|
||||
if (bo is Map && bo['value'] is num) {
|
||||
final v = (bo['value'] as num).toDouble();
|
||||
if (v < 95) abnormals.add('血氧 ${v.toStringAsFixed(0)}% 偏低');
|
||||
final boAbnormal = _recordIsAbnormal(
|
||||
bo,
|
||||
fallback: () {
|
||||
final v = _numValue(bo is Map ? bo['value'] ?? bo['Value'] : null);
|
||||
return v != null && v <= 94;
|
||||
},
|
||||
);
|
||||
if (boAbnormal && bo is Map) {
|
||||
final v = _numValue(bo['value'] ?? bo['Value']);
|
||||
abnormals.add('血氧 ${v?.toStringAsFixed(0) ?? '--'}% 异常');
|
||||
}
|
||||
final hasAbnormal = abnormals.isNotEmpty;
|
||||
|
||||
@@ -1545,8 +1580,8 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
'健康指标',
|
||||
trailing: trailing,
|
||||
status: 'warning',
|
||||
iconColor: healthIconColor,
|
||||
iconBg: healthIconBg,
|
||||
iconColor: AppColors.warning,
|
||||
iconBg: AppColors.warningLight,
|
||||
onTap: () => pushRoute(ref, 'trend'),
|
||||
),
|
||||
);
|
||||
@@ -1749,7 +1784,7 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 10),
|
||||
padding: const EdgeInsets.fromLTRB(16, 13, 16, 11),
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
@@ -1760,26 +1795,13 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 28,
|
||||
height: 28,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withValues(alpha: 0.6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.health_and_safety,
|
||||
size: 16,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text(
|
||||
'今日健康',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: AppColors.textPrimary,
|
||||
height: 1.15,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
@@ -1867,6 +1889,8 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
trailing ?? label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: AppColors.textPrimary,
|
||||
@@ -1884,6 +1908,27 @@ class ChatMessagesView extends ConsumerWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool _recordIsAbnormal(dynamic record, {required bool Function() fallback}) {
|
||||
if (record is Map) {
|
||||
final raw =
|
||||
record['isAbnormal'] ?? record['IsAbnormal'] ?? record['abnormal'];
|
||||
if (raw is bool) return raw;
|
||||
if (raw is String) {
|
||||
final normalized = raw.toLowerCase();
|
||||
if (normalized == 'true') return true;
|
||||
if (normalized == 'false') return false;
|
||||
}
|
||||
if (raw is num) return raw != 0;
|
||||
}
|
||||
return fallback();
|
||||
}
|
||||
|
||||
double? _numValue(dynamic value) {
|
||||
if (value is num) return value.toDouble();
|
||||
if (value is String) return double.tryParse(value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class _AgentMark extends StatelessWidget {
|
||||
@@ -1906,7 +1951,7 @@ class _AgentMark extends StatelessWidget {
|
||||
? Alignment.bottomCenter
|
||||
: Alignment.bottomRight,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(colors.verticalGradient ? 18 : 20),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: colors.accent.withValues(alpha: 0.18),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/app_module_visuals.dart';
|
||||
import '../../core/app_theme.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/auth_provider.dart';
|
||||
@@ -21,8 +22,7 @@ class MedicationCheckInPage extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _MedicationCheckInPageState extends ConsumerState<MedicationCheckInPage> {
|
||||
static const _medBlue = Color(0xFF60A5FA);
|
||||
static const _medViolet = Color(0xFF8B5CF6);
|
||||
static const _visual = AppModuleVisuals.medication;
|
||||
static const _softGreen = Color(0xFFEAF8EF);
|
||||
|
||||
Future<List<Map<String, dynamic>>>? _future;
|
||||
@@ -67,11 +67,7 @@ class _MedicationCheckInPageState extends ConsumerState<MedicationCheckInPage> {
|
||||
} catch (e) {
|
||||
debugPrint('[MedCheckIn] 打卡失败: $e');
|
||||
if (mounted) {
|
||||
AppToast.show(
|
||||
context,
|
||||
'打卡失败,请稍后重试',
|
||||
type: AppToastType.error,
|
||||
);
|
||||
AppToast.show(context, '打卡失败,请稍后重试', type: AppToastType.error);
|
||||
}
|
||||
} finally {
|
||||
if (mounted) setState(() => _busyDoses.remove(doseKey));
|
||||
@@ -212,14 +208,7 @@ class _CheckInSummary extends StatelessWidget {
|
||||
width: 42,
|
||||
height: 42,
|
||||
decoration: BoxDecoration(
|
||||
gradient: const LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
_MedicationCheckInPageState._medBlue,
|
||||
_MedicationCheckInPageState._medViolet,
|
||||
],
|
||||
),
|
||||
gradient: _MedicationCheckInPageState._visual.gradient,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: const Icon(
|
||||
@@ -254,10 +243,10 @@ class _CheckInSummary extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
'${(progress * 100).round()}%',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: _MedicationCheckInPageState._medViolet,
|
||||
color: _MedicationCheckInPageState._visual.color,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -269,8 +258,8 @@ class _CheckInSummary extends StatelessWidget {
|
||||
minHeight: 9,
|
||||
value: progress,
|
||||
backgroundColor: AppColors.cardInner,
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||
_MedicationCheckInPageState._medBlue,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
_MedicationCheckInPageState._visual.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -300,7 +289,7 @@ class _CheckInSummary extends StatelessWidget {
|
||||
label: '总次数',
|
||||
value: '$total',
|
||||
icon: Icons.format_list_numbered_outlined,
|
||||
color: _MedicationCheckInPageState._medViolet,
|
||||
color: _MedicationCheckInPageState._visual.color,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -415,7 +404,7 @@ class _MedicationDoseCard extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: allTaken
|
||||
? _MedicationCheckInPageState._softGreen
|
||||
: AppColors.infoLight,
|
||||
: _MedicationCheckInPageState._visual.lightColor,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: AppColors.borderLight),
|
||||
),
|
||||
@@ -423,7 +412,7 @@ class _MedicationDoseCard extends StatelessWidget {
|
||||
allTaken ? Icons.done_all_rounded : Icons.medication_liquid,
|
||||
color: allTaken
|
||||
? AppTheme.success
|
||||
: _MedicationCheckInPageState._medBlue,
|
||||
: _MedicationCheckInPageState._visual.color,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
@@ -613,7 +602,7 @@ class _DoseRow extends StatelessWidget {
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: isTaken
|
||||
? Colors.white
|
||||
: _MedicationCheckInPageState._medBlue,
|
||||
: _MedicationCheckInPageState._visual.color,
|
||||
foregroundColor: isTaken
|
||||
? AppTheme.success
|
||||
: Colors.white,
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/app_design_tokens.dart';
|
||||
import '../../core/app_module_visuals.dart';
|
||||
import '../../core/app_theme.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
import '../../providers/data_providers.dart';
|
||||
@@ -19,8 +18,6 @@ class MedicationEditPage extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _MedicationEditPageState extends ConsumerState<MedicationEditPage> {
|
||||
static const _visual = AppModuleVisuals.medication;
|
||||
|
||||
final _nameCtrl = TextEditingController();
|
||||
final _dosageCtrl = TextEditingController();
|
||||
final _notesCtrl = TextEditingController();
|
||||
@@ -202,7 +199,7 @@ class _MedicationEditPageState extends ConsumerState<MedicationEditPage> {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
border: Border.all(color: _visual.borderColor, width: 1),
|
||||
border: Border.all(color: AppColors.border, width: 1),
|
||||
),
|
||||
child: Text(
|
||||
'${_times[i].hour.toString().padLeft(2, '0')}:${_times[i].minute.toString().padLeft(2, '0')}',
|
||||
@@ -235,19 +232,9 @@ class _MedicationEditPageState extends ConsumerState<MedicationEditPage> {
|
||||
const SizedBox(height: 16),
|
||||
_field('备注', _notesCtrl, hint: '如:饭后服用、睡前'),
|
||||
const SizedBox(height: 32),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _loading ? null : _save,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: _visual.color,
|
||||
side: BorderSide(color: _visual.color, width: 1.5),
|
||||
shape: RoundedRectangleBorder(borderRadius: AppRadius.lgBorder),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
),
|
||||
child: Text(_loading ? '保存中...' : '保存', style: AppTextStyles.button),
|
||||
),
|
||||
_GradientOutlineButton(
|
||||
onPressed: _loading ? null : _save,
|
||||
label: _loading ? '保存中...' : '保存',
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
@@ -271,7 +258,7 @@ class _MedicationEditPageState extends ConsumerState<MedicationEditPage> {
|
||||
fillColor: AppTheme.surface,
|
||||
border: _inputBorder(AppColors.border),
|
||||
enabledBorder: _inputBorder(AppColors.border),
|
||||
focusedBorder: _inputBorder(_visual.color),
|
||||
focusedBorder: _inputBorder(AppColors.primary),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 12,
|
||||
@@ -377,6 +364,57 @@ class _PickerBox extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _GradientOutlineButton extends StatelessWidget {
|
||||
final VoidCallback? onPressed;
|
||||
final String label;
|
||||
|
||||
const _GradientOutlineButton({required this.onPressed, required this.label});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final enabled = onPressed != null;
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
gradient: enabled ? AppColors.actionOutlineGradient : null,
|
||||
color: enabled ? null : AppColors.border,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
),
|
||||
padding: const EdgeInsets.all(1.4),
|
||||
child: Material(
|
||||
color: Colors.white,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
child: InkWell(
|
||||
onTap: onPressed,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
child: SizedBox(
|
||||
height: 46,
|
||||
child: Center(
|
||||
child: enabled
|
||||
? ShaderMask(
|
||||
shaderCallback: (bounds) =>
|
||||
AppColors.actionOutlineGradient.createShader(bounds),
|
||||
child: Text(
|
||||
label,
|
||||
style: AppTextStyles.button.copyWith(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
label,
|
||||
style: AppTextStyles.button.copyWith(
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _displayDate(DateTime date) {
|
||||
return '${date.year}/${date.month.toString().padLeft(2, '0')}/${date.day.toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
@@ -50,11 +50,9 @@ class _MedicationListPageState extends ConsumerState<MedicationListPage> {
|
||||
),
|
||||
title: const Text('用药管理'),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => pushRoute(ref, 'medicationEdit'),
|
||||
backgroundColor: _medVisual.color,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: const Icon(Icons.add, size: 28, color: Colors.white),
|
||||
floatingActionButton: _GradientFab(
|
||||
gradient: _medVisual.gradient,
|
||||
onTap: () => pushRoute(ref, 'medicationEdit'),
|
||||
),
|
||||
body: AppFutureView<List<Map<String, dynamic>>>(
|
||||
future: _future,
|
||||
@@ -136,6 +134,41 @@ class _MedicationListPageState extends ConsumerState<MedicationListPage> {
|
||||
}
|
||||
}
|
||||
|
||||
class _GradientFab extends StatelessWidget {
|
||||
final Gradient gradient;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _GradientFab({required this.gradient, required this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
gradient: gradient,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.medication.withValues(alpha: 0.22),
|
||||
blurRadius: 16,
|
||||
offset: const Offset(0, 8),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: AppRadius.lgBorder,
|
||||
child: const Icon(Icons.add, size: 28, color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MedicationListGroup extends StatelessWidget {
|
||||
final List<Widget> children;
|
||||
|
||||
|
||||
@@ -342,20 +342,24 @@ class _UnreadHint extends StatelessWidget {
|
||||
margin: const EdgeInsets.fromLTRB(0, 2, 0, 14),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 11),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFFBEB),
|
||||
color: AppColors.notificationLight,
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
border: Border.all(color: const Color(0xFFFDE68A)),
|
||||
border: Border.all(color: AppColors.notificationBorder),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(LucideIcons.bellRing, size: 18, color: Color(0xFFF97316)),
|
||||
const Icon(
|
||||
LucideIcons.bellRing,
|
||||
size: 18,
|
||||
color: AppColors.notification,
|
||||
),
|
||||
const SizedBox(width: 9),
|
||||
Text(
|
||||
'你有 $unreadCount 条未读消息',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Color(0xFF92400E),
|
||||
color: AppColors.notification,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -370,23 +374,14 @@ class _SectionTitle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _SectionShell(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
LucideIcons.calendarDays,
|
||||
size: 18,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.textHint,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -421,34 +416,29 @@ class _CollapsibleSectionTitle extends StatelessWidget {
|
||||
child: _SectionShell(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
LucideIcons.history,
|
||||
size: 18,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'$text · $count',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w900,
|
||||
color: AppColors.textPrimary,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.textHint,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
expanded ? '收起' : '展开',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: AppColors.textSecondary,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
expanded ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
|
||||
size: 22,
|
||||
color: AppColors.textSecondary,
|
||||
size: 18,
|
||||
color: AppColors.textHint,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -483,50 +473,17 @@ class _NotificationRow extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(14, 13, 12, 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
visual.color.withValues(alpha: 0.18),
|
||||
visual.lightColor,
|
||||
],
|
||||
),
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
border: Border.all(
|
||||
color: visual.color.withValues(alpha: 0.22),
|
||||
),
|
||||
),
|
||||
child: Icon(
|
||||
visual.icon,
|
||||
size: 24,
|
||||
color: visual.color,
|
||||
),
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
gradient: visual.gradient,
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
border: Border.all(
|
||||
color: visual.borderColor.withValues(alpha: 0.85),
|
||||
),
|
||||
if (!item.isRead)
|
||||
Positioned(
|
||||
top: -2,
|
||||
right: -2,
|
||||
child: Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.error,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(visual.icon, size: 24, color: Colors.white),
|
||||
),
|
||||
const SizedBox(width: 13),
|
||||
Expanded(
|
||||
@@ -594,14 +551,22 @@ class _NotificationRow extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (item.actionType != null) ...[
|
||||
const SizedBox(width: 6),
|
||||
const Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
size: 22,
|
||||
color: AppColors.textSecondary,
|
||||
const SizedBox(width: 10),
|
||||
SizedBox(
|
||||
width: 12,
|
||||
child: Center(
|
||||
child: item.isRead
|
||||
? const SizedBox.shrink()
|
||||
: Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: AppColors.error,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -641,21 +606,33 @@ class _NotificationVisual {
|
||||
final IconData icon;
|
||||
final Color color;
|
||||
final Color lightColor;
|
||||
final Color borderColor;
|
||||
final LinearGradient gradient;
|
||||
final String label;
|
||||
|
||||
const _NotificationVisual(this.icon, this.color, this.lightColor, this.label);
|
||||
const _NotificationVisual(
|
||||
this.icon,
|
||||
this.color,
|
||||
this.lightColor,
|
||||
this.borderColor,
|
||||
this.gradient,
|
||||
this.label,
|
||||
);
|
||||
|
||||
factory _NotificationVisual.fromModule(AppModuleVisual visual) {
|
||||
return _NotificationVisual(
|
||||
visual.icon,
|
||||
visual.color,
|
||||
visual.lightColor,
|
||||
visual.borderColor,
|
||||
visual.gradient,
|
||||
visual.label,
|
||||
);
|
||||
}
|
||||
|
||||
factory _NotificationVisual.of(InAppNotification item) {
|
||||
switch (item.actionType) {
|
||||
final kind = item.actionType ?? item.type;
|
||||
switch (kind) {
|
||||
case 'exercise':
|
||||
return _NotificationVisual.fromModule(AppModuleVisuals.exercise);
|
||||
case 'health':
|
||||
@@ -664,6 +641,12 @@ class _NotificationVisual {
|
||||
LucideIcons.triangleAlert,
|
||||
Color(0xFFEF4444),
|
||||
Color(0xFFFEE2E2),
|
||||
Color(0xFFFECACA),
|
||||
LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [Color(0xFFFF7A7A), Color(0xFFEF4444)],
|
||||
),
|
||||
'紧急',
|
||||
)
|
||||
: _NotificationVisual.fromModule(AppModuleVisuals.health);
|
||||
@@ -673,11 +656,21 @@ class _NotificationVisual {
|
||||
LucideIcons.fileWarning,
|
||||
Color(0xFFEF4444),
|
||||
Color(0xFFFEE2E2),
|
||||
Color(0xFFFECACA),
|
||||
LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [Color(0xFFFF7A7A), Color(0xFFEF4444)],
|
||||
),
|
||||
'报告',
|
||||
)
|
||||
: _NotificationVisual.fromModule(AppModuleVisuals.report);
|
||||
default:
|
||||
case 'medication':
|
||||
return _NotificationVisual.fromModule(AppModuleVisuals.medication);
|
||||
case 'diet':
|
||||
return _NotificationVisual.fromModule(AppModuleVisuals.diet);
|
||||
default:
|
||||
return _NotificationVisual.fromModule(AppModuleVisuals.notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../core/app_colors.dart';
|
||||
import '../../core/app_design_tokens.dart';
|
||||
import '../../core/app_theme.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/navigation_provider.dart';
|
||||
@@ -231,35 +232,35 @@ class NotificationPrefsPage extends ConsumerWidget {
|
||||
),
|
||||
if (prefs['healthRecord'] ?? true) ...[
|
||||
_SwitchTile(
|
||||
title: ' · 血压',
|
||||
title: '血压',
|
||||
value: prefs['healthRecord.bp'] ?? true,
|
||||
onChanged: (v) => ref
|
||||
.read(notificationPrefsProvider.notifier)
|
||||
.toggle('healthRecord.bp'),
|
||||
),
|
||||
_SwitchTile(
|
||||
title: ' · 心率',
|
||||
title: '心率',
|
||||
value: prefs['healthRecord.hr'] ?? true,
|
||||
onChanged: (v) => ref
|
||||
.read(notificationPrefsProvider.notifier)
|
||||
.toggle('healthRecord.hr'),
|
||||
),
|
||||
_SwitchTile(
|
||||
title: ' · 血糖',
|
||||
title: '血糖',
|
||||
value: prefs['healthRecord.glucose'] ?? true,
|
||||
onChanged: (v) => ref
|
||||
.read(notificationPrefsProvider.notifier)
|
||||
.toggle('healthRecord.glucose'),
|
||||
),
|
||||
_SwitchTile(
|
||||
title: ' · 血氧',
|
||||
title: '血氧',
|
||||
value: prefs['healthRecord.spo2'] ?? true,
|
||||
onChanged: (v) => ref
|
||||
.read(notificationPrefsProvider.notifier)
|
||||
.toggle('healthRecord.spo2'),
|
||||
),
|
||||
_SwitchTile(
|
||||
title: ' · 体重',
|
||||
title: '体重',
|
||||
value: prefs['healthRecord.weight'] ?? true,
|
||||
showDivider: false,
|
||||
onChanged: (v) => ref
|
||||
@@ -391,7 +392,7 @@ class _SettingsListSection extends StatelessWidget {
|
||||
children: [
|
||||
_SectionTitle(title: title),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(AppTheme.rSm),
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
child: ColoredBox(
|
||||
color: AppTheme.surface,
|
||||
child: Column(children: children),
|
||||
@@ -425,71 +426,127 @@ class _SwitchTile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dense = icon == null && (subtitle == null || subtitle!.isEmpty);
|
||||
return Container(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.surface,
|
||||
border: showDivider
|
||||
? Border(
|
||||
bottom: BorderSide(
|
||||
color: AppColors.borderLight.withValues(alpha: 0.75),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Row(
|
||||
decoration: BoxDecoration(color: AppTheme.surface),
|
||||
child: Column(
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Container(
|
||||
width: 34,
|
||||
height: 34,
|
||||
decoration: BoxDecoration(
|
||||
color: iconBg ?? AppColors.iconBg,
|
||||
borderRadius: BorderRadius.circular(AppTheme.rSm),
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: iconColor ?? AppColors.primary,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: dense ? 8 : 14,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: AppColors.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
if (icon != null) ...[
|
||||
Container(
|
||||
width: 34,
|
||||
height: 34,
|
||||
decoration: BoxDecoration(
|
||||
color: iconBg ?? AppColors.iconBg,
|
||||
borderRadius: AppRadius.smBorder,
|
||||
),
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
color: iconColor ?? AppColors.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: dense ? 15 : 16,
|
||||
color: AppColors.textPrimary,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
if (subtitle != null && subtitle!.isNotEmpty)
|
||||
const SizedBox(height: 2),
|
||||
if (subtitle != null && subtitle!.isNotEmpty)
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppTheme.textSub,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (subtitle != null && subtitle!.isNotEmpty)
|
||||
const SizedBox(height: 2),
|
||||
if (subtitle != null && subtitle!.isNotEmpty)
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(fontSize: 13, color: AppTheme.textSub),
|
||||
),
|
||||
_AppSwitch(value: value, onChanged: onChanged),
|
||||
],
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: value,
|
||||
onChanged: onChanged,
|
||||
activeThumbColor: AppTheme.primary,
|
||||
activeTrackColor: AppColors.primaryLight,
|
||||
),
|
||||
if (showDivider)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: icon != null ? 60 : 14),
|
||||
child: const Divider(
|
||||
height: 1,
|
||||
thickness: 0.7,
|
||||
color: Color(0xFFE8ECF2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _AppSwitch extends StatelessWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
const _AppSwitch({required this.value, required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final trackColor = value ? AppColors.primary : Colors.white;
|
||||
final borderColor = value
|
||||
? AppColors.primary.withValues(alpha: 0.38)
|
||||
: AppColors.border;
|
||||
return Semantics(
|
||||
button: true,
|
||||
toggled: value,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => onChanged(!value),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
curve: Curves.easeOutCubic,
|
||||
width: 46,
|
||||
height: 28,
|
||||
padding: const EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
color: trackColor,
|
||||
borderRadius: AppRadius.pillBorder,
|
||||
border: Border.all(color: borderColor, width: 1),
|
||||
),
|
||||
child: AnimatedAlign(
|
||||
duration: const Duration(milliseconds: 160),
|
||||
curve: Curves.easeOutCubic,
|
||||
alignment: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
child: Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: value ? Colors.white : AppColors.textHint,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TimeButton extends StatelessWidget {
|
||||
final String label;
|
||||
final String time;
|
||||
@@ -508,7 +565,7 @@ class _TimeButton extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColors.border),
|
||||
borderRadius: BorderRadius.circular(AppTheme.rSm),
|
||||
borderRadius: AppRadius.mdBorder,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user