李志伟 3 years ago
parent
commit
12e293a27b

BIN
images/logo.png View File


BIN
images/splash.png View File


+ 2
- 7
lib/pages/Login/index.dart View File

@@ -102,11 +102,6 @@ class _Login extends State<Login> {
102 102
 
103 103
   @override
104 104
   Widget build(BuildContext context) {
105
-    ScreenUtil.init(context,
106
-        designSize: const Size(375, 812),
107
-        minTextAdapt: true,
108
-        orientation: Orientation.portrait);
109
-
110 105
     return Scaffold(
111 106
       resizeToAvoidBottomInset: false,
112 107
       body: Container(
@@ -212,8 +207,8 @@ class _Login extends State<Login> {
212 207
                         Positioned(
213 208
                           child: Image.asset(
214 209
                             "images/login/VerificationCode.png",
215
-                            width: 20.h,
216
-                            height: 20.h,
210
+                            width: 20.w,
211
+                            height: 20.w,
217 212
                           ),
218 213
                         ),
219 214
                       ],

+ 77
- 47
lib/pages/home/index.dart View File

@@ -1,3 +1,4 @@
1
+import 'package:flutter/cupertino.dart';
1 2
 import 'package:flutter/material.dart';
2 3
 import 'package:get/get.dart';
3 4
 import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -8,16 +9,56 @@ class Home extends StatefulWidget {
8 9
   @override
9 10
   _Home createState() => _Home();
10 11
 }
11
-class _Home extends State<Home> {
12 12
 
13
+class _Home extends State<Home> {
13 14
   List images = [
14 15
     ['images/index/index.png', 'images/index/indexActive.png'],
15 16
     ['images/index/job.png', 'images/index/jobActive.png'],
16 17
     ['images/index/user.png', 'images/index/userActive.png'],
17 18
   ];
18 19
 
19
-  final List _titles = ['首页', '好物', '双11'];
20
+  final List _titles = ['首页', '订单列表', '个人中心'];
20 21
   int _currentIndex = 0;
22
+  final tabTextStyleSelected =
23
+      TextStyle(color: const Color(0xFF06B03B),fontSize: 15.sp,fontWeight: FontWeight.bold); //选线卡选中字体颜色
24
+  final tabTextStyleNormal =
25
+      TextStyle(color: const Color(0xFF323232),fontSize: 15.sp,fontWeight: FontWeight.bold); //选项卡未选中字体颜色
26
+  int _tabIndex = 0; //选项卡下标
27
+
28
+  var _body = [Text('我是首页'), Text('我是订单列表'), Text('我是个人中心')];
29
+  TextStyle getTabTextStyle(int curIndex) {
30
+    //设置tabbar 选中和未选中的状态文本
31
+    if (curIndex == _tabIndex) {
32
+      return tabTextStyleSelected;
33
+    }
34
+    return tabTextStyleNormal;
35
+  }
36
+
37
+  Image getTabIcon(int curIndex) {
38
+    //设置tabbar选中和未选中的状态图标
39
+    if (curIndex == _tabIndex) {
40
+      return Image.asset(
41
+        images[curIndex][1],
42
+        width: 20.w,
43
+        height: 20.w,
44
+      );
45
+    }
46
+    return Image.asset(
47
+      images[curIndex][0],
48
+      width: 20.w,
49
+      height: 20.w,
50
+    );
51
+  }
52
+
53
+  Image getTabImage(path) {
54
+    return Image.asset(path, width: 26.w, height: 26.w);
55
+  }
56
+
57
+  // 切换底部选项卡,标题的变化设置
58
+  Text getTabTitle(int curIndex) {
59
+    return Text(_titles[curIndex], style: getTabTextStyle(curIndex));
60
+  }
61
+
21 62
   @override
22 63
   Widget build(BuildContext context) {
23 64
     return Scaffold(
@@ -27,53 +68,42 @@ class _Home extends State<Home> {
27 68
         backgroundColor: Colors.white,
28 69
         title: Text(
29 70
           '首页',
30
-          style:
31
-          TextStyle(color: Colors.black, fontSize: 17.sp, letterSpacing: 2),
71
+          style: TextStyle(
72
+              color: Colors.black,
73
+              fontSize: 17.sp,
74
+              letterSpacing: 2,
75
+              fontWeight: FontWeight.bold
76
+          ),
32 77
         ),
33 78
       ),
79
+      body: _body[_tabIndex],
80
+      bottomNavigationBar: Container(
81
+        height: 65.h,
34 82
 
83
+        child: Row(
84
+          mainAxisAlignment: MainAxisAlignment.spaceAround,
85
+          children: [
86
+            Column(
87
+              children: [
88
+                getTabIcon(0),
89
+                getTabTitle(0)
90
+              ],
91
+            ),
92
+            Column(
93
+              children: [
94
+                getTabIcon(1),
95
+                getTabTitle(1)
96
+              ],
97
+            ),
98
+            Column(
99
+              children: [
100
+                getTabIcon(2),
101
+                getTabTitle(2)
102
+              ],
103
+            ),
104
+          ],
105
+        ),
106
+      ),
35 107
     );
36 108
   }
37
-  }
38
-// class Home extends StatelessWidget {
39
-//   @override
40
-//   Widget build(BuildContext context) {
41
-//     // controller.person
42
-//     return Scaffold(
43
-//       appBar: AppBar(
44
-//         elevation: 0,
45
-//         centerTitle: true,
46
-//         backgroundColor: Colors.white,
47
-//         title: Text(
48
-//           '首页',
49
-//           style:
50
-//               TextStyle(color: Colors.black, fontSize: 17.sp, letterSpacing: 2),
51
-//         ),
52
-//       ),
53
-//       body: GestureDetector(
54
-//         onTap: () {
55
-//           Get.snackbar(
56
-//             "Hey i'm a Get SnackBar!", // title
57
-//             "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message
58
-//             icon: Icon(Icons.alarm),
59
-//             shouldIconPulse: true,
60
-//             barBlur: 20,
61
-//             isDismissible: true,
62
-//             duration: Duration(seconds: 3),
63
-//           );
64
-//           // Get.snackbar('Hi', 'i am a modern snackbar');
65
-//         },
66
-//         child: const Text("首页内容"),
67
-//       ),
68
-//       bottomNavigationBar: BottomNavigationBar(
69
-//         items: const <BottomNavigationBarItem>[
70
-//           BottomNavigationBarItem(title: Text('首页'),icon: Icon(Icons.home)),
71
-//           BottomNavigationBarItem(title: Text('书籍'),icon: Icon(Icons.book)),
72
-//           BottomNavigationBarItem(title: Text('我的'),icon: Icon(Icons.perm_identity)),
73
-//         ],
74
-//       ),
75
-//     );
76
-//   }
77
-// }
78
-
79
-
109
+}

+ 46
- 4
lib/pages/splash/splash.dart View File

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

+ 26
- 25
lib/pages/splash/widgets/countdown.dart View File

@@ -1,31 +1,9 @@
1
-
2 1
 import 'dart:async';
3 2
 
4 3
 import '../../../utils/timer.dart';
5 4
 import 'package:flutter/widgets.dart';
6 5
 import 'package:get/get.dart';
7
-
8
-// Widget countdown(void Function() onFinish) {
9
-//   int _countdown = 3;
10
-//   late StateSetter _update;
11
-//   late Timer _timer;
12
-//   _timer = setInterval((_) {
13
-//     if (_countdown <= 1) {
14
-//       _timer.cancel();
15
-//       onFinish();
16
-//       return;
17
-//     }
18
-//
19
-//     _update((){
20
-//       _countdown -= 1;
21
-//     });
22
-//   }, 1000);
23
-//
24
-//   return StatefulBuilder(builder: (context, setState) {
25
-//     _update = setState;
26
-//     return Text(_countdown.toString());
27
-//   });
28
-// }
6
+import 'package:flutter_screenutil/flutter_screenutil.dart';
29 7
 
30 8
 Widget countdown(int sec, void Function() onFinish) {
31 9
   var _countdown = Rx<int>(sec);
@@ -37,9 +15,32 @@ Widget countdown(int sec, void Function() onFinish) {
37 15
       onFinish();
38 16
       return;
39 17
     }
40
-
41 18
     _countdown.value -= 1;
42 19
   }, 1000);
43 20
 
44
-  return Obx(() =>Text(_countdown.value.toString()));
21
+  return Obx(
22
+    () => GestureDetector(
23
+      onTap: () {
24
+        _timer.cancel();
25
+        // return;
26
+        // onFinish();
27
+      },
28
+      child: Container(
29
+        width: 50.w,
30
+        height: 30.h,
31
+        alignment: const Alignment(0, 0),
32
+        decoration: const BoxDecoration(
33
+            borderRadius: BorderRadius.all(Radius.circular(20)),
34
+            color: Color(0x77222222)),
35
+        child: Text(
36
+          _countdown.value.toString() + '跳过',
37
+          style: TextStyle(
38
+              fontSize: 13.sp,
39
+              letterSpacing: 2,
40
+              color: const Color(0xFFFFFFFF),
41
+              decoration: TextDecoration.none),
42
+        ),
43
+      ),
44
+    ),
45
+  );
45 46
 }

+ 2
- 0
pubspec.yaml View File

@@ -81,6 +81,8 @@ flutter:
81 81
     - images/index/search.png
82 82
     - images/index/user.png
83 83
     - images/index/userActive.png
84
+    - images/splash.png
85
+    - images/logo.png
84 86
   # To add assets to your application, add an assets section, like this:
85 87
   # assets:
86 88
   #   - images/a_dot_burr.jpeg