Browse Source

Merge branch 'master' of http://git.ycjcjy.com/nanyang/farmer_client

张延森 3 years ago
parent
commit
66ba5a355f

+ 89
- 0
lib/components/UI/DefaultButton.dart View File

1
+import 'package:flutter/material.dart';
2
+
3
+
4
+
5
+class DefaultButton extends StatefulWidget {
6
+  //点击回调
7
+  final GestureTapCallback onPressed;
8
+  final String text;
9
+  final EdgeInsetsGeometry margin;
10
+  final double width;
11
+  final double height;
12
+  final double? fontSize;
13
+  final Color backColor;
14
+  final Color color;
15
+
16
+  EdgeInsetsGeometry marginDefault =
17
+  const EdgeInsets.fromLTRB(0, 90.0, 0, 30); //按钮默认的margin值
18
+
19
+  DefaultButton({
20
+    Key? key,
21
+    required this.onPressed,
22
+    required this.text,
23
+    required this.margin,
24
+    required this.width,
25
+    required this.height,
26
+    this.fontSize,
27
+    required this.backColor,
28
+    required this.color,
29
+  }) : super(key: key);
30
+
31
+  @override
32
+  State createState() {
33
+    if (margin == null) {
34
+      return _DefaultButtonState(onPressed, text, marginDefault,width,height,fontSize,backColor,color);
35
+    }
36
+    return _DefaultButtonState(onPressed, text, margin,width,height,fontSize,backColor,color);
37
+  }
38
+}
39
+
40
+class _DefaultButtonState extends State<DefaultButton> {
41
+  //点击回调
42
+  final GestureTapCallback onPressed;
43
+  final String text;
44
+  final EdgeInsetsGeometry margin;
45
+  final double width;
46
+  final double height;
47
+  final double? fontSize;
48
+  final Color backColor;
49
+  final Color color;
50
+  _DefaultButtonState(
51
+      this.onPressed,
52
+      this.text,
53
+      this.margin,
54
+      this.width,
55
+      this.height,
56
+      this.fontSize,
57
+      this.backColor,
58
+      this.color
59
+      );
60
+
61
+  @override
62
+  Widget build(BuildContext context) {
63
+    Widget _SectionBtn = Container(
64
+      margin: margin,
65
+      child: SizedBox(
66
+        width: width,
67
+        height: height,
68
+        child: RaisedButton(
69
+          color: backColor,
70
+          disabledColor: const Color(0xF5F6F7ff),
71
+          disabledTextColor: const Color(0xF5F6F7ff),
72
+          colorBrightness: Brightness.dark,
73
+          shape:
74
+          RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
75
+          child: Text(text,style:  TextStyle(
76
+              fontSize: fontSize,
77
+              color: color,
78
+          ),),
79
+          textColor: Colors.white,
80
+          onPressed: onPressed,
81
+        ),
82
+      ),
83
+    );
84
+
85
+    return _SectionBtn;
86
+  }
87
+
88
+}
89
+

lib/pages/home.dart → lib/models/Store.dart View File


+ 15
- 0
lib/models/User.dart View File

1
+
2
+import 'package:farmer_client/models/entities/person.dart';
3
+import 'package:get/get.dart';
4
+
5
+class User extends GetxController {
6
+  Person? _person;
7
+  Person? get person => _person;
8
+  set person (Person? p) {
9
+    _person = p;
10
+    update();
11
+  }
12
+
13
+  bool get isLogin => _person != null;
14
+
15
+}

+ 10
- 0
lib/models/app.dart View File

15
   final location = Rxn<LocationData>();
15
   final location = Rxn<LocationData>();
16
   final testInt = 1.obs;
16
   final testInt = 1.obs;
17
 
17
 
18
+  // get locationStr {
19
+  //   if(location.value!.longitude==null){
20
+  //     return null;
21
+  //
22
+  //   }else{
23
+  //   return location.value!.longitude.toString() + "," + location.value!.latitude.toString();
24
+  //
25
+  //   }
26
+  // }
27
+
18
   @override
28
   @override
19
   void onInit() {
29
   void onInit() {
20
     super.onInit();
30
     super.onInit();

+ 6
- 20
lib/pages/ArticleInfo/ArticleInfo.dart View File

1
 import 'package:flutter/material.dart';
1
 import 'package:flutter/material.dart';
2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3
 
3
 
4
-class ArticleInfo extends StatelessWidget {
5
-  const ArticleInfo({Key? key}) : super(key: key);
4
+import '../../widgets/layout/BasicPage.dart';
5
+
6
+class ArticleInfo extends BasicPage {
6
 
7
 
7
   @override
8
   @override
8
-  Widget build(BuildContext context) {
9
-    return Scaffold(
10
-      resizeToAvoidBottomInset: false,
11
-      appBar: AppBar(
12
-        elevation: 0,
13
-        centerTitle: true,
14
-        backgroundColor: Colors.white,
15
-        title: Text(
16
-          '资讯详情',
17
-          style: TextStyle(
18
-              color: Colors.black,
19
-              fontSize: 17.sp,
20
-              letterSpacing: 2,
21
-              fontWeight: FontWeight.bold),
22
-        ),
23
-      ),
24
-        body: Container(
9
+  Widget builder(BuildContext context) {
10
+    naviTitle='资讯详情';
11
+    return  Container(
25
           padding: EdgeInsets.fromLTRB(15, 30, 15, 50),
12
           padding: EdgeInsets.fromLTRB(15, 30, 15, 50),
26
 
13
 
27
           child: Column(
14
           child: Column(
59
               )
46
               )
60
             ],
47
             ],
61
           ),
48
           ),
62
-        ),
63
     );
49
     );
64
 
50
 
65
   }
51
   }

+ 10
- 1
lib/pages/TabBar/widgets/home/index.dart View File

4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
 import 'package:get/get.dart';
5
 import 'package:get/get.dart';
6
 import 'package:get/get_core/src/get_main.dart';
6
 import 'package:get/get_core/src/get_main.dart';
7
+import '../../../../models/app.dart';
7
 import '../../../../models/entities/banner.dart';
8
 import '../../../../models/entities/banner.dart';
8
 import '../../../../services/homeAPI.dart';
9
 import '../../../../services/homeAPI.dart';
9
 import '../../../../widgets/CarsCard.dart';
10
 import '../../../../widgets/CarsCard.dart';
10
-import '../../../../widgets/Search.dart';
11
+import 'package:farmer_client/models/app.dart';
11
 import '../../../MoreCars/index.dart';
12
 import '../../../MoreCars/index.dart';
12
 
13
 
13
 class HomePage extends StatefulWidget {
14
 class HomePage extends StatefulWidget {
17
   State<HomePage> createState() => _HomePageState();
18
   State<HomePage> createState() => _HomePageState();
18
 }
19
 }
19
 
20
 
21
+
20
 class _HomePageState extends State<HomePage> {
22
 class _HomePageState extends State<HomePage> {
21
   final CarouselController _controller = CarouselController();
23
   final CarouselController _controller = CarouselController();
22
   List<banner> BannerList = [];
24
   List<banner> BannerList = [];
24
   @override
26
   @override
25
   void initState() {
27
   void initState() {
26
     super.initState();
28
     super.initState();
29
+    final location = AppController.t.location;
30
+    print('location+$location');
31
+
27
     getHomeBanner('banner').then((value) {
32
     getHomeBanner('banner').then((value) {
28
       setState(() {
33
       setState(() {
29
         value.forEach((item) {
34
         value.forEach((item) {
31
         });
36
         });
32
       });
37
       });
33
     });
38
     });
39
+
40
+    // getMachinery(location.value!.longitude.toString()).then((value) {
41
+    //   print('$value');
42
+    // });
34
   }
43
   }
35
 
44
 
36
   @override
45
   @override

+ 11
- 18
lib/pages/TabBar/widgets/home/widgets/headers.dart View File

2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
2
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3
 import 'package:get/get.dart';
3
 import 'package:get/get.dart';
4
 
4
 
5
-
6
 class TypeHeader extends StatefulWidget {
5
 class TypeHeader extends StatefulWidget {
7
   TypeHeader({Key? key, required this.type}) : super(key: key);
6
   TypeHeader({Key? key, required this.type}) : super(key: key);
8
 
7
 
12
   State<TypeHeader> createState() => _TypeHeaderState();
11
   State<TypeHeader> createState() => _TypeHeaderState();
13
 }
12
 }
14
 
13
 
14
+
15
 class _TypeHeaderState extends State<TypeHeader> {
15
 class _TypeHeaderState extends State<TypeHeader> {
16
   @override
16
   @override
17
-  Widget build (BuildContext context) {
17
+  Widget build(BuildContext context) {
18
     if (widget.type) {
18
     if (widget.type) {
19
       return Container(
19
       return Container(
20
         child: Row(
20
         child: Row(
21
+          // mainAxisAlignment: MainAxisAlignment.start,
21
           children: [
22
           children: [
22
             Container(
23
             Container(
23
               height: 32.w,
24
               height: 32.w,
41
                       ),
42
                       ),
42
                     ),
43
                     ),
43
                   ),
44
                   ),
44
-        Container(
45
-          padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
46
-          child: Icon(Icons.arrow_drop_down),
47
-        ),
45
+                  Container(
46
+                    padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
47
+                    child: Icon(Icons.arrow_drop_down),
48
+                  ),
48
                   _initWidget(),
49
                   _initWidget(),
49
                 ],
50
                 ],
50
               ),
51
               ),
54
       );
55
       );
55
     } else {
56
     } else {
56
       return _initWidget();
57
       return _initWidget();
57
-
58
     }
58
     }
59
-
60
-
61
   }
59
   }
62
 }
60
 }
63
 //
61
 //
64
 
62
 
65
-
66
 class _initWidget extends StatelessWidget {
63
 class _initWidget extends StatelessWidget {
67
   const _initWidget({Key? key}) : super(key: key);
64
   const _initWidget({Key? key}) : super(key: key);
68
 
65
 
76
             onTap: () {
73
             onTap: () {
77
               print('点击了搜索');
74
               print('点击了搜索');
78
               Get.toNamed('/searchPage');
75
               Get.toNamed('/searchPage');
79
-
80
             },
76
             },
81
             child: Container(
77
             child: Container(
82
               decoration: const BoxDecoration(
78
               decoration: const BoxDecoration(
85
                 borderRadius: BorderRadius.all(Radius.circular(25)),
81
                 borderRadius: BorderRadius.all(Radius.circular(25)),
86
               ),
82
               ),
87
               child: Row(
83
               child: Row(
88
-                children: [
84
+                children: const [
89
                   Padding(
85
                   Padding(
90
-                    padding: EdgeInsets.fromLTRB(15, 0, 5, 0),
86
+                    padding: EdgeInsets.fromLTRB(5, 0, 5, 0),
91
                     child: Icon(
87
                     child: Icon(
92
                       Icons.search,
88
                       Icons.search,
93
                       size: 19,
89
                       size: 19,
101
                 ],
97
                 ],
102
               ),
98
               ),
103
             )
99
             )
104
-          // Search(),
105
-        ));
106
-
100
+            // Search(),
101
+            ));
107
   }
102
   }
108
 }
103
 }
109
-
110
-

+ 12
- 8
lib/pages/login/login.dart View File

135
             mainAxisAlignment: MainAxisAlignment.end,
135
             mainAxisAlignment: MainAxisAlignment.end,
136
             crossAxisAlignment: CrossAxisAlignment.start,
136
             crossAxisAlignment: CrossAxisAlignment.start,
137
             children:[
137
             children:[
138
-              const Text(
138
+              Padding(padding: EdgeInsets.fromLTRB(15, 0, 0, 5),
139
+              child:    const Text(
139
                 '您好!',
140
                 '您好!',
140
                 style: TextStyle(
141
                 style: TextStyle(
141
                   fontWeight: FontWeight.bold,
142
                   fontWeight: FontWeight.bold,
142
-                  fontSize: 50,
143
+                  fontSize: 33,
143
                 ),
144
                 ),
144
               ),
145
               ),
145
-              const Text(
146
-                '欢迎进入农户端应用!',
147
-                style: TextStyle(
148
-                  fontWeight: FontWeight.bold,
149
-                  fontSize: 35,
146
+              ),
147
+              Padding(padding: EdgeInsets.fromLTRB(15, 0, 0, 0),
148
+                child:    const Text(
149
+                  '欢迎进入农户端应用!',
150
+                  style: TextStyle(
151
+                    fontWeight: FontWeight.bold,
152
+                    fontSize: 27,
153
+                  ),
150
                 ),
154
                 ),
151
               ),
155
               ),
156
+
152
               Cell(
157
               Cell(
153
                 // margin: EdgeInsets.symmetric(horizontal: 13.w),
158
                 // margin: EdgeInsets.symmetric(horizontal: 13.w),
154
                   margin: const EdgeInsets.fromLTRB(13, 43, 10, 0),
159
                   margin: const EdgeInsets.fromLTRB(13, 43, 10, 0),
178
                     },
183
                     },
179
                   ),
184
                   ),
180
                   footer: SizedBox(
185
                   footer: SizedBox(
181
-                    width: 300.w,
182
                     child: ElevatedButton(
186
                     child: ElevatedButton(
183
                       onPressed: () => {
187
                       onPressed: () => {
184
                         setState(() {
188
                         setState(() {

+ 14
- 75
lib/pages/orderInfo/index.dart View File

5
 import 'package:get/get.dart';
5
 import 'package:get/get.dart';
6
 
6
 
7
 import '../../widgets/OrderInfoCard.dart';
7
 import '../../widgets/OrderInfoCard.dart';
8
+import '../../widgets/layout/BasicPage.dart';
8
 
9
 
9
-class OrderPageInfo extends StatefulWidget {
10
-  const OrderPageInfo({Key? key}) : super(key: key);
10
+// class OrderPageInfo extends StatefulWidget {
11
+//   const OrderPageInfo({Key? key}) : super(key: key);
12
+//
13
+//   @override
14
+//   State<OrderPageInfo> createState() => _OrderPageInfoState();
15
+// }
11
 
16
 
17
+class OrderPageInfo extends BasicPage {
12
   @override
18
   @override
13
-  State<OrderPageInfo> createState() => _OrderPageInfoState();
14
-}
15
 
19
 
16
-class _OrderPageInfoState extends State<OrderPageInfo> {
20
+
17
   void onCancel() {
21
   void onCancel() {
18
-    showDialog(
19
-        context: context,
20
-        builder: (context) {
21
-          return AlertDialog(content: Text("您确定要取消订单吗?"), actions: <Widget>[
22
-            TextButton(
23
-              child: Text("取消"),
24
-              onPressed: () {
25
-                print("取消");
26
-                Navigator.pop(context, 'Cancle');
27
-              },
28
-            ),
29
-            TextButton(
30
-                child: Text("确定"),
31
-                onPressed: () {
32
-                  // setState(() {
33
-                  //   addressList.remove(addressList[e]);
34
-                  // });
35
-                  Navigator.pop(context, "Ok");
36
-                  Fluttertoast.showToast(msg: '取消成功!');
37
-                  Get.offAllNamed('/');
38
-                })
39
-          ]);
40
-        });
22
+
41
   }
23
   }
42
 
24
 
43
   @override
25
   @override
44
-  Widget build(BuildContext context) {
45
-    return Scaffold(
46
-      resizeToAvoidBottomInset: false,
47
-      appBar: AppBar(
48
-        elevation: 0,
49
-        centerTitle: true,
50
-        backgroundColor: Colors.white,
51
-        title: Text(
52
-          '订单详情',
53
-          style: TextStyle(
54
-              color: Colors.black,
55
-              fontSize: 17.sp,
56
-              letterSpacing: 2,
57
-              fontWeight: FontWeight.bold),
58
-        ),
59
-      ),
60
-      body: Column(
26
+  Widget builder (BuildContext context) {
27
+    naviTitle= '订单详情';
28
+    return  Column(
61
         children: [
29
         children: [
62
           OrderInfoCard(),
30
           OrderInfoCard(),
63
           Spacer(),
31
           Spacer(),
109
               ],
77
               ],
110
             ),
78
             ),
111
           ),
79
           ),
112
-          // Container(
113
-          //   height: 130.h,
114
-          //   margin: EdgeInsets.only(top: 20.0, bottom: 0.0),
115
-          //   alignment: Alignment.bottomCenter,
116
-          //   child: SizedBox(
117
-          //     width: 315.w,
118
-          //     height: 49.h,
119
-          //     child: ElevatedButton(
120
-          //       onPressed: () {
121
-          //         // _handelSubmit();
122
-          //         print('用户点击了支付啊阿松大撒地方');
123
-          //       },
124
-          //       child: const Text(
125
-          //         "支付",
126
-          //         style: TextStyle(
127
-          //             fontSize: 18,
128
-          //             color: Colors.white,
129
-          //             fontWeight: FontWeight.bold),
130
-          //       ),
131
-          //       style: ButtonStyle(
132
-          //         elevation: MaterialStateProperty.all(0),
133
-          //         backgroundColor:
134
-          //             MaterialStateProperty.all(const Color(0xFFFF703B)),
135
-          //         shape: MaterialStateProperty.all(const RoundedRectangleBorder(
136
-          //             borderRadius: BorderRadius.all(Radius.circular(24.4)))),
137
-          //       ),
138
-          //     ),
139
-          //   ),
140
-          // ),
141
         ],
80
         ],
142
-      ),
143
     );
81
     );
82
+
144
   }
83
   }
145
 }
84
 }

+ 34
- 30
lib/pages/splash/splash.dart View File

1
-
2
 import 'package:farmer_client/pages/splash/widgets/countdown.dart';
1
 import 'package:farmer_client/pages/splash/widgets/countdown.dart';
3
 import 'package:get/get.dart';
2
 import 'package:get/get.dart';
4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
3
 import 'package:flutter_screenutil/flutter_screenutil.dart';
5
 import 'package:flutter/material.dart';
4
 import 'package:flutter/material.dart';
5
+import 'package:get_storage/get_storage.dart';
6
 
6
 
7
-import '../TabBar/index.dart';
8
 
7
 
9
 class SplashScreen extends StatefulWidget {
8
 class SplashScreen extends StatefulWidget {
10
   const SplashScreen({Key? key}) : super(key: key);
9
   const SplashScreen({Key? key}) : super(key: key);
14
 }
13
 }
15
 
14
 
16
 class _SplashScreen extends State<SplashScreen> {
15
 class _SplashScreen extends State<SplashScreen> {
16
+  GetStorage box = GetStorage();
17
   handleOnFinish() {
17
   handleOnFinish() {
18
-    Get.off(Home());
19
-    // Get.toNamed("/addressList");
18
+    bool isLogin = box.hasData('token');
19
+    if (isLogin) {
20
+      Get.offNamed('/');
21
+    } else {
22
+      Get.offNamed('/login');
23
+    }
20
   }
24
   }
21
 
25
 
22
   @override
26
   @override
23
   Widget build(BuildContext context) {
27
   Widget build(BuildContext context) {
24
     return Scaffold(
28
     return Scaffold(
25
         body: Container(
29
         body: Container(
26
-          decoration: const BoxDecoration(
27
-            image: DecorationImage(
28
-                image: AssetImage("images/splash.png"),
29
-                fit: BoxFit.cover,
30
-                alignment: Alignment.topCenter),
30
+      decoration: const BoxDecoration(
31
+        image: DecorationImage(
32
+            image: AssetImage("images/splash.png"),
33
+            fit: BoxFit.cover,
34
+            alignment: Alignment.topCenter),
35
+      ),
36
+      child: Stack(
37
+        children: [
38
+          Positioned(
39
+            right: 15.w,
40
+            top: 50.h,
41
+            child: countdown(3, handleOnFinish),
31
           ),
42
           ),
32
-          child: Stack(
33
-            children: [
34
-              Positioned(
35
-                right: 15.w,
36
-                top: 50.h,
37
-                child: countdown(3, handleOnFinish),
38
-              ),
39
-              Positioned(
40
-                bottom: 0,
41
-                child: Container(
42
-                  width: 375.w,
43
-                  height: 60.w,
44
-                  child: Center(
45
-                    child: Image.asset(
46
-                      'images/logo.png',
47
-                      width: 218.w,
48
-                      height: 50.w,
49
-                    ),
50
-                  ),
43
+          Positioned(
44
+            bottom: 0,
45
+            child: Container(
46
+              width: 375.w,
47
+              height: 60.w,
48
+              child: Center(
49
+                child: Image.asset(
50
+                  'images/logo.png',
51
+                  width: 218.w,
52
+                  height: 50.w,
51
                 ),
53
                 ),
52
               ),
54
               ),
53
-            ],
55
+            ),
54
           ),
56
           ),
55
-        ));
57
+        ],
58
+      ),
59
+    ));
56
   }
60
   }
57
 }
61
 }