Browse Source

Start app (#2927)

* WIP

* Apply default options when screen options are null

* modal animations

* fix tests

* refactor

* refactor

* refactor

* refactor

* test fix

* topBar anim

* child disappear bug

* Update app.js

* Update WelcomeScreen.js

* fix tests

* bottom tabs

* stack id

* fix test

* refactoring

* merge fix

* Update app.js

* merge

* comment to fix test

* merge options

* start app anim

* anim
Roman Kozlov 6 years ago
parent
commit
16415b2213

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/anim/BaseAnimator.java View File

15
 
15
 
16
 class BaseAnimator {
16
 class BaseAnimator {
17
 
17
 
18
-    AnimationsOptions options = new AnimationsOptions();
18
+    protected AnimationsOptions options = new AnimationsOptions();
19
 
19
 
20
     private static final int DURATION = 300;
20
     private static final int DURATION = 300;
21
     private static final DecelerateInterpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();
21
     private static final DecelerateInterpolator DECELERATE_INTERPOLATOR = new DecelerateInterpolator();

+ 22
- 0
lib/android/app/src/main/java/com/reactnativenavigation/anim/NavigationAnimator.java View File

16
         super(context);
16
         super(context);
17
     }
17
     }
18
 
18
 
19
+    public NavigationAnimator(Context context, AnimationsOptions options) {
20
+        super(context);
21
+        this.options = options;
22
+    }
23
+
19
     public void animatePush(final View view, @Nullable final AnimationListener animationListener) {
24
     public void animatePush(final View view, @Nullable final AnimationListener animationListener) {
20
         view.setVisibility(View.INVISIBLE);
25
         view.setVisibility(View.INVISIBLE);
21
         AnimatorSet set;
26
         AnimatorSet set;
58
         set.start();
63
         set.start();
59
     }
64
     }
60
 
65
 
66
+    public void animateStartApp(View view, @Nullable final AnimationListener animationListener) {
67
+        view.setVisibility(View.INVISIBLE);
68
+        AnimatorSet set = options.startApp.getAnimation(view);
69
+        set.addListener(new AnimatorListenerAdapter() {
70
+            @Override
71
+            public void onAnimationStart(Animator animation) {
72
+                view.setVisibility(View.VISIBLE);
73
+            }
74
+
75
+            @Override
76
+            public void onAnimationEnd(Animator animation) {
77
+                if (animationListener != null) animationListener.onAnimationEnd();
78
+            }
79
+        });
80
+        set.start();
81
+    }
82
+
61
     public void setOptions(AnimationsOptions options) {
83
     public void setOptions(AnimationsOptions options) {
62
         this.options = options;
84
         this.options = options;
63
     }
85
     }

+ 14
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/Navigator.java View File

3
 import android.app.Activity;
3
 import android.app.Activity;
4
 import android.support.annotation.NonNull;
4
 import android.support.annotation.NonNull;
5
 import android.support.annotation.Nullable;
5
 import android.support.annotation.Nullable;
6
+import android.view.View;
6
 import android.view.ViewGroup;
7
 import android.view.ViewGroup;
7
 import android.widget.FrameLayout;
8
 import android.widget.FrameLayout;
8
 
9
 
9
 import com.facebook.react.bridge.Promise;
10
 import com.facebook.react.bridge.Promise;
11
+import com.reactnativenavigation.anim.NavigationAnimator;
12
+import com.reactnativenavigation.parse.AnimationsOptions;
10
 import com.reactnativenavigation.parse.Options;
13
 import com.reactnativenavigation.parse.Options;
11
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
14
 import com.reactnativenavigation.presentation.NavigationOptionsListener;
12
 import com.reactnativenavigation.presentation.OverlayManager;
15
 import com.reactnativenavigation.presentation.OverlayManager;
66
         }
69
         }
67
 
70
 
68
         root = viewController;
71
         root = viewController;
69
-        getView().addView(viewController.getView());
70
-        promise.resolve(viewController.getId());
72
+        View view = viewController.getView();
73
+
74
+        AnimationsOptions animationsOptions = viewController.options.animationsOptions;
75
+        if (animationsOptions.startApp.hasValue()) {
76
+            getView().addView(view);
77
+            new NavigationAnimator(viewController.getActivity(), animationsOptions)
78
+                    .animateStartApp(view, () -> promise.resolve(viewController.getId()));
79
+        } else {
80
+            getView().addView(view);
81
+            promise.resolve(viewController.getId());
82
+        }
71
     }
83
     }
72
 
84
 
73
     public void setDefaultOptions(Options defaultOptions) {
85
     public void setDefaultOptions(Options defaultOptions) {

+ 0
- 1
playground/android/gradle.properties View File

21
 # Disable incremental resource processing as it broke relase build
21
 # Disable incremental resource processing as it broke relase build
22
 # https://github.com/react-community/react-navigation/issues/1976
22
 # https://github.com/react-community/react-navigation/issues/1976
23
 # https://developer.android.com/studio/build/gradle-plugin-3-0-0.html
23
 # https://developer.android.com/studio/build/gradle-plugin-3-0-0.html
24
-android.enableAapt2=false

+ 14
- 0
playground/src/app.js View File

25
   Navigation.events().onAppLaunched(() => {
25
   Navigation.events().onAppLaunched(() => {
26
     Navigation.setDefaultOptions({
26
     Navigation.setDefaultOptions({
27
       _animations: {
27
       _animations: {
28
+        startApp: {
29
+          y: {
30
+            from: 1000,
31
+            to: 0,
32
+            duration: 500,
33
+            interpolation: 'accelerate',
34
+          },
35
+          alpha: {
36
+            from: 0,
37
+            to: 1,
38
+            duration: 500,
39
+            interpolation: 'accelerate'
40
+          }
41
+        },
28
         push: {
42
         push: {
29
           topBar: {
43
           topBar: {
30
             id: 'TEST',
44
             id: 'TEST',