Просмотр исходного кода

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

[baozhangchao] 3 лет назад
Родитель
Сommit
17fa8c1b40

+ 89
- 0
lib/components/UI/DefaultButton.dart Просмотреть файл

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
+

+ 15
- 0
lib/models/User.dart Просмотреть файл

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

+ 11
- 0
lib/pages/TabBar/Information_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class InformationPage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    // TODO: implement build
7
+    return Scaffold(
8
+      body: Center(child: Text('资讯')),
9
+    );
10
+  }
11
+}

+ 11
- 0
lib/pages/TabBar/Mine_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class MinePage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    // TODO: implement build
7
+    return Scaffold(
8
+      body: Center(child: Text('我的')),
9
+    );
10
+  }
11
+}

+ 11
- 0
lib/pages/TabBar/Orders_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class OrdersPage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    // TODO: implement build
7
+    return Scaffold(
8
+      body: Center(child: Text('订单')),
9
+    );
10
+  }
11
+}

+ 10
- 0
lib/pages/TabBar/home_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+
3
+class HomePage extends StatelessWidget {
4
+  @override
5
+  Widget build(BuildContext context) {
6
+    return Scaffold(
7
+      body: Center(child: Text('首页')),
8
+    );
9
+  }
10
+}

+ 71
- 0
lib/pages/TabBar/index_page.dart Просмотреть файл

1
+import 'package:flutter/material.dart';
2
+import 'package:flutter/cupertino.dart';
3
+import 'home_page.dart';
4
+import 'Information_page.dart';
5
+import 'Mine_page.dart';
6
+import 'Orders_page.dart';
7
+
8
+class IndexPage extends StatefulWidget {
9
+  _IndexPageState createState() => _IndexPageState();
10
+}
11
+
12
+class _IndexPageState extends State<IndexPage> {
13
+
14
+
15
+  final List<BottomNavigationBarItem> bottomTabs = [
16
+     BottomNavigationBarItem(
17
+      icon: Icon(CupertinoIcons.home),
18
+      title: Text('首页'),
19
+    ),
20
+     BottomNavigationBarItem(
21
+      icon: Icon(CupertinoIcons.search),
22
+      title: Text('资讯'),
23
+
24
+    ),
25
+     BottomNavigationBarItem(
26
+      icon: Icon(CupertinoIcons.shopping_cart),
27
+      title: Text('订单'),
28
+
29
+    ),
30
+     BottomNavigationBarItem(
31
+      icon: Icon(CupertinoIcons.profile_circled),
32
+      title: Text('我的'),
33
+    ),
34
+  ];
35
+
36
+  final List tabBodies = [
37
+    HomePage(),
38
+    InformationPage(),
39
+    OrdersPage(),
40
+    MinePage(),
41
+  ];
42
+
43
+  int currentIndex = 0;
44
+  var currentPage;
45
+
46
+  @override
47
+  void initState() {
48
+    super.initState();
49
+    currentPage = tabBodies[currentIndex];
50
+  }
51
+
52
+  @override
53
+  Widget build(BuildContext context) {
54
+    // TODO: implement build
55
+    return Scaffold(
56
+      backgroundColor: Color.fromRGBO(244, 245, 245, 1),
57
+      bottomNavigationBar: BottomNavigationBar(
58
+        type: BottomNavigationBarType.fixed,
59
+        currentIndex: currentIndex,
60
+        items: bottomTabs,
61
+        onTap: (index){
62
+          setState(() {
63
+            currentIndex = index;
64
+            currentPage = tabBodies[currentIndex];
65
+          });
66
+        },
67
+      ),
68
+      body: currentPage,
69
+    );
70
+  }
71
+}

+ 1
- 0
lib/pages/TabBar/member_page.dart Просмотреть файл

1
+// TODO Implement this library.