view.dart 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:vnoteapp/components/dynamic_drawer.dart.dart';
  4. import 'package:vnoteapp/pages/home/controller.dart';
  5. import 'widgets/avatar.dart';
  6. import 'widgets/menus.dart';
  7. import 'widgets/navigator.dart';
  8. class HomePage extends GetView<HomeController> {
  9. const HomePage({super.key});
  10. @override
  11. Widget build(BuildContext context) {
  12. return SafeArea(
  13. top: false,
  14. bottom: false,
  15. right: false,
  16. left: false,
  17. // maintainBottomViewPadding: true,
  18. child: LayoutBuilder(
  19. builder: (context, c) {
  20. return Scaffold(
  21. key: controller.homeScaffoldKey,
  22. // resizeToAvoidBottomInset: false,
  23. backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
  24. endDrawer: VDynamicDrawerWrapper(
  25. scaffoldKey: controller.homeScaffoldKey,
  26. ),
  27. body: Column(
  28. mainAxisSize: MainAxisSize.max,
  29. children: [
  30. SizedBox(
  31. height: 90,
  32. child: _buildHeader(context),
  33. ),
  34. const SizedBox(height: 2),
  35. // Expanded(child: _buildBody(context)),
  36. SizedBox(
  37. height: c.maxHeight - 90 - 2,
  38. child: _buildBody(context),
  39. ),
  40. ],
  41. ),
  42. );
  43. },
  44. ),
  45. );
  46. }
  47. Widget _buildBody(BuildContext context) {
  48. final menuScrollController = ScrollController();
  49. return Row(
  50. mainAxisSize: MainAxisSize.max,
  51. children: [
  52. Container(
  53. width: 120,
  54. // color: const Color.fromRGBO(34, 164, 211, 1),
  55. color: Theme.of(context).primaryColor.withOpacity(.8),
  56. child: Stack(
  57. children: [
  58. Positioned(
  59. bottom: 0,
  60. left: 0,
  61. right: 0,
  62. child: Opacity(
  63. opacity: 0.5,
  64. child: Image.asset(
  65. "assets/images/e_hospital.png",
  66. fit: BoxFit.fitWidth,
  67. ),
  68. ),
  69. ),
  70. Column(
  71. mainAxisSize: MainAxisSize.max,
  72. children: [
  73. Expanded(
  74. child: Obx(
  75. () {
  76. return HomeMenuListViewWidget(
  77. source: controller.state.menuItems,
  78. scrollerController: menuScrollController,
  79. );
  80. },
  81. ),
  82. ),
  83. ],
  84. ),
  85. ],
  86. ),
  87. ),
  88. Expanded(child: _buildContent()),
  89. ],
  90. );
  91. }
  92. Widget _buildContent() {
  93. return Padding(
  94. padding: EdgeInsets.all(8),
  95. child: HomeNavigator(),
  96. // child: Container(
  97. // color: Colors.white,
  98. // child: HomeNavigator(),
  99. // ),
  100. );
  101. }
  102. Widget _buildHeader(BuildContext context) {
  103. final themeData = Theme.of(context);
  104. return Container(
  105. alignment: Alignment.center,
  106. padding: const EdgeInsets.symmetric(horizontal: 20),
  107. decoration: BoxDecoration(
  108. gradient: LinearGradient(
  109. colors: [
  110. // Color.fromRGBO(59, 188, 255, 1),
  111. // Color.fromRGBO(44, 120, 229, 1),
  112. themeData.primaryColor.withOpacity(.6),
  113. themeData.primaryColor,
  114. ],
  115. begin: Alignment.topCenter,
  116. end: Alignment.bottomCenter,
  117. ),
  118. ),
  119. child: Center(
  120. child: Row(
  121. mainAxisSize: MainAxisSize.max,
  122. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  123. children: [
  124. Expanded(
  125. child: Align(
  126. alignment: Alignment.centerLeft,
  127. child: _buildHeaderLeft(),
  128. ),
  129. ),
  130. Align(
  131. alignment: Alignment.center,
  132. child: _buildHeaderCenter(),
  133. ),
  134. const Spacer(),
  135. // Expanded(
  136. // child: Align(
  137. // alignment: Alignment.centerRight,
  138. // child: _buildHeaderRight(),
  139. // ),
  140. // ),
  141. ],
  142. ),
  143. ),
  144. );
  145. }
  146. Widget _buildHeaderLeft() {
  147. return Row(
  148. mainAxisSize: MainAxisSize.min,
  149. crossAxisAlignment: CrossAxisAlignment.center,
  150. children: [
  151. const HomeAvatarWidget(size: 50),
  152. const SizedBox(width: 16),
  153. Column(
  154. mainAxisAlignment: MainAxisAlignment.center,
  155. crossAxisAlignment: CrossAxisAlignment.start,
  156. children: [
  157. Text(
  158. controller.state.doctorName,
  159. style: const TextStyle(
  160. color: Colors.white,
  161. fontSize: 20,
  162. fontWeight: FontWeight.bold,
  163. ),
  164. ),
  165. Text(
  166. controller.state.doctorTeamName,
  167. style: const TextStyle(
  168. color: Color.fromRGBO(208, 208, 208, 1),
  169. fontSize: 16,
  170. ),
  171. ),
  172. ],
  173. )
  174. ],
  175. );
  176. }
  177. Widget _buildHeaderCenter() {
  178. return Row(
  179. mainAxisSize: MainAxisSize.min,
  180. crossAxisAlignment: CrossAxisAlignment.center,
  181. children: [
  182. Image.asset(
  183. "assets/images/vinno_logo2.png",
  184. height: 40,
  185. fit: BoxFit.fitHeight,
  186. ),
  187. const SizedBox(width: 8),
  188. const Column(
  189. mainAxisAlignment: MainAxisAlignment.center,
  190. children: [
  191. SizedBox(height: 8),
  192. Text(
  193. "智慧家医平台",
  194. style: TextStyle(
  195. color: Colors.white,
  196. fontSize: 20,
  197. ),
  198. ),
  199. ],
  200. ),
  201. ],
  202. );
  203. }
  204. Widget _buildHeaderRight() {
  205. return Image.asset(
  206. "assets/images/iflyrobot.png",
  207. height: 80,
  208. fit: BoxFit.fitHeight,
  209. );
  210. }
  211. }