123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import 'dart:convert';
- import 'package:flutter/material.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'package:vitalapp/pages/form/form_info.dart';
- import 'package:vnote_device_plugin/models/exams/nibp.dart';
- import 'exam_card.dart';
- import 'follow_blood_pressure.dart';
- class ExamBlood extends StatefulWidget {
- final FormObject currentFormObject;
- ExamBlood({required this.currentFormObject});
- @override
- State<StatefulWidget> createState() {
- return ExamBloodState();
- }
- }
- class ExamBloodState extends State<ExamBlood> {
- NibpExamValue? _nibpExamValue;
- FormObject get currentFormObject => widget.currentFormObject;
- @override
- void initState() {
- if (FormInfo.instance.formValue.containsKey(widget.currentFormObject.key)) {
- var value = FormInfo.instance.formValue[widget.currentFormObject.key];
- _nibpExamValue = NibpExamValue(
- diastolicPressure: int.parse(value[0]),
- pulse: 0,
- systolicPressure: int.parse(value[1]),
- );
- }
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return ExamCard(
- content: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- InkWell(
- child: SideBar(
- title: '血压',
- value: _buildResult(_nibpExamValue),
- unit: 'mmHg',
- ),
- onTap: _onTap,
- ),
- ],
- ),
- );
- }
- Future<void> _onTap() async {
- String? result = await VDialogBloodPressure(
- title: '血压',
- initialValue: [
- _nibpExamValue?.systolicPressure.toString() ?? '',
- _nibpExamValue?.diastolicPressure.toString() ?? '',
- ],
- ).show();
- if (result != null) {
- _nibpExamValue = NibpExamValue(
- diastolicPressure: int.parse(jsonDecode(result).last),
- systolicPressure: int.parse(jsonDecode(result).first),
- pulse: 0,
- );
- FormInfo.instance.formValue[currentFormObject.key!] = [
- _nibpExamValue!.diastolicPressure.toString(),
- _nibpExamValue!.systolicPressure.toString(),
- ];
- }
- setState(() {});
- }
- Widget _buildResult(NibpExamValue? nibpExamValue) {
- const textStyle = TextStyle(fontSize: 26, color: Colors.black);
- var systolicPressure = nibpExamValue?.systolicPressure.toString() ?? '';
- var diastolicPressure = nibpExamValue?.diastolicPressure.toString() ?? '';
- var span = " / ";
- if (systolicPressure.isEmpty && diastolicPressure.isEmpty) {
- span += " ";
- }
- return Row(
- children: [
- Align(
- alignment: Alignment.centerLeft,
- child: Text(
- systolicPressure,
- style: textStyle,
- ),
- ),
- Text(
- span,
- style: textStyle,
- ),
- Align(
- alignment: Alignment.centerRight,
- child: Text(
- diastolicPressure,
- style: textStyle,
- ),
- ),
- Text(
- " mmHg",
- style: textStyle,
- ),
- ],
- );
- }
- }
|