feat: 饮食记录逻辑重构 + 通知管理分隔线修复 + 多页面 UI 调整
- 饮食: 新增 DietCommentaryPolicy + diet_record_logic, 饮食记录逻辑抽取复用 - 通知管理: 分隔线改为仿通知中心样式, 跳过图标区域只留文字下方 - 侧边栏: 对话记录操作栏浮层修复 + 常用功能间距收紧 - 智能体: 欢迎卡片去 400ms 延迟 + 胶囊去阴影 - 后端: AI 会话仓库新增方法 + 饮食评论策略 + 健康记录规则调整 - 其他: api_client IP 适配 + 多页面 UI 微调 + 新增测试
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user