splash_controller.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import 'dart:io';
  2. import 'package:clean/base/base_controller.dart';
  3. import 'package:clean/data/consts/constants.dart';
  4. import 'package:clean/dialog/privacy_dialog.dart';
  5. import 'package:clean/main.dart';
  6. import 'package:clean/module/main/main_view.dart';
  7. import 'package:clean/module/splash/intro/intro_view.dart';
  8. import 'package:flutter/Material.dart';
  9. import 'package:get/get.dart';
  10. class SplashController extends BaseController {
  11. Animation<double>? animation;
  12. @override
  13. void onInit() {
  14. super.onInit();
  15. }
  16. @override
  17. void onReady() {
  18. print('SplashController onReady');
  19. super.onReady();
  20. final isAgreePrivacy = isAgreePrivacyPolicy();
  21. if (isAgreePrivacy) {
  22. onAgreePrivacy();
  23. } else {
  24. Future.delayed(const Duration(seconds: 2), () {
  25. privacyDialog(
  26. onAgree: () {
  27. setPrivacyPolicy(true);
  28. onAgreePrivacy();
  29. },
  30. onDisagree: () {
  31. setPrivacyPolicy(false);
  32. exit(0);
  33. },
  34. );
  35. });
  36. }
  37. }
  38. // 已经同意隐私
  39. void onAgreePrivacy() async {
  40. await initAfterGrant();
  41. Future.delayed(const Duration(seconds: 2), () {
  42. if (isFirstIntro()) {
  43. IntroPage.start();
  44. } else {
  45. MainTabPage.start();
  46. }
  47. });
  48. }
  49. @override
  50. void onClose() {
  51. print('SplashController onClose');
  52. super.onClose();
  53. }
  54. }