view.dart 9.7 KB

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