PatrolJobDrawer.dart 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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, 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. SizedBox(
  118. height: 80,
  119. ),
  120. Row(
  121. crossAxisAlignment: CrossAxisAlignment.end,
  122. mainAxisAlignment: MainAxisAlignment.end,
  123. children: [
  124. TextButton(
  125. onPressed: () {
  126. Navigator.pop(context);
  127. },
  128. child: Text(ConstantString.cancel),
  129. style: ButtonStyle(
  130. backgroundColor:
  131. MaterialStateProperty.all<Color>(Color(0xFF4875EC)),
  132. foregroundColor:
  133. MaterialStateProperty.all<Color>(Colors.white),
  134. minimumSize: MaterialStateProperty.all(Size(80, 40)),
  135. padding: MaterialStateProperty.all(EdgeInsets.zero)),
  136. ),
  137. SizedBox(
  138. width: 20,
  139. ),
  140. TextButton(
  141. onPressed: () {
  142. if (widget.callback != null) {
  143. widget.callback(name,no,satus,termType);
  144. Navigator.pop(context);
  145. }
  146. },
  147. child: Text(ConstantString.query),
  148. style: ButtonStyle(
  149. backgroundColor:
  150. MaterialStateProperty.all<Color>(Color(0xFF4875EC)),
  151. foregroundColor:
  152. MaterialStateProperty.all<Color>(Colors.white),
  153. minimumSize: MaterialStateProperty.all(Size(80, 40)),
  154. padding: MaterialStateProperty.all(EdgeInsets.zero)),
  155. ),
  156. SizedBox(
  157. width: 20,
  158. ),
  159. ],
  160. )
  161. ],
  162. ),
  163. ),
  164. );
  165. }
  166. Widget dropDownButtonsColumn(List<DropMenuItem> list, String hint, int type) {
  167. return Container(
  168. height: 40,
  169. //gives the height of the dropdown button
  170. width: MediaQuery.of(context).size.width,
  171. //gives the width of the dropdown button
  172. decoration: BoxDecoration(
  173. border: new Border.all(
  174. color: Colors.grey, //边框颜色
  175. width: 1.0, //边框粗细
  176. ),
  177. borderRadius:
  178. const BorderRadius.all(const Radius.circular(4.0)), //边框的弧度
  179. ),
  180. // padding: const EdgeInsets.symmetric(horizontal: 13), //you can include padding to control the menu items
  181. child: Theme(
  182. data: Theme.of(context).copyWith(
  183. // canvasColor: Colors.white, // background color for the dropdown items
  184. buttonTheme: ButtonTheme.of(context).copyWith(
  185. alignedDropdown:
  186. true, //If false (the default), then the dropdown's menu will be wider than its button.
  187. )),
  188. child: DropdownButtonHideUnderline(
  189. // to hide the default underline of the dropdown button
  190. child: DropdownButton<String>(
  191. iconEnabledColor: Color(0xFF595959),
  192. // icon color of the dropdown button
  193. items: list.map((dropMenuItem) {
  194. return DropdownMenuItem<String>(
  195. value: dropMenuItem.label,
  196. child: Text(
  197. dropMenuItem.label,
  198. style: TextStyle(fontSize: 15),
  199. ),
  200. );
  201. }).toList(),
  202. hint: Text(
  203. hint,
  204. style: TextStyle(fontSize: 15),
  205. ),
  206. // setting hint
  207. onChanged: (String? value) {
  208. if (0 == type) {
  209. key = value;
  210. } else {
  211. key2 = value;
  212. }
  213. setState(() {
  214. for (var element in list) {
  215. if (value == element.label) {
  216. if (type == 0) {
  217. satus = element.value; // saving the selected value
  218. } else {
  219. termType = element.value;
  220. }
  221. }
  222. }
  223. });
  224. },
  225. value: type == 0 ? key : key2, // displaying the selected value
  226. ),
  227. )),
  228. );
  229. }
  230. dynamic satus = null;
  231. dynamic termType = null;
  232. String? key, key2;
  233. String name = '', no = '';
  234. }