home_page.dart 8.8 KB

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