import 'package:flutter/material.dart'; import 'package:vitalapp/components/dialog_number.dart'; import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_card.dart'; import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_side_bar.dart'; // ignore: must_be_immutable class ExamBloodOxygen extends StatefulWidget { ExamBloodOxygen({ super.key, required this.currentValue, required this.bloodOxygenInput, }); Map currentValue; Function(Map) bloodOxygenInput; @override State createState() => _ExamBloodOxygenState(); } class _ExamBloodOxygenState extends State { late String pulse = widget.currentValue['Pulse_Frequency'] ?? ''; late String spO2 = widget.currentValue['Spo2'] ?? ''; @override void initState() { super.initState(); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Stack( children: [ ExamCard( topPadding: 0, content: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ ExamSideBar( title: '血氧饱和度', value: widget.currentValue['Spo2'] ?? '', unit: '%', onTap: () => _inputSpo2("血氧饱和度"), ), const Divider(indent: 3), ExamSideBar( title: '脉率', value: widget.currentValue['Pulse_Frequency'] ?? '', unit: 'bpm', onTap: () => _inputPulseFrequency("脉率"), ), ], ), ), ], ); } Future _inputSpo2(String title) async { String? result = await VDialogNumber( title: title, initialValue: spO2, ).show(); if (result?.isNotEmpty ?? false) { spO2 = result ?? ''; widget.bloodOxygenInput.call({ 'Spo2': spO2, 'Pulse_Frequency': pulse, }); widget.currentValue = { 'Spo2': spO2, 'Pulse_Frequency': pulse, }; } } Future _inputPulseFrequency(String title) async { String? result = await VDialogNumber( title: title, initialValue: pulse, ).show(); if (result?.isNotEmpty ?? false) { pulse = result ?? ''; widget.bloodOxygenInput.call({ 'Spo2': spO2, 'Pulse_Frequency': pulse, }); widget.currentValue = { 'Spo2': spO2, 'Pulse_Frequency': pulse, }; } } }