123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/utils/advance_debounce.dart';
- import 'package:vitalapp/components/alert_dialog.dart';
- import 'package:vitalapp/pages/medical/controllers/waist.dart';
- import 'package:vitalapp/pages/medical/widgets/heart_rate.dart';
- import 'package:vitalapp/pages/medical/widgets/twelve_ecg.dart';
- import 'package:vitalapp/pages/medical/widgets/urinalysis.dart';
- import 'package:vitalapp/pages/medical/widgets/waist.dart';
- import 'package:vnote_device_plugin/consts/types.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/pages/medical/controller.dart';
- import 'package:vitalapp/pages/medical/widgets/blood_pressure.dart';
- import 'package:vitalapp/pages/medical/widgets/blood_sugar.dart';
- import 'package:vitalapp/pages/medical/widgets/body_temperature.dart';
- import 'package:vitalapp/pages/medical/widgets/body_bmi.dart';
- import 'package:vitalapp/pages/medical/widgets/bool_oxygen.dart';
- import 'package:vitalapp/store/store.dart';
- class MedicalPage extends GetView<MedicalController> {
- const MedicalPage({super.key});
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- resizeToAvoidBottomInset: false,
- body: SizedBox(height: double.maxFinite, child: _buildMedical()),
- floatingActionButton: _buildSaveButton(context),
- );
- }
- Widget _buildMedical() {
- return Row(
- children: [
- _buildMedicalMenus(),
- Obx(
- () => _buildDeviceImage(controller.state.currentTab),
- ),
- Obx(
- () => _buildMedicalInput(controller.state.currentTab),
- ),
- ],
- );
- }
- Widget _buildMedicalMenus() {
- return Expanded(
- flex: 3,
- child: Obx(
- () => Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- ListView(
- shrinkWrap: true,
- children: controller.state.medicalMenuList
- .map(
- (e) => Material(
- borderRadius: const BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30),
- ),
- child: Ink(
- decoration: const BoxDecoration(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30),
- ),
- ),
- child: InkWell(
- borderRadius: const BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30),
- ),
- onTap: () {
- controller.state.currentTab = e.key;
- },
- child: Obx(
- () => _SideBar(
- title: e.diagnosticItem,
- isActive: controller.state.currentTab == e.key,
- ),
- )),
- ),
- ),
- )
- .toList(),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildMedicalInput(String? currentTab) {
- return Expanded(
- flex: currentTab == DeviceTypes.TWELVEHEART ? 18 : 11,
- child: Stack(
- children: [
- Container(
- padding: const EdgeInsets.all(16),
- child: Column(
- children: [
- _buildContent(),
- ],
- ),
- ),
- ],
- ),
- );
- }
- String _deviceImageUrl(String? currentTab) {
- switch (currentTab) {
- case DeviceTypes.TEMP:
- return 'assets/images/healthCheck/temp.png';
- case DeviceTypes.SUGAR:
- return 'assets/images/healthCheck/sugar.png';
- case DeviceTypes.NIBP:
- return 'assets/images/healthCheck/nibp.png';
- case DeviceTypes.SPO2:
- return 'assets/images/healthCheck/spo2.png';
- case DeviceTypes.WEIGHT:
- return 'assets/images/healthCheck/bmi.png';
- case DeviceTypes.URINE:
- return 'assets/images/healthCheck/urine.png';
- case DeviceTypes.WAIST:
- return 'assets/images/healthCheck/whb.png';
- default:
- return 'assets/images/exam/normalMeasurementChart.png';
- }
- }
- Widget _buildDeviceImage(String? currentTab) {
- if (currentTab == DeviceTypes.TWELVEHEART) {
- return const SizedBox();
- }
- return Expanded(
- flex: 7,
- child: Container(
- alignment: Alignment.topCenter,
- margin: const EdgeInsets.all(16).copyWith(top: 10),
- child: Obx(
- () => ClipRect(
- child: Align(
- alignment: Alignment.bottomCenter,
- heightFactor: 0.8,
- child: controller.state.currentTab != null
- ? Image.asset(
- _deviceImageUrl(controller.state.currentTab),
- height: double.infinity,
- fit: BoxFit.contain, // 设置图像的适应方式
- )
- : Container(),
- ),
- ),
- ),
- ),
- );
- }
- Widget _buildGenerateReport() {
- return Positioned(
- bottom: 100,
- left: 16,
- child: VButton(
- onTap: () {
- Get.dialog(
- VAlertDialog(
- title: '提示',
- content: Container(
- margin: const EdgeInsets.only(bottom: 20),
- child: const Text(
- '当前检测是否已完成,请确定是否结束本次检测',
- style: TextStyle(fontSize: 20),
- textAlign: TextAlign.center,
- ),
- ),
- showCancel: true,
- onConfirm: () {
- controller.saveCachedAppDataId();
- },
- ),
- );
- },
- child: const Text(
- '生成检测',
- style: TextStyle(fontSize: 26),
- ),
- ),
- );
- }
- Widget _buildSaveButton(BuildContext context) {
- return Obx(() {
- if (Store.user.currentSelectPatientInfo == null) {
- return const SizedBox();
- }
- return FloatingActionButton.extended(
- backgroundColor: Theme.of(context).primaryColor,
- onPressed: () {
- advanceDebounce(controller.createDiagnosis, "createDiagnosis", 1500);
- },
- label: const SizedBox(
- width: 240,
- height: 60,
- child: Center(
- child: Text(
- '提交',
- style: TextStyle(
- fontSize: 26,
- color: Colors.white,
- ),
- ),
- ),
- ),
- );
- });
- }
- Widget _buildContent() {
- return Obx(() {
- switch (controller.state.currentTab) {
- case DeviceTypes.TEMP:
- return const BodyTemperature();
- case DeviceTypes.SUGAR:
- return const BloodSugar();
- case DeviceTypes.NIBP:
- return const BloodPressure();
- case DeviceTypes.SPO2:
- return const BloodOxygen();
- case DeviceTypes.WEIGHT:
- return const BodyWeight();
- case DeviceTypes.URINE:
- return const Urinalysis();
- case DeviceTypes.HEART:
- return const HeartRate();
- case DeviceTypes.TWELVEHEART:
- return const TwelveHeartRate();
- case DeviceTypes.WAIST:
- // TODO: 待统一各检测项
- return GetBuilder(
- init: WaistDeviceController(),
- builder: (_) => const WaistView(),
- );
- default:
- return const SizedBox();
- }
- });
- }
- }
- class _SideBar extends StatelessWidget {
- const _SideBar({
- required this.title,
- this.isActive,
- });
- final String title;
- final bool? isActive;
- @override
- Widget build(BuildContext context) {
- return Container(
- alignment: Alignment.centerLeft,
- width: 156,
- child: Container(
- margin: const EdgeInsets.only(bottom: 2),
- decoration: BoxDecoration(
- color: isActive!
- ? Theme.of(context).primaryColor
- : Theme.of(context).primaryColor.withOpacity(.2),
- borderRadius: const BorderRadius.only(
- topRight: Radius.circular(30),
- bottomRight: Radius.circular(30),
- ),
- ),
- alignment: Alignment.center,
- width: 156,
- height: 60,
- child: Text(
- title,
- style: TextStyle(
- fontSize: 26,
- color: isActive! ? Colors.white : Colors.black,
- ),
- ),
- ),
- );
- }
- }
|