view.dart 12 KB

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