diff --git a/lib/screens/session_screen.dart b/lib/screens/session_screen.dart index e2e7c58..62581c5 100644 --- a/lib/screens/session_screen.dart +++ b/lib/screens/session_screen.dart @@ -65,6 +65,7 @@ class _SessionScreenState extends State { bool _rinsedMouth = true; bool _washedFace = true; + bool _isWaitingForNextMed = false; @override void initState() { @@ -197,6 +198,27 @@ class _SessionScreenState extends State { void _onStepCompleted() { _triggerFeedback(); + + if (_currentStepIndex < _steps.length) { + final currentStep = _steps[_currentStepIndex]; + // 如果当前是两药间隔等待,到点后提醒用户,并等待手动点击确认后再开始第二种药物 + if (currentStep.type == StepType.crossDrugWait && _currentStepIndex + 1 < _steps.length) { + _timer?.cancel(); + if (_settings.enableSound) { + AudioService().playSessionComplete(); + } + final nextMed = _steps[_currentStepIndex + 1].canister; + final nextName = nextMed?.name.split(' ')[0] ?? '第二组药物'; + if (_settings.enableVoicePrompt) { + TtsService().speak('两药间隔等待已结束!气道已充分舒张。请换上$nextName,戴好面罩后点击屏幕开始吸入。'); + } + setState(() { + _isWaitingForNextMed = true; + }); + return; + } + } + if (_currentStepIndex + 1 < _steps.length) { _startStep(_currentStepIndex + 1); } else { @@ -275,6 +297,10 @@ class _SessionScreenState extends State { return _buildFinishedView(); } + if (_isWaitingForNextMed && _currentStepIndex + 1 < _steps.length) { + return _buildWaitingForNextMedView(_steps[_currentStepIndex + 1]); + } + final step = _steps[_currentStepIndex]; final isCross = step.type == StepType.crossDrugWait; @@ -605,4 +631,186 @@ class _SessionScreenState extends State { ), ); } + + Widget _buildWaitingForNextMedView(SessionStep nextStep) { + final nextMed = nextStep.canister; + final nextName = nextMed?.name ?? '第二种药物'; + final shortName = nextName.split(' ')[0]; + final isSteroid = nextMed?.isSteroid ?? false; + + return Scaffold( + backgroundColor: const Color(0xFF0F172A), + appBar: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + foregroundColor: Colors.white, + title: const Text( + '两药间隔等待结束', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(), + child: const Text('退出', style: TextStyle(color: Colors.white70)), + ), + ], + ), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16), + child: Column( + children: [ + // 状态标志 + Container( + width: 64, + height: 64, + decoration: BoxDecoration( + color: const Color(0xFF10B981).withValues(alpha: 0.15), + shape: BoxShape.circle, + border: Border.all(color: const Color(0xFF10B981), width: 2), + ), + child: const Icon(Icons.check, color: Color(0xFF10B981), size: 36), + ), + const SizedBox(height: 16), + const Text( + '两药间隔倒计时已结束', + style: TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 6), + const Text( + '气道已充分舒张吸收,已暂停等待手动开始', + style: TextStyle(color: Color(0xFF94A3B8), fontSize: 13), + ), + + const SizedBox(height: 24), + + // 第二组药物卡片 + Container( + width: double.infinity, + padding: const EdgeInsets.all(18), + decoration: BoxDecoration( + color: const Color(0xFF1E293B), + borderRadius: BorderRadius.circular(20), + border: Border.all( + color: isSteroid ? const Color(0xFF059669) : const Color(0xFF2563EB), + width: 1.5, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: isSteroid + ? const Color(0xFF10B981).withValues(alpha: 0.2) + : const Color(0xFF2563EB).withValues(alpha: 0.2), + borderRadius: BorderRadius.circular(10), + ), + child: Center( + child: Text( + isSteroid ? '辅' : '万', + style: TextStyle( + color: isSteroid ? const Color(0xFF34D399) : const Color(0xFF60A5FA), + fontWeight: FontWeight.bold, + fontSize: 18, + ), + ), + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '准备开始第二组用药', + style: TextStyle( + fontSize: 12, + color: isSteroid ? const Color(0xFF34D399) : const Color(0xFF60A5FA), + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 2), + Text( + nextName, + style: const TextStyle( + fontSize: 16, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 14), + const Divider(color: Colors.white12, height: 1), + const SizedBox(height: 14), + Text( + '计划用药:${nextMed?.puffsPerSession ?? 1} 喷 • 单喷吸气时长 ${nextMed?.inhalationSeconds ?? 15} 秒', + style: const TextStyle(fontSize: 13, color: Color(0xFFCBD5E1), fontWeight: FontWeight.w600), + ), + const SizedBox(height: 12), + _buildCheckTip('1. 请取下前序药物,换上【$shortName】并充分摇匀'), + _buildCheckTip('2. 将储雾罐面罩紧贴口鼻,保持自然平静呼吸'), + _buildCheckTip('3. 一切就绪后,按压药瓶并点击下方按钮开始吸入'), + ], + ), + ), + + const Spacer(), + + // 手动开始第二组大按钮 + SizedBox( + width: double.infinity, + child: ElevatedButton.icon( + onPressed: () { + setState(() { + _isWaitingForNextMed = false; + }); + _startStep(_currentStepIndex + 1); + }, + style: ElevatedButton.styleFrom( + backgroundColor: const Color(0xFF2563EB), + foregroundColor: Colors.white, + padding: const EdgeInsets.symmetric(vertical: 18), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + elevation: 4, + ), + icon: const Icon(Icons.play_arrow_rounded, size: 26), + label: Text( + '开始吸入【$shortName】第 1 喷', + style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + ), + ), + ], + ), + ), + ), + ); + } + + Widget _buildCheckTip(String text) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 3), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text('• ', style: TextStyle(color: Color(0xFF38BDF8), fontSize: 13, fontWeight: FontWeight.bold)), + Expanded( + child: Text( + text, + style: const TextStyle(color: Color(0xFF94A3B8), fontSize: 12, height: 1.4), + ), + ), + ], + ), + ); + } }