react-native-navigation 7.42.0 → 7.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/lib/android/app/src/main/java/com/reactnativenavigation/FeatureToggles.kt +62 -0
  2. package/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java +2 -2
  3. package/lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java +13 -3
  4. package/lib/android/app/src/main/java/com/reactnativenavigation/options/ValueAnimationOptions.kt +3 -3
  5. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/ColorUtils.java +11 -0
  6. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/StubAnimationListener.kt +19 -0
  7. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/SystemUiUtils.kt +17 -16
  8. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenter.java +0 -1
  9. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAnimator.kt +2 -2
  10. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +4 -9
  11. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java +7 -14
  12. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentPresenter.java +18 -0
  13. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +24 -12
  14. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +52 -24
  15. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +20 -10
  16. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/{TopBarAnimator.kt → TopBarAppearanceAnimator.kt} +4 -2
  17. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarCollapseBehavior.kt +1 -1
  18. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarController.kt +154 -26
  19. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/statusbar/StatusBarPresenter.kt +212 -0
  20. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +12 -107
  21. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/StatusBarColorAnimator.kt +28 -0
  22. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +34 -2
  23. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerVisibilityInfo.kt +5 -0
  24. package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/{BaseViewAnimator.kt → BaseViewAppearanceAnimator.kt} +4 -4
  25. package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/ColorAnimator.kt +22 -0
  26. package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreator.kt +8 -8
  27. package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/ViewAnimatorCreator.kt +2 -2
  28. package/lib/android/app/src/main/java/com/reactnativenavigation/views/animations/ViewBkgColorProperty.kt +17 -0
  29. package/lib/dist/src/commands/OptionsProcessor.js +8 -1
  30. package/lib/dist/src/interfaces/Options.d.ts +33 -3
  31. package/lib/ios/BottomTabsBasePresenter.m +1 -1
  32. package/lib/ios/RNNConvert.h +0 -1
  33. package/lib/ios/RNNConvert.m +3 -8
  34. package/lib/ios/RNNStackPresenter.m +1 -1
  35. package/lib/src/commands/OptionsProcessor.ts +13 -2
  36. package/lib/src/interfaces/Options.ts +38 -3
  37. package/package.json +1 -1
@@ -3,6 +3,7 @@ package com.reactnativenavigation.viewcontrollers.viewcontroller;
3
3
  import static com.reactnativenavigation.utils.CollectionUtils.forEach;
4
4
  import static com.reactnativenavigation.utils.ObjectUtils.perform;
5
5
 
6
+ import android.animation.Animator;
6
7
  import android.app.Activity;
7
8
  import android.content.res.Configuration;
8
9
  import android.view.View;
@@ -12,11 +13,11 @@ import android.view.ViewTreeObserver;
12
13
 
13
14
  import androidx.annotation.CallSuper;
14
15
  import androidx.annotation.CheckResult;
16
+ import androidx.annotation.NonNull;
15
17
  import androidx.annotation.Nullable;
16
18
  import androidx.annotation.VisibleForTesting;
17
19
  import androidx.coordinatorlayout.widget.CoordinatorLayout;
18
20
 
19
- import com.reactnativenavigation.BuildConfig;
20
21
  import com.reactnativenavigation.options.Options;
21
22
  import com.reactnativenavigation.options.params.Bool;
22
23
  import com.reactnativenavigation.options.params.NullBool;
@@ -113,10 +114,34 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
113
114
 
114
115
  public abstract T createView();
115
116
 
117
+ public void onSelected(ViewController<?> previousVC) {
118
+ setVisible();
119
+ }
120
+
121
+ public void onDeselected() {
122
+ setInvisible();
123
+ }
124
+
125
+ public void setVisible() {
126
+ getView().setVisibility(View.VISIBLE);
127
+
128
+ onViewWillAppear();
129
+ onViewDidAppear();
130
+ }
131
+
132
+ public void setInvisible() {
133
+ getView().setVisibility(View.INVISIBLE);
134
+ }
135
+
116
136
  public void setViewVisibilityListener(ViewVisibilityListener viewVisibilityListener) {
117
137
  this.viewVisibilityListener = viewVisibilityListener;
118
138
  }
119
139
 
140
+ @NonNull
141
+ public ViewControllerVisibilityInfo getVisibilityInfo() {
142
+ return new ViewControllerVisibilityInfo(null);
143
+ }
144
+
120
145
  @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
121
146
  public void ensureViewIsCreated() {
122
147
  getView();
@@ -172,7 +197,6 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
172
197
  }
173
198
 
174
199
  public void setDefaultOptions(Options defaultOptions) {
175
-
176
200
  }
177
201
 
178
202
  public Activity getActivity() {
@@ -352,6 +376,14 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
352
376
 
353
377
  }
354
378
 
379
+ public Animator getPushAnimations(Options appearingOptions) {
380
+ return null;
381
+ }
382
+
383
+ public Animator getPopAnimations(Options appearingOptions, Options disappearingOptions) {
384
+ return null;
385
+ }
386
+
355
387
  protected void runOnPreDraw(Func1<T> task) {
356
388
  if (!isDestroyed) UiUtils.runOnPreDrawOnce(getView(), task);
357
389
  }
@@ -0,0 +1,5 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller
2
+
3
+ data class TopBarVisibilityInfo(val isShown: Boolean, val solidColor: Int?)
4
+
5
+ data class ViewControllerVisibilityInfo(val topBarVisibilityInfo: TopBarVisibilityInfo?)
@@ -12,7 +12,7 @@ import com.reactnativenavigation.options.animations.ViewAnimationOptions
12
12
  import com.reactnativenavigation.options.params.Bool
13
13
  import com.reactnativenavigation.utils.resetViewProperties
14
14
 
15
- open class BaseViewAnimator<T : View>(
15
+ open class BaseViewAppearanceAnimator<T : View>(
16
16
  private val hideDirection: HideDirection,
17
17
  view: T? = null,
18
18
  private val defaultAnimatorCreator: ViewAnimatorCreator = DefaultViewAnimatorCreator()
@@ -90,16 +90,16 @@ open class BaseViewAnimator<T : View>(
90
90
 
91
91
  fun isAnimatingShow() = showAnimator.isRunning
92
92
 
93
- fun getPushAnimation(animation: ViewAnimationOptions, visible: Bool, additionalDy: Float = 0f): Animator? {
93
+ fun getPushAnimation(animationOpts: ViewAnimationOptions, visible: Bool, additionalDy: Float = 0f): Animator? {
94
94
  if (isOrWillBeVisible && visible.isFalse) {
95
95
  showAnimator.cancel()
96
- hideAnimator = animation.exit.getAnimation(view, defaultAnimatorCreator.getHideAnimator(view, hideDirection, additionalDy))
96
+ hideAnimator = animationOpts.exit.getAnimation(view, defaultAnimatorCreator.getHideAnimator(view, hideDirection, additionalDy))
97
97
  return hideAnimator
98
98
  }
99
99
 
100
100
  if (isOrWillBeHidden && visible.isTrueOrUndefined) {
101
101
  hideAnimator.cancel()
102
- showAnimator = animation.enter.getAnimation(view, defaultAnimatorCreator.getShowAnimator(view, hideDirection, additionalDy))
102
+ showAnimator = animationOpts.enter.getAnimation(view, defaultAnimatorCreator.getShowAnimator(view, hideDirection, additionalDy))
103
103
  return showAnimator
104
104
  }
105
105
 
@@ -0,0 +1,22 @@
1
+ package com.reactnativenavigation.views.animations
2
+
3
+ import android.animation.ObjectAnimator
4
+ import android.animation.ValueAnimator
5
+ import android.view.View
6
+
7
+ class ColorAnimator {
8
+ fun getAnimation(from: Int, to: Int): ValueAnimator = createObjectAnimator(null, from, to)
9
+ fun getAnimation(view: View, from: Int, to: Int): ValueAnimator = createObjectAnimator(view, from, to)
10
+
11
+ private fun createObjectAnimator(view: View?, from: Int, to: Int) =
12
+ if (view == null) {
13
+ ObjectAnimator.ofArgb(from, to)
14
+ } else {
15
+ ObjectAnimator.ofArgb(
16
+ view,
17
+ view.BkgColorProperty,
18
+ from,
19
+ to,
20
+ )
21
+ }
22
+ }
@@ -13,11 +13,11 @@ class DefaultViewAnimatorCreator : ViewAnimatorCreator {
13
13
  }
14
14
 
15
15
  override fun getShowAnimator(
16
- view: View,
17
- hideDirection: BaseViewAnimator.HideDirection,
18
- translationStart: Float
16
+ view: View,
17
+ hideDirection: BaseViewAppearanceAnimator.HideDirection,
18
+ translationStart: Float
19
19
  ): Animator {
20
- val direction = if (hideDirection == BaseViewAnimator.HideDirection.Up) 1 else -1
20
+ val direction = if (hideDirection == BaseViewAppearanceAnimator.HideDirection.Up) 1 else -1
21
21
  return ObjectAnimator.ofFloat(
22
22
  view,
23
23
  View.TRANSLATION_Y,
@@ -30,11 +30,11 @@ class DefaultViewAnimatorCreator : ViewAnimatorCreator {
30
30
  }
31
31
 
32
32
  override fun getHideAnimator(
33
- view: View,
34
- hideDirection: BaseViewAnimator.HideDirection,
35
- additionalDy: Float
33
+ view: View,
34
+ hideDirection: BaseViewAppearanceAnimator.HideDirection,
35
+ additionalDy: Float
36
36
  ): Animator {
37
- val direction = if (hideDirection == BaseViewAnimator.HideDirection.Up) -1 else 1
37
+ val direction = if (hideDirection == BaseViewAppearanceAnimator.HideDirection.Up) -1 else 1
38
38
  return ObjectAnimator.ofFloat(
39
39
  view,
40
40
  View.TRANSLATION_Y,
@@ -4,6 +4,6 @@ import android.animation.Animator
4
4
  import android.view.View
5
5
 
6
6
  interface ViewAnimatorCreator {
7
- fun getShowAnimator(view: View, hideDirection: BaseViewAnimator.HideDirection, translationStart: Float): Animator
8
- fun getHideAnimator(view: View, hideDirection: BaseViewAnimator.HideDirection, additionalDy: Float): Animator
7
+ fun getShowAnimator(view: View, hideDirection: BaseViewAppearanceAnimator.HideDirection, translationStart: Float): Animator
8
+ fun getHideAnimator(view: View, hideDirection: BaseViewAppearanceAnimator.HideDirection, additionalDy: Float): Animator
9
9
  }
@@ -0,0 +1,17 @@
1
+ package com.reactnativenavigation.views.animations
2
+
3
+ import android.graphics.drawable.ColorDrawable
4
+ import android.util.Property
5
+ import android.view.View
6
+
7
+ val View.BkgColorProperty: Property<View, Int>
8
+ // TODO Replace Property with IntProperty (Requires SDK≥24)
9
+ get() = object: Property<View, Int>(Int::class.java, "bkgColor") {
10
+ override fun set(view: View, value: Int) {
11
+ (view.background as ColorDrawable).color = value
12
+ }
13
+
14
+ override fun get(view: View): Int {
15
+ return (view.background as ColorDrawable).color
16
+ }
17
+ }
@@ -68,7 +68,7 @@ class OptionsProcessor {
68
68
  return path;
69
69
  }
70
70
  processColor(key, value, options) {
71
- if ((0, isEqual_1.default)(key, 'color') || (0, endsWith_1.default)(key, 'Color')) {
71
+ if (((0, isEqual_1.default)(key, 'color') || (0, endsWith_1.default)(key, 'Color')) && !(0, isEqual_1.default)(key, 'bkgColor')) {
72
72
  if (react_native_1.Platform.OS === 'ios')
73
73
  this.processColorIOS(key, value, options);
74
74
  else
@@ -313,6 +313,13 @@ class OptionsProcessor {
313
313
  enter: animation.topBar,
314
314
  };
315
315
  }
316
+ if (animation.statusBar &&
317
+ !(0, has_1.default)(animation, 'statusBar.enter') &&
318
+ !(0, has_1.default)(animation, 'statusBar.exit')) {
319
+ parentOptions.push.statusBar = {
320
+ enter: animation.statusBar,
321
+ };
322
+ }
316
323
  if (animation.bottomTabs &&
317
324
  !(0, has_1.default)(animation, 'bottomTabs.enter') &&
318
325
  !(0, has_1.default)(animation, 'bottomTabs.exit')) {
@@ -1166,12 +1166,34 @@ export interface IconInsets {
1166
1166
  */
1167
1167
  right?: number;
1168
1168
  }
1169
+ export interface ColorAnimationOptions {
1170
+ /**
1171
+ * Color duration time; Default is as determined by the OS
1172
+ */
1173
+ duration?: number;
1174
+ }
1169
1175
  export interface ViewAnimationOptions extends ScreenAnimationOptions {
1170
1176
  /**
1171
1177
  * ID of the Top Bar we want to animate
1172
1178
  */
1173
1179
  id?: string;
1174
1180
  }
1181
+ export interface TopBarAnimationOptions extends ViewAnimationOptions {
1182
+ /**
1183
+ * Animation of the top-bar's background color, in case the top-bar background color
1184
+ * has been explicitly specified.
1185
+ *
1186
+ * Applicable only in transition of screens with color (non-component) backgrounds.
1187
+ */
1188
+ bkgColor?: ColorAnimationOptions;
1189
+ }
1190
+ export interface StatusBarAnimationOptions extends ViewAnimationOptions {
1191
+ /**
1192
+ * Animation of the status-bar's background color, in case its background color
1193
+ * has been explicitly specified.
1194
+ */
1195
+ bkgColor?: ColorAnimationOptions;
1196
+ }
1175
1197
  export interface EnterExitAnimationOptions {
1176
1198
  /**
1177
1199
  * Animate opening component
@@ -1226,9 +1248,17 @@ export interface StackAnimationOptions {
1226
1248
  /**
1227
1249
  * Configure animations for the top bar
1228
1250
  */
1229
- topBar?: ViewAnimationOptions | {
1230
- enter?: ViewAnimationOptions;
1231
- exit?: ViewAnimationOptions;
1251
+ topBar?: TopBarAnimationOptions | {
1252
+ enter?: TopBarAnimationOptions;
1253
+ exit?: TopBarAnimationOptions;
1254
+ };
1255
+ /**
1256
+ * Configure animations for the status bar (typically aligned
1257
+ * with the top-bar's)
1258
+ */
1259
+ statusBar?: StatusBarAnimationOptions | {
1260
+ enter?: StatusBarAnimationOptions;
1261
+ exit?: StatusBarAnimationOptions;
1232
1262
  };
1233
1263
  /**
1234
1264
  * Configure animations for the bottom tabs
@@ -1,7 +1,7 @@
1
1
  #import "BottomTabsBasePresenter.h"
2
2
  #import "RNNBottomTabsController.h"
3
- #import "UIImage+utils.h"
4
3
  #import "RNNConvert.h"
4
+ #import "UIImage+utils.h"
5
5
 
6
6
  @implementation BottomTabsBasePresenter
7
7
 
@@ -9,5 +9,4 @@
9
9
 
10
10
  + (UIBarStyle)UIBarStyle:(id)json;
11
11
 
12
-
13
12
  @end
@@ -32,13 +32,8 @@ RCT_ENUM_CONVERTER(UIModalPresentationStyle, (@{
32
32
  }),
33
33
  UIModalPresentationFullScreen, integerValue)
34
34
 
35
- RCT_ENUM_CONVERTER(
36
- UIBarStyle,
37
- (@{
38
- @"default" : @(UIBarStyleDefault),
39
- @"black" : @(UIBarStyleBlack)
40
- }),
41
- UIBarStyleDefault,
42
- integerValue)
35
+ RCT_ENUM_CONVERTER(UIBarStyle,
36
+ (@{@"default" : @(UIBarStyleDefault), @"black" : @(UIBarStyleBlack)}),
37
+ UIBarStyleDefault, integerValue)
43
38
 
44
39
  @end
@@ -1,11 +1,11 @@
1
1
  #import "RNNStackPresenter.h"
2
2
  #import "InteractivePopGestureDelegate.h"
3
+ #import "RNNConvert.h"
3
4
  #import "RNNCustomTitleView.h"
4
5
  #import "RNNReactBackgroundView.h"
5
6
  #import "RNNStackController.h"
6
7
  #import "TopBarPresenterCreator.h"
7
8
  #import "UINavigationController+RNNOptions.h"
8
- #import "RNNConvert.h"
9
9
 
10
10
  @interface RNNStackPresenter () {
11
11
  RNNReactComponentRegistry *_componentRegistry;
@@ -20,6 +20,8 @@ import {
20
20
  OptionsSearchBar,
21
21
  OptionsTopBar,
22
22
  StackAnimationOptions,
23
+ StatusBarAnimationOptions,
24
+ TopBarAnimationOptions,
23
25
  ViewAnimationOptions,
24
26
  } from '../interfaces/Options';
25
27
  import { Deprecations } from './Deprecations';
@@ -117,7 +119,7 @@ export class OptionsProcessor {
117
119
  }
118
120
 
119
121
  private processColor(key: string, value: any, options: Record<string, any>) {
120
- if (isEqual(key, 'color') || endsWith(key, 'Color')) {
122
+ if ((isEqual(key, 'color') || endsWith(key, 'Color')) && !isEqual(key, 'bkgColor')) {
121
123
  if (Platform.OS === 'ios') this.processColorIOS(key, value, options);
122
124
  else this.processColorAndroid(key, value, options);
123
125
  }
@@ -399,7 +401,16 @@ export class OptionsProcessor {
399
401
  }
400
402
  if (animation.topBar && !has(animation, 'topBar.enter') && !has(animation, 'topBar.exit')) {
401
403
  parentOptions.push!!.topBar = {
402
- enter: animation.topBar as ViewAnimationOptions,
404
+ enter: animation.topBar as TopBarAnimationOptions,
405
+ };
406
+ }
407
+ if (
408
+ animation.statusBar &&
409
+ !has(animation, 'statusBar.enter') &&
410
+ !has(animation, 'statusBar.exit')
411
+ ) {
412
+ parentOptions.push!!.statusBar = {
413
+ enter: animation.statusBar as StatusBarAnimationOptions,
403
414
  };
404
415
  }
405
416
  if (
@@ -1267,6 +1267,13 @@ export interface IconInsets {
1267
1267
  right?: number;
1268
1268
  }
1269
1269
 
1270
+ export interface ColorAnimationOptions {
1271
+ /**
1272
+ * Color duration time; Default is as determined by the OS
1273
+ */
1274
+ duration?: number;
1275
+ }
1276
+
1270
1277
  export interface ViewAnimationOptions extends ScreenAnimationOptions {
1271
1278
  /**
1272
1279
  * ID of the Top Bar we want to animate
@@ -1274,6 +1281,24 @@ export interface ViewAnimationOptions extends ScreenAnimationOptions {
1274
1281
  id?: string;
1275
1282
  }
1276
1283
 
1284
+ export interface TopBarAnimationOptions extends ViewAnimationOptions {
1285
+ /**
1286
+ * Animation of the top-bar's background color, in case the top-bar background color
1287
+ * has been explicitly specified.
1288
+ *
1289
+ * Applicable only in transition of screens with color (non-component) backgrounds.
1290
+ */
1291
+ bkgColor?: ColorAnimationOptions;
1292
+ }
1293
+
1294
+ export interface StatusBarAnimationOptions extends ViewAnimationOptions {
1295
+ /**
1296
+ * Animation of the status-bar's background color, in case its background color
1297
+ * has been explicitly specified.
1298
+ */
1299
+ bkgColor?: ColorAnimationOptions;
1300
+ }
1301
+
1277
1302
  export interface EnterExitAnimationOptions {
1278
1303
  /**
1279
1304
  * Animate opening component
@@ -1332,10 +1357,20 @@ export interface StackAnimationOptions {
1332
1357
  * Configure animations for the top bar
1333
1358
  */
1334
1359
  topBar?:
1335
- | ViewAnimationOptions
1360
+ | TopBarAnimationOptions
1336
1361
  | {
1337
- enter?: ViewAnimationOptions;
1338
- exit?: ViewAnimationOptions;
1362
+ enter?: TopBarAnimationOptions;
1363
+ exit?: TopBarAnimationOptions;
1364
+ };
1365
+ /**
1366
+ * Configure animations for the status bar (typically aligned
1367
+ * with the top-bar's)
1368
+ */
1369
+ statusBar?:
1370
+ | StatusBarAnimationOptions
1371
+ | {
1372
+ enter?: StatusBarAnimationOptions;
1373
+ exit?: StatusBarAnimationOptions;
1339
1374
  };
1340
1375
  /**
1341
1376
  * Configure animations for the bottom tabs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.42.0",
3
+ "version": "7.44.0",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,