LCOV - code coverage report
Current view: top level - src/ui/client/helpers/simple_helper - simple_helper_presenter.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 21 34 61.8 %
Date: 2020-12-04 18:41:24 Functions: 0 0 -

          Line data    Source code
       1             : import 'dart:async';
       2             : 
       3             : import 'package:mvvm_builder/mvvm_builder.dart';
       4             : import 'package:pal/src/ui/client/helpers/simple_helper/simple_helper.dart';
       5             : import 'package:pal/src/ui/client/helpers/simple_helper/simple_helper_viewmodel.dart';
       6             : 
       7             : class SimpleHelperPresenter
       8             :     extends Presenter<SimpleHelperModel, SimpleHelperView> {
       9           1 :   SimpleHelperPresenter(
      10             :     SimpleHelperView viewInterface,
      11           2 :   ) : super(SimpleHelperModel(), viewInterface);
      12             : 
      13           1 :   @override
      14             :   void onInit() {
      15           1 :     super.onInit();
      16           2 :     this.viewModel.thumbAnimation = false;
      17           2 :     this.viewModel.boxTransitionAnimation = false;
      18           2 :     this.viewModel.shakeAnimation = false;
      19             : 
      20           1 :     startAnimation();
      21             :   }
      22             : 
      23           1 :   @override
      24             :   void afterViewInit() {
      25           1 :     super.afterViewInit();
      26             : 
      27           2 :     Future.delayed(Duration(milliseconds: 1000), () {
      28           0 :       this.viewModel.shakeAnimation = true;
      29           0 :       this.refreshAnimations();
      30             :     });
      31             : 
      32           3 :     this.viewModel.shakeAnimationTimer = Timer.periodic(
      33           1 :       Duration(milliseconds: 5200),
      34           0 :       (Timer t) {
      35           0 :         this.viewModel.shakeAnimation = true;
      36           0 :         this.refreshAnimations();
      37             :       },
      38             :     );
      39             :   }
      40             : 
      41           1 :   @override
      42             :   void onDestroy() {
      43           3 :     this.viewModel.shakeAnimationTimer?.cancel();
      44             : 
      45           1 :     super.onDestroy();
      46             :   }
      47             : 
      48           1 :   void startAnimation() async {
      49           4 :     await Future.delayed(Duration(milliseconds: 350), () {
      50           2 :       this.viewModel.boxTransitionAnimation = true;
      51           1 :       this.refreshAnimations();
      52             :     });
      53             : 
      54           3 :     await Future.delayed(Duration(milliseconds: 1000), () {
      55           0 :       this.viewModel.thumbAnimation = true;
      56           0 :       this.refreshAnimations();
      57             :     });
      58             :   }
      59             : 
      60           0 :   onBoxAnimationEnd() {
      61           0 :     this.viewModel.boxTransitionAnimation = false;
      62             :   }
      63             : 
      64           0 :   onThumbAnimationEnd() {
      65           0 :     this.viewModel.thumbAnimation = false;
      66             :   }
      67             : 
      68           0 :   onShakeAnimationEnd() {
      69           0 :     this.viewModel.shakeAnimation = false;
      70             :   }
      71             : }

Generated by: LCOV version 1.14