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