splash_controller.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. import '../../data/consts/event_report_id.dart';
  11. import '../../handler/event_handler.dart';
  12. class SplashController extends BaseController {
  13. Animation<double>? animation;
  14. @override
  15. void onInit() {
  16. super.onInit();
  17. }
  18. @override
  19. void onReady() {
  20. print('SplashController onReady');
  21. super.onReady();
  22. final isAgreePrivacy = isAgreePrivacyPolicy();
  23. if (isAgreePrivacy) {
  24. onAgreePrivacy();
  25. EventHandler.report(EventId.event_01000);
  26. } else {
  27. Future.delayed(const Duration(seconds: 2), () {
  28. privacyDialog(
  29. onAgree: () {
  30. setPrivacyPolicy(true);
  31. onAgreePrivacy();
  32. EventHandler.report(EventId.event_01002);
  33. },
  34. onDisagree: () {
  35. setPrivacyPolicy(false);
  36. exit(0);
  37. },
  38. );
  39. });
  40. }
  41. }
  42. // 已经同意隐私
  43. void onAgreePrivacy() async {
  44. await initAfterGrant();
  45. Future.delayed(const Duration(seconds: 2), () {
  46. if (isFirstIntro()) {
  47. IntroPage.start();
  48. } else {
  49. MainTabPage.start();
  50. }
  51. });
  52. }
  53. @override
  54. void onClose() {
  55. print('SplashController onClose');
  56. super.onClose();
  57. }
  58. }