Line data Source code
1 : import 'package:mvvm_builder/mvvm_builder.dart'; 2 : import 'package:pal/src/services/package_version.dart'; 3 : import 'package:pal/src/ui/client/helpers/user_update_helper/user_update_helper.dart'; 4 : import 'package:pal/src/ui/client/helpers/user_update_helper/user_update_helper_viewmodel.dart'; 5 : 6 : class UserUpdateHelperPresenter 7 : extends Presenter<UserUpdateHelperModel, UserUpdateHelperView> { 8 : final PackageVersionReader packageVersionReader; 9 : 10 1 : UserUpdateHelperPresenter( 11 : UserUpdateHelperView viewInterface, 12 : this.packageVersionReader, 13 2 : ) : super(UserUpdateHelperModel(), viewInterface); 14 : 15 1 : @override 16 : onInit() { 17 2 : this.viewModel.appVersion = '--'; 18 2 : this.viewModel.helperOpacity = 0; 19 2 : this.viewModel.changelogCascadeAnimation = false; 20 2 : this.viewModel.progressBarAnimation = false; 21 2 : this.viewModel.imageAnimation = false; 22 2 : this.viewModel.titleAnimation = false; 23 2 : this.viewModel.showThanksButton = false; 24 2 : this.viewModel.isReversedAnimations = false; 25 : 26 1 : readAppInfo(); 27 1 : startAnimations(); 28 : } 29 : 30 1 : readAppInfo() async { 31 3 : await this.packageVersionReader.init(); 32 4 : this.viewModel.appVersion = this.packageVersionReader.version; 33 : } 34 : 35 1 : startAnimations() async { 36 2 : this.viewModel.isReversedAnimations = false; 37 : 38 : // Fullscreen background opacity animation 39 4 : await Future.delayed(Duration(milliseconds: 1000), () { 40 2 : this.viewModel.helperOpacity = 1; 41 1 : this.refreshView(); 42 : }); 43 : 44 4 : await Future.delayed(Duration(milliseconds: 0), () { 45 2 : this.viewModel.imageAnimation = true; 46 2 : this.viewModel.titleAnimation = true; 47 1 : this.refreshAnimations(); 48 : }); 49 : 50 : // Changelog animation & progress bar 51 4 : await Future.delayed(Duration(milliseconds: 400), () { 52 2 : this.viewModel.changelogCascadeAnimation = true; 53 2 : this.viewModel.progressBarAnimation = true; 54 1 : this.refreshAnimations(); 55 : }); 56 : } 57 : 58 0 : Future reverseAnimations() async { 59 0 : this.viewModel.isReversedAnimations = true; 60 : 61 0 : await Future.delayed(Duration(milliseconds: 0), () { 62 0 : this.viewModel.changelogCascadeAnimation = true; 63 0 : this.refreshAnimations(); 64 : }); 65 : 66 0 : await Future.delayed(Duration(milliseconds: 800), () { 67 0 : this.viewModel.titleAnimation = true; 68 0 : this.refreshAnimations(); 69 : }); 70 : 71 0 : await Future.delayed(Duration(milliseconds: 200), () { 72 0 : this.viewModel.imageAnimation = true; 73 0 : this.refreshAnimations(); 74 : }); 75 : 76 0 : await Future.delayed(Duration(milliseconds: 500), () { 77 0 : this.viewModel.helperOpacity = 0; 78 0 : this.refreshView(); 79 : }); 80 : 81 0 : await Future.delayed(Duration(milliseconds: 500)); 82 : } 83 : 84 1 : onCascadeAnimationEnd() { 85 2 : this.viewModel.changelogCascadeAnimation = false; 86 : } 87 : 88 1 : onProgressBarAnimationEnd() { 89 2 : this.viewModel.progressBarAnimation = false; 90 2 : this.viewModel.showThanksButton = true; 91 1 : this.refreshView(); 92 : } 93 : 94 1 : onTitleAnimationEnd() { 95 2 : this.viewModel.titleAnimation = false; 96 : } 97 : 98 1 : onImageAnimationEnd() { 99 2 : this.viewModel.imageAnimation = false; 100 : } 101 : 102 0 : onThanksButtonCallback() async { 103 0 : await this.reverseAnimations(); 104 0 : this.viewInterface.onThanksButtonCallback(); 105 : } 106 : }