view.dart 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. import 'dart:io';
  2. import 'package:fis_jsonrpc/rpc.dart';
  3. import 'package:flutter/foundation.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:get/get.dart';
  6. import 'package:path_provider/path_provider.dart';
  7. import 'package:vitalapp/architecture/utils/prompt_box.dart';
  8. import 'package:vitalapp/components/dynamic_drawer.dart';
  9. import 'package:vitalapp/pages/home/controller.dart';
  10. import 'package:vitalapp/pages/home/widgets/avatar.dart';
  11. import 'package:fis_common/helpers/color.dart';
  12. import 'package:vitalapp/pages/widgets/qr_view_example.dart';
  13. import 'package:vitalapp/store/store.dart';
  14. import 'widgets/menus.dart';
  15. import 'widgets/navigator.dart';
  16. import 'widgets/patient.dart';
  17. import 'widgets/status_bar.dart';
  18. class HomePage extends GetView<HomeController> {
  19. const HomePage({super.key});
  20. @override
  21. Widget build(BuildContext context) {
  22. return SafeArea(
  23. top: false,
  24. bottom: false,
  25. right: false,
  26. left: false,
  27. // maintainBottomViewPadding: true,
  28. child: LayoutBuilder(
  29. builder: (context, c) {
  30. return WillPopScope(
  31. onWillPop: () async {
  32. return false;
  33. },
  34. child: Scaffold(
  35. key: controller.homeScaffoldKey,
  36. // resizeToAvoidBottomInset: false,
  37. backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
  38. endDrawer: VDynamicDrawerWrapper(
  39. scaffoldKey: controller.homeScaffoldKey,
  40. ),
  41. body: Row(
  42. mainAxisSize: MainAxisSize.max,
  43. children: [
  44. // Expanded(child: _buildBody(context)),
  45. SizedBox(
  46. width: c.maxWidth,
  47. child: _buildBody(context),
  48. ),
  49. ],
  50. ),
  51. ),
  52. );
  53. },
  54. ),
  55. );
  56. }
  57. Widget _buildBody(BuildContext context) {
  58. final menuScrollController = ScrollController();
  59. return Row(
  60. mainAxisSize: MainAxisSize.max,
  61. children: [
  62. Container(
  63. width: 120,
  64. // color: const Color.fromRGBO(10, 32, 48, .8),
  65. decoration: BoxDecoration(
  66. gradient: LinearGradient(
  67. colors: [
  68. // Color.fromRGBO(59, 188, 255, 1),
  69. // Color.fromRGBO(44, 120, 229, 1),
  70. Theme.of(context).primaryColor,
  71. FColorHelper.mixColor(
  72. Colors.black, Theme.of(context).primaryColor, 50),
  73. ],
  74. begin: Alignment.bottomRight,
  75. end: Alignment.topLeft,
  76. ),
  77. ),
  78. child: Stack(
  79. children: [
  80. Positioned(
  81. bottom: 0,
  82. left: 0,
  83. right: 0,
  84. child: Opacity(
  85. opacity: 0.5,
  86. child: Image.asset(
  87. "assets/images/e_hospital.png",
  88. fit: BoxFit.fitWidth,
  89. ),
  90. ),
  91. ),
  92. Column(
  93. mainAxisSize: MainAxisSize.max,
  94. children: [
  95. SizedBox(
  96. height: 90,
  97. child: Column(
  98. mainAxisAlignment: MainAxisAlignment.center,
  99. children: [
  100. Obx(
  101. () => HomeAvatarWidget(
  102. size: 40,
  103. headImageToken: controller.state.headImageToken,
  104. ),
  105. ),
  106. const SizedBox(
  107. height: 8,
  108. ),
  109. Obx(
  110. () => Text(
  111. controller.state.doctorName,
  112. style: const TextStyle(
  113. color: Colors.white,
  114. fontSize: 16,
  115. ),
  116. ),
  117. ),
  118. ],
  119. ),
  120. ),
  121. Divider(
  122. color: Colors.white.withOpacity(.4),
  123. height: 1,
  124. indent: 30,
  125. endIndent: 30,
  126. ),
  127. const SizedBox(
  128. height: 8,
  129. ),
  130. Expanded(
  131. child: Obx(
  132. () {
  133. return HomeMenuListViewWidget(
  134. source: controller.state.menuItems,
  135. scrollerController: menuScrollController,
  136. currentSelectMenu: controller.state.currentSelectMenu,
  137. );
  138. },
  139. ),
  140. ),
  141. ],
  142. ),
  143. ],
  144. ),
  145. ),
  146. Container(
  147. color: Theme.of(context).primaryColor,
  148. child: VerticalDivider(
  149. width: 1,
  150. color: Colors.white.withOpacity(.4),
  151. ),
  152. ),
  153. Expanded(
  154. child: Column(
  155. children: [
  156. SizedBox(
  157. height: 60,
  158. child: _buildHeader(context),
  159. ),
  160. Expanded(
  161. child: Row(
  162. children: [
  163. Expanded(
  164. child: _buildContent(),
  165. ),
  166. ],
  167. ),
  168. ),
  169. ],
  170. ),
  171. ),
  172. ],
  173. );
  174. }
  175. Widget _buildContent() {
  176. return const Padding(
  177. padding: EdgeInsets.all(8),
  178. child: HomeNavigator(),
  179. // child: Container(
  180. // color: Colors.white,
  181. // child: HomeNavigator(),
  182. // ),
  183. );
  184. }
  185. Widget _buildHeader(BuildContext context) {
  186. final themeData = Theme.of(context);
  187. return Container(
  188. alignment: Alignment.center,
  189. decoration: BoxDecoration(
  190. gradient: LinearGradient(
  191. colors: [
  192. // Color.fromRGBO(59, 188, 255, 1),
  193. // Color.fromRGBO(44, 120, 229, 1),
  194. themeData.primaryColor.withOpacity(.6),
  195. themeData.primaryColor,
  196. ],
  197. begin: Alignment.topRight,
  198. end: Alignment.bottomLeft,
  199. ),
  200. ),
  201. child: Center(
  202. child: Row(
  203. mainAxisSize: MainAxisSize.max,
  204. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  205. children: [
  206. Expanded(
  207. flex: 4,
  208. child: Align(
  209. alignment: Alignment.centerLeft,
  210. child: _buildHeaderLeft(),
  211. ),
  212. ),
  213. Flexible(
  214. flex: 4,
  215. child: Align(
  216. alignment: Alignment.center,
  217. child: _buildHeaderCenter(),
  218. ),
  219. ),
  220. Expanded(
  221. flex: 4,
  222. child: Align(
  223. alignment: Alignment.centerRight,
  224. child: _buildHeaderRight(context),
  225. ),
  226. ),
  227. ],
  228. ),
  229. ),
  230. );
  231. }
  232. Widget _buildHeaderLeft() {
  233. return Row(
  234. mainAxisSize: MainAxisSize.min,
  235. crossAxisAlignment: CrossAxisAlignment.center,
  236. children: [
  237. // const HomeAvatarWidget(size: 40),
  238. const SizedBox(width: 16),
  239. RichText(
  240. text: TextSpan(
  241. text: controller.state.doctorTeamName,
  242. style: const TextStyle(
  243. color: Colors.white,
  244. fontSize: 20,
  245. fontWeight: FontWeight.bold,
  246. ),
  247. ),
  248. ),
  249. ],
  250. );
  251. }
  252. Widget _buildHeaderCenter() {
  253. int clickCount = 0;
  254. return Row(
  255. mainAxisSize: MainAxisSize.min,
  256. crossAxisAlignment: CrossAxisAlignment.center,
  257. children: [
  258. const SizedBox(width: 10),
  259. Column(
  260. mainAxisAlignment: MainAxisAlignment.center,
  261. children: [
  262. GestureDetector(
  263. onTap: () async {
  264. if (clickCount >= 10) {
  265. clickCount = 0;
  266. Get.toNamed("/admin");
  267. } else {
  268. if (clickCount > 5) {
  269. PromptBox.toast("Click count: $clickCount!");
  270. }
  271. clickCount++;
  272. }
  273. },
  274. child: const Text(
  275. "杏聆荟健康平台",
  276. style: TextStyle(
  277. color: Colors.white,
  278. fontSize: 24,
  279. fontWeight: FontWeight.bold,
  280. ),
  281. ),
  282. ),
  283. ],
  284. ),
  285. ],
  286. );
  287. }
  288. Widget _buildHeaderRight(BuildContext context) {
  289. return Row(
  290. mainAxisSize: MainAxisSize.min,
  291. children: [
  292. TextButton(
  293. child:
  294. Text('扫一扫', style: TextStyle(fontSize: 24, color: Colors.white)),
  295. onPressed: () {
  296. Get.to(() => QRViewExample(
  297. onPressed: controller.onScanData,
  298. ));
  299. },
  300. ),
  301. // Padding(
  302. // padding: EdgeInsets.symmetric(horizontal: 8),
  303. // child: VerticalDivider(
  304. // indent: 12,
  305. // endIndent: 12,
  306. // color: Colors.white,
  307. // ),
  308. // ),
  309. HeaderPatientPlace(),
  310. Padding(
  311. padding: EdgeInsets.symmetric(horizontal: 8),
  312. child: VerticalDivider(
  313. indent: 12,
  314. endIndent: 12,
  315. color: Colors.white,
  316. ),
  317. ),
  318. HeaderStatusBar(),
  319. ],
  320. );
  321. }
  322. }