123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:get/get.dart';
  6. import 'package:intl/intl.dart';
  7. class OrderConfirmation extends StatefulWidget {
  8. const OrderConfirmation({Key? key}) : super(key: key);
  9. @override
  10. State<OrderConfirmation> createState() => _OrderConfirmationState();
  11. }
  12. class _OrderConfirmationState extends State<OrderConfirmation> {
  13. TextEditingController _unameController = TextEditingController();
  14. TextEditingController _pwdController = TextEditingController();
  15. GlobalKey _formKey = GlobalKey<FormState>();
  16. var selectDate; //选择的时间
  17. var workingArea;
  18. // 20:59:59
  19. @override
  20. Widget build(BuildContext context) {
  21. return Scaffold(
  22. resizeToAvoidBottomInset: false,
  23. appBar: AppBar(
  24. elevation: 0,
  25. centerTitle: true,
  26. backgroundColor: Colors.white,
  27. title: Text(
  28. '预约',
  29. style: TextStyle(
  30. color: Colors.black,
  31. fontSize: 17.sp,
  32. letterSpacing: 2,
  33. fontWeight: FontWeight.bold),
  34. ),
  35. ),
  36. body: Form(
  37. key: _formKey, //设置globalKey,用于后面获取FormState
  38. autovalidateMode: AutovalidateMode.onUserInteraction,
  39. child: Column(
  40. children: <Widget>[
  41. Container(
  42. margin: EdgeInsets.fromLTRB(15, 20, 0, 0),
  43. alignment: Alignment.topLeft,
  44. child: Text(
  45. '作业面积/公顷',
  46. style: TextStyle(
  47. color: Color(0xff222222),
  48. fontSize: 17.sp,
  49. fontWeight: FontWeight.bold),
  50. ),
  51. ),
  52. TextFormField(
  53. // autofocus: true,
  54. keyboardType: TextInputType.number,
  55. controller: _unameController,
  56. decoration: const InputDecoration(
  57. isCollapsed: true,
  58. contentPadding:
  59. EdgeInsets.symmetric(vertical: 8, horizontal: 16),
  60. counterText: '', //去掉计数
  61. /// UnderlineInputBorder 只有下边框 默认使用的就是下边框
  62. border: UnderlineInputBorder(
  63. borderRadius: BorderRadius.all(Radius.circular(10)),
  64. borderSide: BorderSide(
  65. color: Color(0x30000000),
  66. width: 2.0,
  67. ),
  68. ),
  69. floatingLabelBehavior: FloatingLabelBehavior.never,
  70. hintText: "请输入具体面积(公顷)",
  71. ),
  72. onChanged: (e){
  73. setState(() {
  74. workingArea=e;
  75. });
  76. },
  77. // 校验用户名
  78. validator: (v) {
  79. return v!.trim().isNotEmpty ? null : "作业面积/公顷不能为空";
  80. },
  81. ),
  82. Container(
  83. margin: EdgeInsets.fromLTRB(15, 20, 0, 0),
  84. alignment: Alignment.topLeft,
  85. child: Text(
  86. '作业时间:',
  87. style: TextStyle(
  88. color: Color(0xff222222),
  89. fontSize: 17.sp,
  90. fontWeight: FontWeight.bold),
  91. ),
  92. ),
  93. Container(
  94. width: 345.w,
  95. padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
  96. decoration: const BoxDecoration(
  97. border: Border(
  98. bottom: BorderSide(width: 1, color: Color(0x20000000)
  99. // 0x17000000
  100. )),
  101. ),
  102. child: Row(
  103. children: [
  104. Image(
  105. image: AssetImage('images/icons/timeImage.png'),
  106. fit: BoxFit.cover,
  107. width: 18.w,
  108. height: 18.w,
  109. ),
  110. Padding(
  111. padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
  112. child: GestureDetector(
  113. onTap: () async {
  114. var handleChnage = await showDatePicker(
  115. context: context,
  116. helpText: '请选择作业开始时间',
  117. cancelText: '取消',
  118. confirmText: '确定',
  119. initialDate: selectDate == null
  120. ? DateTime.now()
  121. : selectDate,
  122. firstDate: DateTime.now(),
  123. lastDate: DateTime(2030),
  124. );
  125. setState(() {
  126. selectDate = handleChnage;
  127. print('${selectDate}+');
  128. });
  129. },
  130. child: Text(selectDate == null
  131. ? '请选择日期'
  132. : '${DateFormat("yyyy-MM-dd").format(selectDate)}'),
  133. ),
  134. )
  135. ],
  136. )),
  137. Container(
  138. margin: EdgeInsets.fromLTRB(15, 20, 0, 0),
  139. alignment: Alignment.topLeft,
  140. child: Text(
  141. '作业位置:',
  142. style: TextStyle(
  143. color: Color(0xff222222),
  144. fontSize: 17.sp,
  145. fontWeight: FontWeight.bold),
  146. ),
  147. ),
  148. Container(
  149. width: 345.w,
  150. padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
  151. decoration: BoxDecoration(
  152. border: Border(
  153. bottom: BorderSide(width: 1, color: Color(0x20000000)
  154. // 0x17000000
  155. )),
  156. ),
  157. child: Row(
  158. mainAxisAlignment: MainAxisAlignment.start,
  159. children: [
  160. Image(
  161. image: AssetImage('images/gpsImgae.png'),
  162. fit: BoxFit.cover,
  163. width: 14.w,
  164. height: 17.h,
  165. ),
  166. Padding(
  167. padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
  168. child: GestureDetector(
  169. onTap: () {},
  170. child: Container(
  171. width: 290.w,
  172. child: Text(
  173. '请选择详细地址',
  174. softWrap: true,
  175. maxLines: 1,
  176. textAlign: TextAlign.left,
  177. overflow: TextOverflow.ellipsis,
  178. ),
  179. ),
  180. ))
  181. ],
  182. ),
  183. ),
  184. // 登录按钮
  185. Spacer(),
  186. Container(
  187. alignment: Alignment.bottomCenter,
  188. child: SizedBox(
  189. width: 315.w,
  190. height: 49.h,
  191. child: ElevatedButton(
  192. onPressed: () {
  193. if ((_formKey.currentState as FormState).validate()) {
  194. var a={selectDate,workingArea};
  195. print('我确定了$a');
  196. //验证通过提交数据
  197. }
  198. },
  199. child: const Text(
  200. "确定",
  201. style: TextStyle(
  202. fontSize: 18,
  203. color: Colors.white,
  204. fontWeight: FontWeight.bold),
  205. ),
  206. style: ButtonStyle(
  207. elevation: MaterialStateProperty.all(0),
  208. backgroundColor:
  209. MaterialStateProperty.all(const Color(0xFFFF703B)),
  210. shape: MaterialStateProperty.all(
  211. const RoundedRectangleBorder(
  212. borderRadius:
  213. BorderRadius.all(Radius.circular(24.4)))),
  214. ),
  215. ),
  216. ),
  217. ),
  218. Container(
  219. margin: EdgeInsets.fromLTRB(0, 30.w, 0, 30.w),
  220. alignment: Alignment.bottomCenter,
  221. child: SizedBox(
  222. width: 315.w,
  223. height: 49.h,
  224. child: ElevatedButton(
  225. onPressed: () {
  226. Get.back();
  227. },
  228. child: const Text(
  229. "取消",
  230. style: TextStyle(
  231. fontSize: 18,
  232. color: Color(0xFFFF703B),
  233. fontWeight: FontWeight.bold),
  234. ),
  235. style: ButtonStyle(
  236. side: MaterialStateProperty.all(
  237. BorderSide(width: 1, color: Color(0xFFFF703B))), //边框
  238. elevation: MaterialStateProperty.all(0),
  239. backgroundColor: MaterialStateProperty.all(Colors.white),
  240. shape: MaterialStateProperty.all(
  241. RoundedRectangleBorder(
  242. borderRadius:
  243. BorderRadius.all(Radius.circular(24.4))),
  244. ),
  245. ),
  246. ),
  247. ),
  248. ),
  249. ],
  250. ),
  251. ),
  252. );
  253. }
  254. }