ソースを参照

完善隐私政策功能

云天逵 1 年間 前
コミット
033af4a466

BIN
assets/anim/anim_privacy.zip


+ 40 - 34
lib/dialog/privacy_dialog.dart

@@ -8,7 +8,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
 import 'package:lottie/lottie.dart';
 
-void privacyDialog() {
+void privacyDialog({required Function onAgree, required Function onDisagree}) {
   const tag = 'privacyDialog';
   SmartDialog.show(
       tag: tag,
@@ -25,20 +25,25 @@ void privacyDialog() {
                 child: Column(
                   crossAxisAlignment: CrossAxisAlignment.start,
                   children: [
-                    Container(
-                      margin: EdgeInsets.only(left: 16.w, top: 16.h),
-                      width: 28.w,
-                      height: 28.w,
-                      decoration: ShapeDecoration(
-                        color: Color(0xFF2A3E55),
-                        shape: RoundedRectangleBorder(
-                          borderRadius: BorderRadius.circular(86.r),
-                        ),
-                        image: DecorationImage(
-                          image: Assets.images.iconPrivateClose.provider(),
-                        ),
-                      ),
-                    ),
+                    GestureDetector(
+                        onTap: () {
+                          onDisagree();
+                          SmartDialog.dismiss(tag: tag);
+                        },
+                        child: Container(
+                          margin: EdgeInsets.only(left: 16.w, top: 16.h),
+                          width: 28.w,
+                          height: 28.w,
+                          decoration: ShapeDecoration(
+                            color: Color(0xFF2A3E55),
+                            shape: RoundedRectangleBorder(
+                              borderRadius: BorderRadius.circular(86.r),
+                            ),
+                            image: DecorationImage(
+                              image: Assets.images.iconPrivateClose.provider(),
+                            ),
+                          ),
+                        )),
                     SizedBox(
                       height: 45.h,
                     ),
@@ -119,28 +124,29 @@ void privacyDialog() {
                         ),
                         GestureDetector(
                             onTap: () {
-
+                              onAgree();
+                              SmartDialog.dismiss(tag: tag);
                             },
                             child: Container(
-                          width: 316.w,
-                          height: 48.h,
-                          decoration: ShapeDecoration(
-                            color: Color(0xFF0279FB),
-                            shape: RoundedRectangleBorder(
-                              borderRadius: BorderRadius.circular(24.r),
-                            ),
-                          ),
-                          child: Center(
-                            child: Text(
-                              'Start',
-                              style: TextStyle(
-                                color: Colors.white,
-                                fontSize: 16.sp,
-                                fontWeight: FontWeight.w500,
+                              width: 316.w,
+                              height: 48.h,
+                              decoration: ShapeDecoration(
+                                color: Color(0xFF0279FB),
+                                shape: RoundedRectangleBorder(
+                                  borderRadius: BorderRadius.circular(24.r),
+                                ),
                               ),
-                            ),
-                          ),
-                        )),
+                              child: Center(
+                                child: Text(
+                                  'Start',
+                                  style: TextStyle(
+                                    color: Colors.white,
+                                    fontSize: 16.sp,
+                                    fontWeight: FontWeight.w500,
+                                  ),
+                                ),
+                              ),
+                            )),
                       ],
                     ),
                   ],

+ 4 - 3
lib/main.dart

@@ -1,3 +1,4 @@
+import 'package:clean/data/consts/constants.dart';
 import 'package:clean/resource/colors.gen.dart';
 import 'package:clean/resource/string.gen.dart';
 import 'package:clean/resource/string_source.dart';
@@ -24,9 +25,9 @@ Future<void> main() async {
 }
 
 Future<void> initAfterGrant() async {
-  // if (!isAgreePrivacyPolicy()) {
-  //   return;
-  // }
+  if (!isAgreePrivacyPolicy()) {
+    return;
+  }
   //获取包信息
   await appInfoUtil.init();
   //获取设备信息

+ 4 - 3
lib/module/splash/intro/intro_controller.dart

@@ -2,6 +2,7 @@ import 'dart:async';
 
 import 'package:clean/base/base_controller.dart';
 import 'package:clean/data/consts/constants.dart';
+import 'package:clean/module/main/main_view.dart';
 import 'package:clean/resource/assets.gen.dart';
 import 'package:clean/router/app_pages.dart';
 import 'package:flutter/Material.dart';
@@ -43,7 +44,7 @@ class IntroController extends BaseController {
       // 进入主页或其他操作
 
       Timer(const Duration(milliseconds: 500), () {
-        Get.offNamed(RoutePath.mainTab);
+        MainTabPage.start();
         setFirstIntro(false);
       });
     } else {
@@ -56,9 +57,9 @@ class IntroController extends BaseController {
     }
   }
 
-  void nextButton() {
+  void clickContinue() {
     Timer(const Duration(milliseconds: 500), () {
-      Get.offNamed(RoutePath.mainTab);
+      MainTabPage.start();
       setFirstIntro(false);
     });
   }

+ 3 - 0
lib/module/splash/intro/intro_view.dart

@@ -51,6 +51,9 @@ class IntroPage extends BasePage<IntroController> {
             buildIndicator(),
             SizedBox(height: 15.h),
             GestureDetector(
+              onTap: () {
+                controller.clickContinue();
+              },
               child: Container(
                 width: 316.w,
                 height: 48.h,

+ 25 - 7
lib/module/splash/splash_controller.dart

@@ -1,6 +1,9 @@
+import 'dart:io';
+
 import 'package:clean/base/base_controller.dart';
 import 'package:clean/data/consts/constants.dart';
 import 'package:clean/dialog/privacy_dialog.dart';
+import 'package:clean/main.dart';
 import 'package:clean/module/main/main_view.dart';
 import 'package:clean/module/splash/intro/intro_view.dart';
 import 'package:flutter/Material.dart';
@@ -20,18 +23,33 @@ class SplashController extends BaseController {
     super.onReady();
     final isAgreePrivacy = isAgreePrivacyPolicy();
     if (isAgreePrivacy) {
-      Future.delayed(const Duration(seconds: 3), () {
-        MainTabPage.start();
-      });
+      onAgreePrivacy();
     } else {
+      Future.delayed(const Duration(seconds: 2), () {
+        privacyDialog(
+          onAgree: () {
+            setPrivacyPolicy(true);
+            onAgreePrivacy();
+          },
+          onDisagree: () {
+            setPrivacyPolicy(false);
+            exit(0);
+          },
+        );
+      });
+    }
+  }
+
+  // 已经同意隐私
+  void onAgreePrivacy() async {
+    await initAfterGrant();
+    Future.delayed(const Duration(seconds: 2), () {
       if (isFirstIntro()) {
-        Future.delayed(const Duration(seconds: 3), () {
-          IntroPage.start();
-        });
+        IntroPage.start();
       } else {
         MainTabPage.start();
       }
-    }
+    });
   }
 
   @override

+ 22 - 96
lib/module/splash/splash_view.dart

@@ -30,32 +30,29 @@ class SplashPage extends BasePage<SplashController> {
         width: double.infinity,
         height: double.infinity,
         child: SafeArea(
-            child: Container(
-
-          child: Column(
-            crossAxisAlignment: CrossAxisAlignment.center,
-            mainAxisAlignment: MainAxisAlignment.center,
-            children: [
-              SizedBox(
-                  child: Lottie.asset(
-                Assets.anim.animSplash,
-                controller: controller.animation,
-                width: 150.w,
-                height: 150.w,
-                repeat: true,
-              )),
-              Text(
-                StringName.appName,
-                textAlign: TextAlign.center,
-                style: TextStyle(
-                  color: Colors.white,
-                  fontSize: 24.sp,
-                  fontWeight: FontWeight.w900,
+            child: Column(
+              crossAxisAlignment: CrossAxisAlignment.center,
+              mainAxisAlignment: MainAxisAlignment.center,
+              children: [
+                SizedBox(
+                    child: Lottie.asset(
+                  Assets.anim.animSplash,
+                  controller: controller.animation,
+                  width: 150.w,
+                  height: 150.w,
+                  repeat: true,
+                )),
+                Text(
+                  StringName.appName,
+                  textAlign: TextAlign.center,
+                  style: TextStyle(
+                    color: Colors.white,
+                    fontSize: 24.sp,
+                    fontWeight: FontWeight.w900,
+                  ),
                 ),
-              ),
-            ],
-          ),
-        )),
+              ],
+            )),
       ),
       IgnorePointer(
         child: Assets.images.bgPhotoSelectedPreviewFinish.image(
@@ -66,76 +63,5 @@ class SplashPage extends BasePage<SplashController> {
     ]);
   }
 
-// Widget _finishCleanCard() {
-//   return Container(
-//     width: 360.w,
-//     child: Column(
-//       mainAxisAlignment: MainAxisAlignment.start,
-//       children: [
-//         Spacer(
-//           flex: 3,
-//         ),
-//         Text(
-//           'Great!',
-//           textAlign: TextAlign.center,
-//           style: TextStyle(
-//             color: Colors.white,
-//             fontSize: 32.sp,
-//             fontWeight: FontWeight.w700,
-//           ),
-//         ),
-//         SizedBox(height: 14.h),
-//         Text(
-//           "You've completed 1 photo review",
-//           textAlign: TextAlign.center,
-//           style: TextStyle(
-//             color: Colors.white.withValues(alpha: 0.8),
-//             fontSize: 16.sp,
-//             fontWeight: FontWeight.w400,
-//           ),
-//         ),
-//         SizedBox(height: 47.h),
-//         // Assets.images.iconPhotoSelectedPreviewFireworks.image(
-//         //   width: 158.w,
-//         //   height: 158.h,
-//         // ),
-//
-//         SizedBox(
-//             child: Lottie.asset(
-//           Assets.anim.animPhotoSelectedPreviewFireworks,
-//           width: 158.w,
-//           height: 158.w,
-//           repeat: false,
-//         )),
-//
-//         Spacer(
-//           flex: 5,
-//         ),
-//       ],
-//     ),
-//   );
-// }
 
-// Stack(children: [
-// Container(
-// child: SafeArea(
-// child: Column(
-// children: [
-// SizedBox(
-// child: Lottie.asset(
-// Assets.anim.animPhotoSelectedPreviewFireworks,
-// width: 150.w,
-// height: 150.w,
-// repeat: true,
-// )),
-// ],
-// )),
-// ),
-// IgnorePointer(
-// child: Assets.images.bgPhotoSelectedPreviewFinish.image(
-// width: 360.w,
-// height: 335.h,
-// ),
-// ),
-// ]);
 }