MaintJobDrawer.dart 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 MaintJobDrawer extends StatefulWidget {
  6. final _CallBack callback;
  7. const MaintJobDrawer({super.key, required this.callback});
  8. @override
  9. State createState() {
  10. return _maintJobDrawer();
  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. typedef _CallBack = void Function(String device, String name,dynamic stase);
  20. class _maintJobDrawer extends State<MaintJobDrawer> {
  21. @override
  22. Widget build(BuildContext context) {
  23. return Drawer(
  24. child: MediaQuery.removePadding(
  25. context: context,
  26. //移除抽屉菜单顶部默认留白
  27. removeTop: true,
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: <Widget>[
  31. Padding(
  32. padding: const EdgeInsets.only(top: 65.0, left: 10, right: 10),
  33. child: Row(children: [
  34. Expanded(
  35. flex: 2,
  36. child: Text(
  37. '任务名称',
  38. style: TextStyle(
  39. color: Colors.black,
  40. fontSize: GSYConstant.minTextSize,
  41. fontWeight: FontWeight.bold,
  42. ),
  43. ),
  44. ),
  45. Expanded(
  46. child: Container(
  47. height: 40,
  48. child: TextField(
  49. decoration: InputDecoration(
  50. border: OutlineInputBorder(),
  51. ),
  52. style: TextStyle(fontSize: 14),
  53. onChanged: (value) {
  54. setState(() {
  55. _name = value;
  56. });
  57. },
  58. ),
  59. ),
  60. flex: 7,
  61. ),
  62. ]),
  63. ),
  64. Padding(
  65. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  66. child: Row(children: [
  67. Expanded(
  68. flex: 2,
  69. child: Text(
  70. '任务编号',
  71. style: TextStyle(
  72. color: Colors.black,
  73. fontSize: GSYConstant.minTextSize,
  74. fontWeight: FontWeight.bold,
  75. ),
  76. ),
  77. ),
  78. Expanded(
  79. child: Container(
  80. height: 40,
  81. child: TextField(
  82. decoration: InputDecoration(border: OutlineInputBorder()),
  83. style: TextStyle(fontSize: 14),
  84. onChanged: (value) {
  85. setState(() {
  86. _number = value;
  87. });
  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, '请选择任务状态'),
  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,_number,satus);
  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) {
  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. key = value;
  209. setState(() {
  210. for (var element in list) {
  211. if (value == element.label) {
  212. satus = element.value; // saving the selected value
  213. }
  214. }
  215. });
  216. },
  217. value: key, // displaying the selected value
  218. ),
  219. )),
  220. );
  221. }
  222. String _name = '', _number = '';
  223. dynamic satus = null;
  224. String? key;
  225. }