李志伟 3 年之前
父節點
當前提交
e0bc749929

+ 17
- 0
lib/main.dart 查看文件

5
 import 'package:get_storage/get_storage.dart';
5
 import 'package:get_storage/get_storage.dart';
6
 import 'package:flutter_screenutil/flutter_screenutil.dart';
6
 import 'package:flutter_screenutil/flutter_screenutil.dart';
7
 
7
 
8
+import 'package:flutter_localizations/flutter_localizations.dart';
9
+
8
 import 'models/index.dart';
10
 import 'models/index.dart';
9
 import 'routes/index.dart';
11
 import 'routes/index.dart';
10
 
12
 
11
 void main() async {
13
 void main() async {
12
   await GetStorage.init();
14
   await GetStorage.init();
13
 
15
 
16
+
14
   runApp(const MyApp());
17
   runApp(const MyApp());
15
 }
18
 }
16
 
19
 
17
 class MyApp extends StatelessWidget {
20
 class MyApp extends StatelessWidget {
18
   const MyApp({Key? key}) : super(key: key);
21
   const MyApp({Key? key}) : super(key: key);
19
 
22
 
23
+
24
+
20
   // This widget is the root of your application.
25
   // This widget is the root of your application.
21
   @override
26
   @override
22
   Widget build(BuildContext context) {
27
   Widget build(BuildContext context) {
28
+
23
     GetStorage box = GetStorage();
29
     GetStorage box = GetStorage();
24
 
30
 
25
     return ScreenUtilInit(
31
     return ScreenUtilInit(
28
       splitScreenMode: true,
34
       splitScreenMode: true,
29
       builder: (_) {
35
       builder: (_) {
30
         return GetMaterialApp(
36
         return GetMaterialApp(
37
+          localizationsDelegates: const [
38
+            GlobalMaterialLocalizations.delegate,
39
+            GlobalWidgetsLocalizations.delegate,
40
+            GlobalCupertinoLocalizations.delegate,
41
+          ],
42
+          supportedLocales: [
43
+            Locale('zh', ''),
44
+            Locale('en', ''),
45
+          ],
46
+
31
           theme: getTheme(),
47
           theme: getTheme(),
32
           initialRoute: '/splash',
48
           initialRoute: '/splash',
33
           defaultTransition: Transition.native,
49
           defaultTransition: Transition.native,
34
           routingCallback: routingCallback,
50
           routingCallback: routingCallback,
35
           initialBinding: AppBindings(),
51
           initialBinding: AppBindings(),
36
           getPages: pages,
52
           getPages: pages,
53
+
37
         );
54
         );
38
       },
55
       },
39
     );
56
     );

+ 267
- 0
lib/pages/OrderConfirmation/index.dart 查看文件

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
+

+ 0
- 0
lib/pages/OrderConfirmation/widgets/timeDatePicker.dart 查看文件


+ 1
- 1
lib/routes/pages.dart 查看文件

9
 List<GetPage> pages = [
9
 List<GetPage> pages = [
10
 GetPage(name: '/', page: () =>  Home()),
10
 GetPage(name: '/', page: () =>  Home()),
11
 GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
11
 GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
12
-GetPage(name: '/splash', page: () => SplashScreen()),
12
+GetPage(name: '/splash', page: () => SplashScreen()),//SplashScreen
13
 GetPage(name: '/login', page: () =>  MyRouteLogin()),
13
 GetPage(name: '/login', page: () =>  MyRouteLogin()),
14
 GetPage(name: '/addressList', page: () =>  AddressList()),
14
 GetPage(name: '/addressList', page: () =>  AddressList()),
15
 GetPage(name: '/addAddress', page: () =>  AddAddress()),
15
 GetPage(name: '/addAddress', page: () =>  AddAddress()),

+ 5
- 0
lib/widgets/CarsCard.dart 查看文件

1
 import 'package:flutter/foundation.dart';
1
 import 'package:flutter/foundation.dart';
2
 import 'package:flutter/material.dart';
2
 import 'package:flutter/material.dart';
3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
+import 'package:get/get.dart';
5
+import 'package:get/get_core/src/get_main.dart';
6
+
7
+import '../pages/OrderConfirmation/index.dart';
4
 
8
 
5
 // class CarItem {
9
 // class CarItem {
6
 //   late String name;
10
 //   late String name;
83
                     height: 44.h, //+10
87
                     height: 44.h, //+10
84
                     child: ElevatedButton(
88
                     child: ElevatedButton(
85
                       onPressed: () {
89
                       onPressed: () {
90
+                        Get.to(OrderConfirmation());
86
                         print('点我去预约');
91
                         print('点我去预约');
87
                       },
92
                       },
88
                       child: const Text(
93
                       child: const Text(

+ 12
- 0
pubspec.lock 查看文件

153
       url: "https://pub.flutter-io.cn"
153
       url: "https://pub.flutter-io.cn"
154
     source: hosted
154
     source: hosted
155
     version: "1.0.4"
155
     version: "1.0.4"
156
+  flutter_localizations:
157
+    dependency: "direct main"
158
+    description: flutter
159
+    source: sdk
160
+    version: "0.0.0"
156
   flutter_screenutil:
161
   flutter_screenutil:
157
     dependency: "direct main"
162
     dependency: "direct main"
158
     description:
163
     description:
205
       url: "https://pub.flutter-io.cn"
210
       url: "https://pub.flutter-io.cn"
206
     source: hosted
211
     source: hosted
207
     version: "4.0.0"
212
     version: "4.0.0"
213
+  intl:
214
+    dependency: transitive
215
+    description:
216
+      name: intl
217
+      url: "https://pub.flutter-io.cn"
218
+    source: hosted
219
+    version: "0.17.0"
208
   js:
220
   js:
209
     dependency: transitive
221
     dependency: transitive
210
     description:
222
     description:

+ 6
- 0
pubspec.yaml 查看文件

27
 # the latest version available on pub.dev. To see which dependencies have newer
27
 # the latest version available on pub.dev. To see which dependencies have newer
28
 # versions available, run `flutter pub outdated`.
28
 # versions available, run `flutter pub outdated`.
29
 dependencies:
29
 dependencies:
30
+  # 添加国际化
31
+  flutter_localizations:
32
+    sdk: flutter
30
   flutter:
33
   flutter:
31
     sdk: flutter
34
     sdk: flutter
32
 
35
 
33
 
36
 
37
+
34
   # The following adds the Cupertino Icons font to your application.
38
   # The following adds the Cupertino Icons font to your application.
35
   # Use with the CupertinoIcons class for iOS style icons.
39
   # Use with the CupertinoIcons class for iOS style icons.
36
   cupertino_icons: ^1.0.2
40
   cupertino_icons: ^1.0.2
42
   fluttertoast: ^8.0.9
46
   fluttertoast: ^8.0.9
43
   location: ^4.3.0
47
   location: ^4.3.0
44
 
48
 
49
+
50
+
45
 dev_dependencies:
51
 dev_dependencies:
46
   flutter_test:
52
   flutter_test:
47
     sdk: flutter
53
     sdk: flutter