view.dart 14 KB

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