exam_boold_oxygen.dart 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/components/dialog_number.dart';
  3. import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_card.dart';
  4. import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_side_bar.dart';
  5. // ignore: must_be_immutable
  6. class ExamBloodOxygen extends StatefulWidget {
  7. ExamBloodOxygen({
  8. super.key,
  9. required this.currentValue,
  10. required this.bloodOxygenInput,
  11. });
  12. Map<String, dynamic> currentValue;
  13. Function(Map<String, dynamic>) bloodOxygenInput;
  14. @override
  15. State<ExamBloodOxygen> createState() => _ExamBloodOxygenState();
  16. }
  17. class _ExamBloodOxygenState extends State<ExamBloodOxygen> {
  18. late String pulse = widget.currentValue['Pulse_Frequency'] ?? '';
  19. late String spO2 = widget.currentValue['Spo2'] ?? '';
  20. @override
  21. void initState() {
  22. super.initState();
  23. }
  24. @override
  25. void dispose() {
  26. super.dispose();
  27. }
  28. @override
  29. Widget build(BuildContext context) {
  30. return Stack(
  31. children: [
  32. ExamCard(
  33. topPadding: 0,
  34. content: Column(
  35. mainAxisAlignment: MainAxisAlignment.start,
  36. children: [
  37. ExamSideBar(
  38. title: '血氧饱和度',
  39. value: widget.currentValue['Spo2'] ?? '',
  40. unit: '%',
  41. onTap: () => _inputSpo2("血氧饱和度"),
  42. ),
  43. const Divider(indent: 3),
  44. ExamSideBar(
  45. title: '脉率',
  46. value: widget.currentValue['Pulse_Frequency'] ?? '',
  47. unit: 'bpm',
  48. onTap: () => _inputPulseFrequency("脉率"),
  49. ),
  50. ],
  51. ),
  52. ),
  53. ],
  54. );
  55. }
  56. Future<void> _inputSpo2(String title) async {
  57. String? result = await VDialogNumber(
  58. title: title,
  59. initialValue: spO2,
  60. ).show();
  61. if (result?.isNotEmpty ?? false) {
  62. spO2 = result ?? '';
  63. widget.bloodOxygenInput.call({
  64. 'Spo2': spO2,
  65. 'Pulse_Frequency': pulse,
  66. });
  67. widget.currentValue = {
  68. 'Spo2': spO2,
  69. 'Pulse_Frequency': pulse,
  70. };
  71. }
  72. }
  73. Future<void> _inputPulseFrequency(String title) async {
  74. String? result = await VDialogNumber(
  75. title: title,
  76. initialValue: pulse,
  77. ).show();
  78. if (result?.isNotEmpty ?? false) {
  79. pulse = result ?? '';
  80. widget.bloodOxygenInput.call({
  81. 'Spo2': spO2,
  82. 'Pulse_Frequency': pulse,
  83. });
  84. widget.currentValue = {
  85. 'Spo2': spO2,
  86. 'Pulse_Frequency': pulse,
  87. };
  88. }
  89. }
  90. }