view.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. import 'package:fis_ui/values/icons.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:get/get.dart';
  5. import 'package:vitalapp/components/dynamic_drawer.dart';
  6. import 'package:vitalapp/pages/admin/blank_door.dart';
  7. import 'package:vitalapp/pages/home/controller.dart';
  8. import 'package:vitalapp/pages/home/widgets/avatar.dart';
  9. import 'package:fis_common/helpers/color.dart';
  10. import 'package:vitalapp/pages/settings/center/controller.dart';
  11. import 'package:vitalapp/pages/settings/center/view.dart';
  12. import 'package:vitalapp/pages/settings/devices/controller.dart';
  13. import 'package:vitalapp/pages/settings/server/controller.dart';
  14. import 'package:vitalapp/pages/widgets/qr_view_example.dart';
  15. import 'widgets/menus.dart';
  16. import 'widgets/navigator.dart';
  17. import 'widgets/patient.dart';
  18. import 'widgets/status_bar.dart';
  19. class HomePage extends GetView<HomeController> {
  20. const HomePage({super.key});
  21. @override
  22. Widget build(BuildContext context) {
  23. return SafeArea(
  24. top: false,
  25. bottom: false,
  26. right: false,
  27. left: false,
  28. // maintainBottomViewPadding: true,
  29. child: LayoutBuilder(
  30. builder: (context, c) {
  31. return WillPopScope(
  32. onWillPop: () async {
  33. return false;
  34. },
  35. child: Scaffold(
  36. key: controller.homeScaffoldKey,
  37. // resizeToAvoidBottomInset: false,
  38. backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
  39. endDrawer: VDynamicDrawerWrapper(
  40. scaffoldKey: controller.homeScaffoldKey,
  41. ),
  42. body: Row(
  43. mainAxisSize: MainAxisSize.max,
  44. children: [
  45. // Expanded(child: _buildBody(context)),
  46. SizedBox(
  47. width: c.maxWidth,
  48. child: _buildBody(context),
  49. ),
  50. ],
  51. )),
  52. );
  53. },
  54. ),
  55. );
  56. }
  57. Widget _buildBody(BuildContext context) {
  58. Widget leftMenus = SizedBox();
  59. if (controller.state.menuItems.length != 1) leftMenus = _buildMenu(context);
  60. return Row(
  61. mainAxisSize: MainAxisSize.max,
  62. children: [
  63. leftMenus,
  64. Container(
  65. color: Theme.of(context).primaryColor,
  66. child: VerticalDivider(
  67. width: 1,
  68. color: Colors.white.withOpacity(.4),
  69. ),
  70. ),
  71. Expanded(
  72. child: Column(
  73. children: [
  74. SizedBox(
  75. height: 60,
  76. child: _buildHeader(context),
  77. ),
  78. Expanded(
  79. child: Row(
  80. children: [
  81. Expanded(
  82. child: _buildContent(),
  83. ),
  84. ],
  85. ),
  86. ),
  87. ],
  88. ),
  89. ),
  90. ],
  91. );
  92. }
  93. Widget _buildMenu(BuildContext context) {
  94. final menuScrollController = ScrollController();
  95. return Container(
  96. width: kIsWeb ? 100 : 120,
  97. decoration: BoxDecoration(
  98. gradient: LinearGradient(
  99. colors: [
  100. Theme.of(context).primaryColor,
  101. FColorHelper.mixColor(
  102. Colors.black,
  103. Theme.of(context).primaryColor,
  104. 50,
  105. ),
  106. ],
  107. begin: Alignment.bottomRight,
  108. end: Alignment.topLeft,
  109. ),
  110. ),
  111. child: Stack(
  112. children: [
  113. Positioned(
  114. bottom: 0,
  115. left: 0,
  116. right: 0,
  117. child: Opacity(
  118. opacity: 0.5,
  119. child: Image.asset(
  120. "assets/images/e_hospital.png",
  121. fit: BoxFit.fitWidth,
  122. ),
  123. ),
  124. ),
  125. Column(
  126. mainAxisSize: MainAxisSize.max,
  127. children: [
  128. SizedBox(
  129. height: 90,
  130. child: Column(
  131. mainAxisAlignment: MainAxisAlignment.center,
  132. children: [
  133. Obx(
  134. () => HomeAvatarWidget(
  135. size: 40,
  136. headImageToken: controller.state.headImageToken,
  137. ),
  138. ),
  139. const SizedBox(
  140. height: 8,
  141. ),
  142. Obx(
  143. () => Padding(
  144. padding: const EdgeInsets.symmetric(horizontal: 4),
  145. child: Text(
  146. controller.state.doctorName,
  147. style: const TextStyle(
  148. color: Colors.white,
  149. fontSize: 16,
  150. ),
  151. overflow: TextOverflow.ellipsis,
  152. ),
  153. ),
  154. ),
  155. ],
  156. ),
  157. ),
  158. Divider(
  159. color: Colors.white.withOpacity(.4),
  160. height: 1,
  161. indent: 30,
  162. endIndent: 30,
  163. ),
  164. const SizedBox(
  165. height: 8,
  166. ),
  167. Expanded(
  168. child: Obx(
  169. () {
  170. return HomeMenuListViewWidget(
  171. source: controller.state.menuItems,
  172. scrollerController: menuScrollController,
  173. currentSelectMenu: controller.state.currentSelectMenu,
  174. );
  175. },
  176. ),
  177. ),
  178. ],
  179. ),
  180. ],
  181. ),
  182. );
  183. }
  184. Widget _buildContent() {
  185. return Padding(
  186. padding: EdgeInsets.all(8),
  187. child: HomeNavigator(),
  188. // child: Container(
  189. // color: Colors.white,
  190. // child: HomeNavigator(),
  191. // ),
  192. );
  193. }
  194. Widget _buildHeader(BuildContext context) {
  195. final themeData = Theme.of(context);
  196. return Container(
  197. alignment: Alignment.center,
  198. decoration: BoxDecoration(
  199. gradient: LinearGradient(
  200. colors: [
  201. // Color.fromRGBO(59, 188, 255, 1),
  202. // Color.fromRGBO(44, 120, 229, 1),
  203. themeData.primaryColor.withOpacity(.6),
  204. themeData.primaryColor,
  205. ],
  206. begin: Alignment.topRight,
  207. end: Alignment.bottomLeft,
  208. ),
  209. ),
  210. child: Center(
  211. child: kIsWeb
  212. ? GestureDetector(
  213. onPanStart: (event) {
  214. controller.onStartDrag();
  215. },
  216. onPanEnd: (e) {
  217. controller.onEndDrag();
  218. },
  219. onDoubleTap: () {
  220. controller.onMaximize();
  221. },
  222. onPanCancel: () {
  223. controller.onEndDrag();
  224. },
  225. child: _buildWindowTitle(context),
  226. )
  227. : _buildWindowTitle(context),
  228. ),
  229. );
  230. }
  231. Widget _buildHeaderLeft() {
  232. return Row(
  233. mainAxisSize: MainAxisSize.min,
  234. crossAxisAlignment: CrossAxisAlignment.center,
  235. children: [
  236. // const HomeAvatarWidget(size: 40),
  237. const SizedBox(width: 16),
  238. RichText(
  239. text: TextSpan(
  240. text: controller.state.doctorTeamName,
  241. style: const TextStyle(
  242. color: Colors.white,
  243. fontSize: 20,
  244. fontWeight: FontWeight.bold,
  245. ),
  246. ),
  247. ),
  248. if (kIsWeb)
  249. Expanded(
  250. child: Container(
  251. color: Colors.transparent,
  252. height: 60,
  253. ),
  254. ),
  255. ],
  256. );
  257. }
  258. Widget _buildHeaderCenter() {
  259. return Row(
  260. mainAxisSize: MainAxisSize.min,
  261. crossAxisAlignment: CrossAxisAlignment.center,
  262. children: [
  263. const SizedBox(width: 10),
  264. if (kIsWeb)
  265. Expanded(
  266. child: Container(
  267. color: Colors.transparent,
  268. height: 60,
  269. ),
  270. ),
  271. Column(
  272. mainAxisAlignment: MainAxisAlignment.center,
  273. children: [
  274. GestureDetector(
  275. onTap: () async {
  276. BlankDoor.tryOpen();
  277. },
  278. child: const Text(
  279. "杏聆荟健康平台",
  280. style: TextStyle(
  281. color: Colors.white,
  282. fontSize: 24,
  283. fontWeight: FontWeight.bold,
  284. ),
  285. ),
  286. ),
  287. ],
  288. ),
  289. if (kIsWeb)
  290. Expanded(
  291. child: Container(
  292. color: Colors.transparent,
  293. height: 60,
  294. ),
  295. ),
  296. ],
  297. );
  298. }
  299. Widget _buildHeaderRight(BuildContext context) {
  300. return Row(
  301. mainAxisSize: MainAxisSize.min,
  302. mainAxisAlignment: MainAxisAlignment.center,
  303. crossAxisAlignment: CrossAxisAlignment.center,
  304. children: [
  305. if (kIsWeb)
  306. Expanded(
  307. child: Container(
  308. color: Colors.transparent,
  309. height: 60,
  310. ),
  311. ),
  312. Obx(() {
  313. print("currentRouter" + controller.state.currentSelectMenu);
  314. String currentRouter = controller.state.currentSelectMenu;
  315. if ([
  316. "/basicCheck",
  317. "/electrocardiogram",
  318. "/ncg",
  319. "/bloodTest",
  320. "/biochemistryTest",
  321. "/remedicalRecordView",
  322. "/TraditionalChineseMedicineConstitution"
  323. ].contains(currentRouter) &&
  324. !kIsWeb) {
  325. return IconButton(
  326. onPressed: () {
  327. // Get.to(
  328. // CameraExampleHome(),
  329. // );
  330. // Get.to(
  331. // BarcodeScannerPage(
  332. // mode: BarcodeScannerMode.barcode,
  333. // ),
  334. // );
  335. Get.to(
  336. () => QRViewExample(
  337. onScanSuccess: controller.onScanData,
  338. isBarcode: true,
  339. ),
  340. );
  341. },
  342. icon: Icon(
  343. FIcons.fis_scan,
  344. size: 40,
  345. color: Colors.white,
  346. ),
  347. );
  348. }
  349. return SizedBox();
  350. }),
  351. HeaderPatientPlace(),
  352. Padding(
  353. padding: EdgeInsets.symmetric(horizontal: 8),
  354. child: VerticalDivider(
  355. indent: 12,
  356. endIndent: 12,
  357. color: Colors.white,
  358. ),
  359. ),
  360. if (!kIsWeb) ...[
  361. HeaderStatusBar(),
  362. ],
  363. Center(
  364. child: IconButton(
  365. padding: EdgeInsets.all(0),
  366. onPressed: () async {
  367. if (!kIsWeb) {
  368. Get.lazyPut(() => DevicesSettingController());
  369. }
  370. Get.lazyPut(() => ServerSettingController());
  371. Get.lazyPut(() => SettingCenterController());
  372. await Get.to(
  373. Container(
  374. child: SettingCenterPage(),
  375. color: Colors.white,
  376. ),
  377. );
  378. String currentRouter = controller.state.currentSelectMenu;
  379. controller.switchNavByName(currentRouter);
  380. },
  381. icon: Icon(
  382. Icons.settings,
  383. color: Colors.white,
  384. size: 36,
  385. ),
  386. ),
  387. ),
  388. ],
  389. );
  390. }
  391. Widget _buildWindowTitle(BuildContext context) {
  392. return Row(
  393. mainAxisSize: MainAxisSize.max,
  394. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  395. children: [
  396. Expanded(
  397. flex: 4,
  398. child: Align(
  399. alignment: Alignment.centerLeft,
  400. child: _buildHeaderLeft(),
  401. ),
  402. ),
  403. Flexible(
  404. flex: 4,
  405. child: Align(
  406. alignment: Alignment.center,
  407. child: _buildHeaderCenter(),
  408. ),
  409. ),
  410. Expanded(
  411. flex: 6,
  412. child: Align(
  413. alignment: Alignment.centerRight,
  414. child: _buildHeaderRight(context),
  415. ),
  416. ),
  417. ],
  418. );
  419. }
  420. }