李志伟 3 年 前
コミット
0ae9c93977
共有2 個のファイルを変更した35 個の追加31 個の削除を含む
  1. 34
    30
      lib/pages/splash/splash.dart
  2. 1
    1
      lib/routes/pages.dart

+ 34
- 30
lib/pages/splash/splash.dart ファイルの表示

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
 }

+ 1
- 1
lib/routes/pages.dart ファイルの表示

17
 List<GetPage> pages = [
17
 List<GetPage> pages = [
18
   GetPage(name: '/', page: () =>  Home()),
18
   GetPage(name: '/', page: () =>  Home()),
19
   GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
19
   GetPage(name: '/ArticleInfo', page: () =>  ArticleInfo()),//资讯详情
20
-  GetPage(name: '/splash', page: () => MachineryMapPage()),//SplashScreen
20
+  GetPage(name: '/splash', page: () => SplashScreen()),//SplashScreen
21
   GetPage(name: '/login', page: () =>  MyRouteLogin()),
21
   GetPage(name: '/login', page: () =>  MyRouteLogin()),
22
   GetPage(name: '/addressList', page: () =>  AddressList()),
22
   GetPage(name: '/addressList', page: () =>  AddressList()),
23
   GetPage(name: '/addAddress', page: () =>  AddAddress()),
23
   GetPage(name: '/addAddress', page: () =>  AddAddress()),