follow_medical.dart 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:vitalapp/pages/medical/models/item.dart';
  4. import 'package:vitalapp/pages/medical/widgets/heart_rate.dart';
  5. import 'package:vitalapp/pages/medical/widgets/twelve_ecg.dart';
  6. import 'package:vitalapp/pages/medical/widgets/urinalysis.dart';
  7. import 'package:vnote_device_plugin/consts/types.dart';
  8. import 'package:vitalapp/pages/medical/controller.dart';
  9. import 'package:vitalapp/pages/medical/widgets/blood_pressure.dart';
  10. import 'package:vitalapp/pages/medical/widgets/blood_sugar.dart';
  11. import 'package:vitalapp/pages/medical/widgets/body_temperature.dart';
  12. import 'package:vitalapp/pages/medical/widgets/body_bmi.dart';
  13. import 'package:vitalapp/pages/medical/widgets/bool_oxygen.dart';
  14. import 'package:vitalapp/store/store.dart';
  15. class FollowMedicalPage extends GetView<MedicalController> {
  16. const FollowMedicalPage({
  17. super.key,
  18. required this.cardKey,
  19. });
  20. final String cardKey;
  21. @override
  22. Widget build(BuildContext context) {
  23. /// TODO 暂时写死
  24. if (cardKey == 'TNB') {
  25. controller.state.currentTab = DeviceTypes.SUGAR;
  26. } else {
  27. controller.state.currentTab = DeviceTypes.NIBP;
  28. }
  29. return Scaffold(
  30. resizeToAvoidBottomInset: false,
  31. body: SizedBox(height: double.maxFinite, child: _buildMedical()),
  32. floatingActionButton: _buildSaveButton(context),
  33. );
  34. }
  35. Widget _buildMedical() {
  36. return Row(
  37. children: [
  38. _buildMedicalMenus(),
  39. Obx(
  40. () => _buildDeviceImage(controller.state.currentTab),
  41. ),
  42. Obx(
  43. () => _buildMedicalInput(controller.state.currentTab),
  44. ),
  45. ],
  46. );
  47. }
  48. Widget _buildMedicalMenus() {
  49. return Expanded(
  50. flex: 3,
  51. child: Column(
  52. mainAxisAlignment: MainAxisAlignment.center,
  53. children: [
  54. ListView(
  55. shrinkWrap: true,
  56. children: [
  57. if (cardKey == 'TNB')
  58. MedicalItem(key: DeviceTypes.SUGAR, diagnosticItem: '血糖'),
  59. MedicalItem(key: DeviceTypes.NIBP, diagnosticItem: '血压'),
  60. MedicalItem(key: DeviceTypes.WEIGHTHEIGHT, diagnosticItem: 'BMI'),
  61. ]
  62. .map(
  63. (e) => Material(
  64. borderRadius: const BorderRadius.only(
  65. topRight: Radius.circular(30),
  66. bottomRight: Radius.circular(30),
  67. ),
  68. child: Ink(
  69. decoration: const BoxDecoration(
  70. borderRadius: BorderRadius.only(
  71. topRight: Radius.circular(30),
  72. bottomRight: Radius.circular(30),
  73. ),
  74. ),
  75. child: InkWell(
  76. borderRadius: const BorderRadius.only(
  77. topRight: Radius.circular(30),
  78. bottomRight: Radius.circular(30),
  79. ),
  80. onTap: () {
  81. controller.state.currentTab = e.key;
  82. },
  83. child: Obx(
  84. () => _SideBar(
  85. title: e.diagnosticItem,
  86. isActive: controller.state.currentTab == e.key,
  87. ),
  88. )),
  89. ),
  90. ),
  91. )
  92. .toList(),
  93. ),
  94. ],
  95. ),
  96. );
  97. }
  98. Widget _buildMedicalInput(String? currentTab) {
  99. return Expanded(
  100. flex: currentTab == DeviceTypes.TWELVEHEART ? 18 : 11,
  101. child: Stack(
  102. children: [
  103. Container(
  104. padding: const EdgeInsets.all(16),
  105. child: Column(
  106. children: [
  107. _buildContent(),
  108. ],
  109. ),
  110. ),
  111. ],
  112. ),
  113. );
  114. }
  115. String _deviceImageUrl(String? currentTab) {
  116. switch (currentTab) {
  117. case DeviceTypes.TEMP:
  118. return 'assets/images/healthCheck/temp.png';
  119. case DeviceTypes.SUGAR:
  120. return 'assets/images/healthCheck/sugar.png';
  121. case DeviceTypes.NIBP:
  122. return 'assets/images/healthCheck/nibp.png';
  123. case DeviceTypes.SPO2:
  124. return 'assets/images/healthCheck/spo2.png';
  125. case DeviceTypes.WEIGHTHEIGHT:
  126. return 'assets/images/healthCheck/bmi.png';
  127. case DeviceTypes.URINE:
  128. return 'assets/images/healthCheck/urine.png';
  129. default:
  130. return 'assets/images/exam/normalMeasurementChart.png';
  131. }
  132. }
  133. Widget _buildDeviceImage(String? currentTab) {
  134. if (currentTab == DeviceTypes.TWELVEHEART) {
  135. return const SizedBox();
  136. }
  137. return Expanded(
  138. flex: 7,
  139. child: Container(
  140. alignment: Alignment.topCenter,
  141. margin: const EdgeInsets.all(16).copyWith(top: 10),
  142. child: Obx(
  143. () => ClipRect(
  144. child: Align(
  145. alignment: Alignment.bottomCenter,
  146. heightFactor: 0.8,
  147. child: controller.state.currentTab != null
  148. ? Image.asset(
  149. _deviceImageUrl(controller.state.currentTab),
  150. height: double.infinity,
  151. fit: BoxFit.contain, // 设置图像的适应方式
  152. )
  153. : Container(),
  154. ),
  155. ),
  156. ),
  157. ),
  158. );
  159. }
  160. Widget _buildSaveButton(BuildContext context) {
  161. return Obx(() {
  162. if (Store.user.currentSelectPatientInfo == null) {
  163. return const SizedBox();
  164. }
  165. return FloatingActionButton.extended(
  166. backgroundColor: Theme.of(context).primaryColor,
  167. onPressed: () async {
  168. Get.back(result: controller.diagnosisDataValue);
  169. },
  170. label: const SizedBox(
  171. width: 240,
  172. height: 60,
  173. child: Center(
  174. child: Text(
  175. '提交',
  176. style: TextStyle(
  177. fontSize: 26,
  178. color: Colors.white,
  179. ),
  180. ),
  181. ),
  182. ),
  183. );
  184. });
  185. }
  186. Widget _buildContent() {
  187. return Obx(() {
  188. switch (controller.state.currentTab) {
  189. case DeviceTypes.TEMP:
  190. return const BodyTemperature();
  191. case DeviceTypes.SUGAR:
  192. return const BloodSugar();
  193. case DeviceTypes.NIBP:
  194. return const BloodPressure();
  195. case DeviceTypes.SPO2:
  196. return const BloodOxygen();
  197. case DeviceTypes.WEIGHTHEIGHT:
  198. return const BodyWeight();
  199. case DeviceTypes.URINE:
  200. return const Urinalysis();
  201. case DeviceTypes.HEART:
  202. return const HeartRate();
  203. case DeviceTypes.TWELVEHEART:
  204. return const TwelveHeartRate();
  205. default:
  206. return const SizedBox();
  207. }
  208. });
  209. }
  210. }
  211. class _SideBar extends StatelessWidget {
  212. const _SideBar({
  213. required this.title,
  214. this.isActive,
  215. });
  216. final String title;
  217. final bool? isActive;
  218. @override
  219. Widget build(BuildContext context) {
  220. return Container(
  221. alignment: Alignment.centerLeft,
  222. width: 156,
  223. child: Container(
  224. margin: const EdgeInsets.only(bottom: 2),
  225. decoration: BoxDecoration(
  226. color: isActive!
  227. ? Theme.of(context).primaryColor
  228. : Theme.of(context).primaryColor.withOpacity(.2),
  229. borderRadius: const BorderRadius.only(
  230. topRight: Radius.circular(30),
  231. bottomRight: Radius.circular(30),
  232. ),
  233. ),
  234. alignment: Alignment.center,
  235. width: 156,
  236. height: 60,
  237. child: Text(
  238. title,
  239. style: TextStyle(
  240. fontSize: 26,
  241. color: isActive! ? Colors.white : Colors.black,
  242. ),
  243. ),
  244. ),
  245. );
  246. }
  247. }