MaintJobDrawer.dart 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 boy = DropMenuItem('男', 1);
  14. DropMenuItem girl = DropMenuItem('女', 2);
  15. DropMenuItem sexSelect = DropMenuItem('男', 1);
  16. List<DropMenuItem> sexMenuItems = [boy, girl];
  17. typedef _CallBack = void Function(int selectIndex, String selectStr);
  18. class _maintJobDrawer extends State<MaintJobDrawer> {
  19. @override
  20. Widget build(BuildContext context) {
  21. return Drawer(
  22. child: MediaQuery.removePadding(
  23. context: context,
  24. //移除抽屉菜单顶部默认留白
  25. removeTop: true,
  26. child: Column(
  27. crossAxisAlignment: CrossAxisAlignment.start,
  28. children: <Widget>[
  29. Padding(
  30. padding: const EdgeInsets.only(top: 50.0, left: 10, right: 10),
  31. child: Row(children: [
  32. Expanded(
  33. flex: 2,
  34. child: Text(
  35. '任务名称',
  36. style: TextStyle(
  37. color: Colors.black,
  38. fontSize: GSYConstant.minTextSize,
  39. fontWeight: FontWeight.bold,
  40. ),
  41. ),
  42. ),
  43. Expanded(
  44. child: Container(
  45. height: 40,
  46. child: TextField(
  47. decoration: InputDecoration(
  48. border: OutlineInputBorder(),
  49. ),
  50. style: TextStyle(fontSize: 14),
  51. onChanged: (value) {
  52. _name = value;
  53. },
  54. ),
  55. ),
  56. flex: 7,
  57. ),
  58. ]),
  59. ),
  60. Padding(
  61. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  62. child: Row(children: [
  63. Expanded(
  64. flex: 2,
  65. child: Text(
  66. '任务编号',
  67. style: TextStyle(
  68. color: Colors.black,
  69. fontSize: GSYConstant.minTextSize,
  70. fontWeight: FontWeight.bold,
  71. ),
  72. ),
  73. ),
  74. Expanded(
  75. child: Container(
  76. height: 40,
  77. child: TextField(
  78. decoration: InputDecoration(border: OutlineInputBorder()),
  79. style: TextStyle(fontSize: 14),
  80. onChanged: (value) {
  81. _number = value;
  82. },
  83. ),
  84. ),
  85. flex: 7,
  86. ),
  87. ]),
  88. ),Padding(
  89. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  90. child: Row(children: [
  91. Expanded(
  92. flex: 2,
  93. child: Text(
  94. '计划名称',
  95. style: TextStyle(
  96. color: Colors.black,
  97. fontSize: GSYConstant.minTextSize,
  98. fontWeight: FontWeight.bold,
  99. ),
  100. ),
  101. ),
  102. Expanded(
  103. child: Container(
  104. height: 40,
  105. child: TextField(
  106. decoration: InputDecoration(border: OutlineInputBorder()),
  107. style: TextStyle(fontSize: 14),
  108. onChanged: (value) {
  109. _planName = value;
  110. },
  111. ),
  112. ),
  113. flex: 7,
  114. ),
  115. ]),
  116. ),Padding(
  117. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  118. child: Row(children: [
  119. Expanded(
  120. flex: 2,
  121. child: Text(
  122. '计划编号',
  123. style: TextStyle(
  124. color: Colors.black,
  125. fontSize: GSYConstant.minTextSize,
  126. fontWeight: FontWeight.bold,
  127. ),
  128. ),
  129. ),
  130. Expanded(
  131. child: Container(
  132. height: 40,
  133. child: TextField(
  134. decoration: InputDecoration(border: OutlineInputBorder()),
  135. style: TextStyle(fontSize: 14),
  136. onChanged: (value) {
  137. _planNumber = value;
  138. },
  139. ),
  140. ),
  141. flex: 7,
  142. ),
  143. ]),
  144. ),
  145. Padding(
  146. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  147. child: Row(children: [
  148. Expanded(
  149. flex: 2,
  150. child: Text(
  151. '任务状态',
  152. style: TextStyle(
  153. color: Colors.black,
  154. fontSize: GSYConstant.minTextSize,
  155. fontWeight: FontWeight.bold,
  156. ),
  157. ),
  158. ),
  159. Expanded(
  160. flex: 7,
  161. child: Container(
  162. child: dropDownButtonsColumn(sexMenuItems, '性别', jobMenu),
  163. ),
  164. ),
  165. ]),
  166. ),
  167. ],
  168. ),
  169. ),
  170. );
  171. }
  172. Widget dropDownButtonsColumn(List<DropMenuItem> list, String hint, DropMenuItem select) {
  173. return Container(
  174. height: 40,
  175. //gives the height of the dropdown button
  176. width: MediaQuery.of(context).size.width,
  177. //gives the width of the dropdown button
  178. decoration: BoxDecoration(
  179. border: new Border.all(
  180. color: Colors.grey, //边框颜色
  181. width: 1.0, //边框粗细
  182. ),
  183. borderRadius:
  184. const BorderRadius.all(const Radius.circular(4.0)), //边框的弧度
  185. ),
  186. // padding: const EdgeInsets.symmetric(horizontal: 13), //you can include padding to control the menu items
  187. child: Theme(
  188. data: Theme.of(context).copyWith(
  189. // canvasColor: Colors.white, // background color for the dropdown items
  190. buttonTheme: ButtonTheme.of(context).copyWith(
  191. alignedDropdown:
  192. true, //If false (the default), then the dropdown's menu will be wider than its button.
  193. )),
  194. child: DropdownButtonHideUnderline(
  195. // to hide the default underline of the dropdown button
  196. child: DropdownButton<String>(
  197. iconEnabledColor: Color(0xFF595959),
  198. // icon color of the dropdown button
  199. items: list.map((dropMenuItem) {
  200. return DropdownMenuItem<String>(
  201. value: dropMenuItem.label,
  202. child: Text(
  203. dropMenuItem.label,
  204. style: TextStyle(fontSize: 15),
  205. ),
  206. );
  207. }).toList(),
  208. hint: Text(
  209. hint,
  210. style: TextStyle(fontSize: 15),
  211. ),
  212. // setting hint
  213. onChanged: (String? value) {
  214. setState(() {
  215. select.label = value; // saving the selected value
  216. });
  217. },
  218. value: select.label, // displaying the selected value
  219. ),
  220. )),
  221. );
  222. }
  223. String _name = '',_number = '', _planName = '', _planNumber = '';
  224. int _status = 1,_termType = 1;
  225. DropMenuItem jobMenu = DropMenuItem('男', 1);
  226. }