Ver código fonte

adssccs and order and Confirmation

[baozhangchao] 3 anos atrás
pai
commit
8b594de8a2

+ 17
- 0
lib/main.dart Ver arquivo

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

+ 267
- 0
lib/pages/OrderConfirmation/index.dart Ver arquivo

@@ -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
+

+ 0
- 0
lib/pages/OrderConfirmation/widgets/timeDatePicker.dart Ver arquivo


+ 2
- 1
lib/routes/pages.dart Ver arquivo

@@ -2,13 +2,14 @@
2 2
 import 'package:farmer_client/pages/ArticleInfo/ArticleInfo.dart';
3 3
 import 'package:farmer_client/pages/addressList/index.dart';
4 4
 import 'package:get/get.dart';
5
+import '../pages/OrderConfirmation/index.dart';
5 6
 import '../pages/index.dart';//Home
6 7
 
7 8
 
8 9
 List<GetPage> pages = [
9 10
 GetPage(name: '/', page: () =>  Home()),
10 11
 GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
11
-GetPage(name: '/splash', page: () => SplashScreen()),
12
+GetPage(name: '/splash', page: () => SplashScreen()),//SplashScreen
12 13
 GetPage(name: '/login', page: () =>  MyRouteLogin()),
13 14
 GetPage(name: '/addressList', page: () =>  AddressList()),
14 15
 ];

+ 5
- 0
lib/widgets/CarsCard.dart Ver arquivo

@@ -1,6 +1,10 @@
1 1
 import 'package:flutter/foundation.dart';
2 2
 import 'package:flutter/material.dart';
3 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 9
 // class CarItem {
6 10
 //   late String name;
@@ -83,6 +87,7 @@ class CarsCard extends StatelessWidget {
83 87
                     height: 44.h, //+10
84 88
                     child: ElevatedButton(
85 89
                       onPressed: () {
90
+                        Get.to(OrderConfirmation());
86 91
                         print('点我去预约');
87 92
                       },
88 93
                       child: const Text(

+ 12
- 0
pubspec.lock Ver arquivo

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

+ 8
- 23
pubspec.yaml Ver arquivo

@@ -27,10 +27,14 @@ environment:
27 27
 # the latest version available on pub.dev. To see which dependencies have newer
28 28
 # versions available, run `flutter pub outdated`.
29 29
 dependencies:
30
+  # 添加国际化
31
+  flutter_localizations:
32
+    sdk: flutter
30 33
   flutter:
31 34
     sdk: flutter
32 35
 
33 36
 
37
+
34 38
   # The following adds the Cupertino Icons font to your application.
35 39
   # Use with the CupertinoIcons class for iOS style icons.
36 40
   cupertino_icons: ^1.0.2
@@ -42,6 +46,8 @@ dependencies:
42 46
   fluttertoast: ^8.0.9
43 47
   location: ^4.3.0
44 48
 
49
+
50
+
45 51
 dev_dependencies:
46 52
   flutter_test:
47 53
     sdk: flutter
@@ -67,29 +73,8 @@ flutter:
67 73
   uses-material-design: true
68 74
   # To add images to your application, add an images section, like this:
69 75
   assets:
70
-    - images/icon_login.png
71
-    - images/phoneCode.png
72
-    - images/index/HomesNOImgaes.png
73
-    - images/index/HomesOFFImgaes.png
74
-    - images/index/MineNOImgaes.png
75
-    - images/index/MineOFFImgaes.png
76
-    - images/index/newsOFFImages.png
77
-    - images/index/newsONImages.png
78
-    - images/index/OrdersNOImgaes.png
79
-    - images/index/OrdersOFFImgaes.png
80
-    - images/cars.png
81
-    - images/gpsImgae.png
82
-    - images/ordersLeft.png
83
-    - images/mineBack.png
84
-    - images/userMoren.png
85
-    - images/aboutUs.png
86
-    - images/feedbacks.png
87
-    - images/userRight.png
88
-    - images/versionUpdate.png
89
-    - images/logo.png
90
-    - images/splash.png
91
-    - images/icons/decorate.png
92
-    - images/ordersListImga.png
76
+    - images/icons/
77
+    - images/
93 78
 
94 79
   # An image asset can refer to one or more resolution-specific "variants", see
95 80
   # https://flutter.dev/assets-and-images/#resolution-aware.