home_page.dart 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. import 'package:deus_app/common/local/StoreHelper.dart';
  2. import 'package:deus_app/common/utils/ConstantString.dart';
  3. import 'package:deus_app/common/utils/ToastUtils.dart';
  4. import 'package:deus_app/page/patrol/patrol_job_page.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:flutter/services.dart';
  7. import '../device/device_manage_page.dart';
  8. import '../maint/maint_job_page.dart';
  9. class HomePage extends StatefulWidget {
  10. static var routeName = '/HomePage';
  11. const HomePage({Key? key}) : super(key: key);
  12. @override
  13. _MineViewPageState createState() => _MineViewPageState();
  14. }
  15. class _MineViewPageState extends State<HomePage> {
  16. List items = [
  17. {"name": "今日维保任务", "num": 1},
  18. {"name": "今日巡检任务", "num": 2}
  19. ];
  20. List icons = [
  21. {
  22. "name": "设备管理",
  23. "image": "images/device_manage.png",
  24. 'jump': DeviceManagePage.routeName
  25. },
  26. {
  27. "name": "维保任务",
  28. "image": "images/maintenance.png",
  29. 'jump': MaintJobPage.routeName
  30. },
  31. {
  32. "name": "巡检任务",
  33. "image": "images/patrol_inspect.png",
  34. 'jump': PatrolJobPage.routeName
  35. },
  36. {"name": "保修管理", "image": "images/maintenance_manage.png", 'jump': ''},
  37. ];
  38. @override
  39. void initState() {
  40. super.initState();
  41. }
  42. void registerHandler() {}
  43. @override
  44. Widget build(BuildContext context) {
  45. return Scaffold(
  46. extendBodyBehindAppBar: true,
  47. appBar: AppBar(
  48. shadowColor: Colors.transparent,
  49. backgroundColor: Colors.transparent,
  50. systemOverlayStyle: SystemUiOverlayStyle.light
  51. .copyWith(statusBarColor: Colors.transparent),
  52. // title: Text(user != null ? user["nickname"] : "",style:TextStyle(color: Colors.white),),
  53. centerTitle: true,
  54. elevation: 0.0,
  55. toolbarHeight: 0,
  56. ),
  57. backgroundColor: const Color(0xfff4f6ff),
  58. body: Column(
  59. children: [
  60. Container(
  61. padding: EdgeInsets.only(
  62. left: 15,
  63. right: 15,
  64. top: MediaQuery.of(context).padding.top + 10),
  65. height: MediaQuery.of(context).size.width * 0.53,
  66. decoration: BoxDecoration(
  67. image: DecorationImage(
  68. image: AssetImage("images/home_bg.jpg"), fit: BoxFit.cover),
  69. ),
  70. child: Column(
  71. children: [
  72. Row(
  73. mainAxisAlignment: MainAxisAlignment.end,
  74. children: [
  75. IconButton(
  76. icon: Icon(Icons.settings),
  77. color: Colors.white,
  78. onPressed: () => showToast("text"),
  79. ),
  80. ],
  81. ),
  82. Row(
  83. children: [
  84. Image.asset(
  85. "images/head.png",
  86. width: 40,
  87. height: 40,
  88. ),
  89. SizedBox(width: 10),
  90. Text(
  91. StoreHelper.getStorage(ConstantString.name),
  92. style: TextStyle(
  93. color: Colors.white,
  94. fontWeight: FontWeight.bold,
  95. fontSize: 15),
  96. )
  97. ],
  98. ),
  99. SizedBox(height: 20),
  100. Row(
  101. children: [
  102. SizedBox(width: 50),
  103. Text(StoreHelper.getStorage(ConstantString.phone),
  104. style: TextStyle(
  105. color: Colors.white,
  106. fontWeight: FontWeight.bold,
  107. fontSize: 18))
  108. ],
  109. ),
  110. SizedBox(height: 10),
  111. Row(
  112. children: [
  113. SizedBox(width: 50),
  114. Text(StoreHelper.getStorage(ConstantString.orgName),
  115. style:
  116. TextStyle(color: Color(0xffaaaaaa), fontSize: 15))
  117. ],
  118. ),
  119. ],
  120. ),
  121. ),
  122. Container(
  123. padding: EdgeInsets.all(10),
  124. margin: EdgeInsets.all(15),
  125. decoration: BoxDecoration(
  126. color: Colors.white, borderRadius: BorderRadius.circular(10)),
  127. child: Column(
  128. crossAxisAlignment: CrossAxisAlignment.start,
  129. children: [
  130. SizedBox(height: 15),
  131. Container(
  132. width: double.infinity,
  133. height: 40,
  134. alignment: Alignment.center,
  135. decoration: BoxDecoration(
  136. color: Color(0xff74b900),
  137. borderRadius: BorderRadius.circular(10)),
  138. child: Text("当前设备运行正常",
  139. style: TextStyle(
  140. color: Color(0xffffffff), fontSize: 15))),
  141. SizedBox(
  142. height: 20,
  143. ),
  144. Text("待办任务",
  145. style: TextStyle(color: Color(0xff000000), fontSize: 18)),
  146. SizedBox(
  147. height: 10,
  148. ),
  149. GridView.builder(
  150. shrinkWrap: true,
  151. padding: const EdgeInsets.only(
  152. top: 10,
  153. ),
  154. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  155. crossAxisCount: 1,
  156. mainAxisSpacing: 10,
  157. crossAxisSpacing: 10,
  158. childAspectRatio: MediaQuery.of(context).size.width / 30,
  159. ),
  160. itemBuilder: (context, index) {
  161. Map item = items[index];
  162. return Row(
  163. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  164. children: [
  165. Text(item["name"],
  166. style: TextStyle(
  167. color: Color(0xff000000), fontSize: 13)),
  168. Text(item["num"].toString(),
  169. style: TextStyle(
  170. color: Color(0xff000000), fontSize: 13))
  171. ],
  172. );
  173. },
  174. itemCount: items.length,
  175. )
  176. ],
  177. ),
  178. ),
  179. Container(
  180. margin: EdgeInsets.only(left: 15, right: 15),
  181. decoration:
  182. BoxDecoration(borderRadius: BorderRadius.circular(10)),
  183. child: Column(
  184. crossAxisAlignment: CrossAxisAlignment.start,
  185. children: [
  186. GridView.builder(
  187. shrinkWrap: true,
  188. padding: const EdgeInsets.only(
  189. top: 0,
  190. ),
  191. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  192. crossAxisCount: 3,
  193. mainAxisSpacing: 10,
  194. crossAxisSpacing: 10,
  195. childAspectRatio:
  196. (MediaQuery.of(context).size.width / 3 - 60 / 3) /
  197. 120,
  198. ),
  199. itemBuilder: (context, index) {
  200. Map item = icons[index];
  201. return GestureDetector(
  202. onTap: () => Navigator.pushNamed(context, item['jump']),
  203. child: Container(
  204. padding: EdgeInsets.all(5),
  205. decoration: BoxDecoration(
  206. color: Color(0xffffffff),
  207. borderRadius: BorderRadius.circular(10)),
  208. child: Column(
  209. crossAxisAlignment: CrossAxisAlignment.center,
  210. mainAxisAlignment: MainAxisAlignment.center,
  211. children: [
  212. Image.asset(
  213. item["image"],
  214. width: 60,
  215. height: 60,
  216. ),
  217. SizedBox(height: 10),
  218. Text(item["name"].toString(),
  219. style: TextStyle(
  220. color: Color(0xff000000), fontSize: 13))
  221. ],
  222. ),
  223. ),
  224. );
  225. },
  226. itemCount: icons.length,
  227. )
  228. ],
  229. ),
  230. ),
  231. ],
  232. ));
  233. }
  234. }