view.dart 9.4 KB

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