PatrolJobDrawer.dart 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. import 'package:deus_app/common/style/gsy_style.dart';
  2. import 'package:deus_app/common/utils/ConstantString.dart';
  3. import 'package:flutter/material.dart';
  4. import '../model/drop_menu_item.dart';
  5. class PatrolJobDrawer extends StatefulWidget {
  6. final _CallBack callback;
  7. const PatrolJobDrawer({super.key, required this.callback});
  8. @override
  9. State createState() {
  10. return _patrolJobDrawer();
  11. }
  12. }
  13. DropMenuItem not = DropMenuItem('已关闭', 0);
  14. DropMenuItem close = DropMenuItem('已完成', 2);
  15. DropMenuItem on = DropMenuItem('执行中', 1);
  16. DropMenuItem overdue = DropMenuItem('待执行', 3);
  17. DropMenuItem complete = DropMenuItem('已逾期', 4);
  18. List<DropMenuItem> sexMenuItems = [not, close, on, overdue, complete];
  19. DropMenuItem day = DropMenuItem('日计划', 0);
  20. DropMenuItem circumference = DropMenuItem('周计划', 1);
  21. DropMenuItem month = DropMenuItem('月计划', 2);
  22. List<DropMenuItem> sexMenuItems2 = [day, circumference, month];
  23. typedef _CallBack = void Function(String deviceName, String deviceNo,dynamic stase,dynamic termType);
  24. class _patrolJobDrawer extends State<PatrolJobDrawer> {
  25. @override
  26. Widget build(BuildContext context) {
  27. return Drawer(
  28. child: MediaQuery.removePadding(
  29. context: context,
  30. //移除抽屉菜单顶部默认留白
  31. removeTop: true,
  32. child: Column(
  33. crossAxisAlignment: CrossAxisAlignment.start,
  34. children: <Widget>[
  35. Padding(
  36. padding: const EdgeInsets.only(top: 65.0, left: 10, right: 10),
  37. child: Row(children: [
  38. Expanded(
  39. flex: 2,
  40. child: Text(
  41. '任务名称',
  42. style: TextStyle(
  43. color: Colors.black,
  44. fontSize: GSYConstant.minTextSize,
  45. fontWeight: FontWeight.bold,
  46. ),
  47. ),
  48. ),
  49. Expanded(
  50. child: Container(
  51. height: 40,
  52. child: TextField(
  53. decoration: InputDecoration(
  54. border: OutlineInputBorder(),
  55. ),
  56. style: TextStyle(fontSize: 14),
  57. onChanged: (value) {
  58. name = value;
  59. },
  60. ),
  61. ),
  62. flex: 7,
  63. ),
  64. ]),
  65. ),
  66. Padding(
  67. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  68. child: Row(children: [
  69. Expanded(
  70. flex: 2,
  71. child: Text(
  72. '任务编号',
  73. style: TextStyle(
  74. color: Colors.black,
  75. fontSize: GSYConstant.minTextSize,
  76. fontWeight: FontWeight.bold,
  77. ),
  78. ),
  79. ),
  80. Expanded(
  81. child: Container(
  82. height: 40,
  83. child: TextField(
  84. decoration: InputDecoration(border: OutlineInputBorder()),
  85. style: TextStyle(fontSize: 14),
  86. onChanged: (value) {
  87. no = value;
  88. },
  89. ),
  90. ),
  91. flex: 7,
  92. ),
  93. ]),
  94. ),
  95. Padding(
  96. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  97. child: Row(children: [
  98. Expanded(
  99. flex: 2,
  100. child: Text(
  101. '任务状态',
  102. style: TextStyle(
  103. color: Colors.black,
  104. fontSize: GSYConstant.minTextSize,
  105. fontWeight: FontWeight.bold,
  106. ),
  107. ),
  108. ),
  109. Expanded(
  110. flex: 7,
  111. child: Container(
  112. child: dropDownButtonsColumn(sexMenuItems, '请选择任务状态', 0),
  113. ),
  114. ),
  115. ]),
  116. ),
  117. Padding(
  118. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  119. child: Row(children: [
  120. Expanded(
  121. flex: 2,
  122. child: Text(
  123. '周期规则',
  124. style: TextStyle(
  125. color: Colors.black,
  126. fontSize: GSYConstant.minTextSize,
  127. fontWeight: FontWeight.bold,
  128. ),
  129. ),
  130. ),
  131. Expanded(
  132. flex: 7,
  133. child: Container(
  134. child: dropDownButtonsColumn(sexMenuItems2, '请选择周期规则', 1),
  135. ),
  136. ),
  137. ]),
  138. ),
  139. SizedBox(
  140. height: 80,
  141. ),
  142. Row(
  143. crossAxisAlignment: CrossAxisAlignment.end,
  144. mainAxisAlignment: MainAxisAlignment.end,
  145. children: [
  146. TextButton(
  147. onPressed: () {
  148. Navigator.pop(context);
  149. },
  150. child: Text(ConstantString.cancel),
  151. style: ButtonStyle(
  152. backgroundColor:
  153. MaterialStateProperty.all<Color>(Color(0xFF4875EC)),
  154. foregroundColor:
  155. MaterialStateProperty.all<Color>(Colors.white),
  156. minimumSize: MaterialStateProperty.all(Size(80, 40)),
  157. padding: MaterialStateProperty.all(EdgeInsets.zero)),
  158. ),
  159. SizedBox(
  160. width: 20,
  161. ),
  162. TextButton(
  163. onPressed: () {
  164. if (widget.callback != null) {
  165. widget.callback(name,no,satus,termType);
  166. Navigator.pop(context);
  167. }
  168. },
  169. child: Text(ConstantString.query),
  170. style: ButtonStyle(
  171. backgroundColor:
  172. MaterialStateProperty.all<Color>(Color(0xFF4875EC)),
  173. foregroundColor:
  174. MaterialStateProperty.all<Color>(Colors.white),
  175. minimumSize: MaterialStateProperty.all(Size(80, 40)),
  176. padding: MaterialStateProperty.all(EdgeInsets.zero)),
  177. ),
  178. SizedBox(
  179. width: 20,
  180. ),
  181. ],
  182. )
  183. ],
  184. ),
  185. ),
  186. );
  187. }
  188. Widget dropDownButtonsColumn(List<DropMenuItem> list, String hint, int type) {
  189. return Container(
  190. height: 40,
  191. //gives the height of the dropdown button
  192. width: MediaQuery.of(context).size.width,
  193. //gives the width of the dropdown button
  194. decoration: BoxDecoration(
  195. border: new Border.all(
  196. color: Colors.grey, //边框颜色
  197. width: 1.0, //边框粗细
  198. ),
  199. borderRadius:
  200. const BorderRadius.all(const Radius.circular(4.0)), //边框的弧度
  201. ),
  202. // padding: const EdgeInsets.symmetric(horizontal: 13), //you can include padding to control the menu items
  203. child: Theme(
  204. data: Theme.of(context).copyWith(
  205. // canvasColor: Colors.white, // background color for the dropdown items
  206. buttonTheme: ButtonTheme.of(context).copyWith(
  207. alignedDropdown:
  208. true, //If false (the default), then the dropdown's menu will be wider than its button.
  209. )),
  210. child: DropdownButtonHideUnderline(
  211. // to hide the default underline of the dropdown button
  212. child: DropdownButton<String>(
  213. iconEnabledColor: Color(0xFF595959),
  214. // icon color of the dropdown button
  215. items: list.map((dropMenuItem) {
  216. return DropdownMenuItem<String>(
  217. value: dropMenuItem.label,
  218. child: Text(
  219. dropMenuItem.label,
  220. style: TextStyle(fontSize: 15),
  221. ),
  222. );
  223. }).toList(),
  224. hint: Text(
  225. hint,
  226. style: TextStyle(fontSize: 15),
  227. ),
  228. // setting hint
  229. onChanged: (String? value) {
  230. if (0 == type) {
  231. key = value;
  232. } else {
  233. key2 = value;
  234. }
  235. setState(() {
  236. for (var element in list) {
  237. if (value == element.label) {
  238. if (type == 0) {
  239. satus = element.value; // saving the selected value
  240. } else {
  241. termType = element.value;
  242. }
  243. }
  244. }
  245. });
  246. },
  247. value: type == 0 ? key : key2, // displaying the selected value
  248. ),
  249. )),
  250. );
  251. }
  252. dynamic satus = null;
  253. dynamic termType = null;
  254. String? key, key2;
  255. String name = '', no = '';
  256. }