view.dart 11 KB

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