react-native-navigation 7.24.0 → 7.24.1

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.
@@ -66,18 +66,22 @@ public class ReactView extends ReactRootView implements IReactView, Renderable {
66
66
  }
67
67
 
68
68
  public void sendComponentWillStart(ComponentType type) {
69
- if (this.reactInstanceManager == null) return;
70
- ReactContext currentReactContext = reactInstanceManager.getCurrentReactContext();
71
- if (currentReactContext != null)
72
- new EventEmitter(currentReactContext).emitComponentWillAppear(componentId, componentName, type);
69
+ this.post(()->{
70
+ if (this.reactInstanceManager == null) return;
71
+ ReactContext currentReactContext = reactInstanceManager.getCurrentReactContext();
72
+ if (currentReactContext != null)
73
+ new EventEmitter(currentReactContext).emitComponentWillAppear(componentId, componentName, type);
74
+ });
73
75
  }
74
76
 
75
77
  public void sendComponentStart(ComponentType type) {
76
- if (this.reactInstanceManager == null) return;
77
- ReactContext currentReactContext = reactInstanceManager.getCurrentReactContext();
78
- if (currentReactContext != null) {
79
- new EventEmitter(currentReactContext).emitComponentDidAppear(componentId, componentName, type);
80
- }
78
+ this.post(()->{
79
+ if (this.reactInstanceManager == null) return;
80
+ ReactContext currentReactContext = reactInstanceManager.getCurrentReactContext();
81
+ if (currentReactContext != null) {
82
+ new EventEmitter(currentReactContext).emitComponentDidAppear(componentId, componentName, type);
83
+ }
84
+ });
81
85
  }
82
86
 
83
87
  public void sendComponentStop(ComponentType type) {
@@ -17,7 +17,7 @@ import kotlin.math.ceil
17
17
  object SystemUiUtils {
18
18
  private const val STATUS_BAR_HEIGHT_M = 24
19
19
  private const val STATUS_BAR_HEIGHT_L = 25
20
- private const val STATUS_BAR_HEIGHT_TRANSLUCENCY = 0.65f
20
+ internal const val STATUS_BAR_HEIGHT_TRANSLUCENCY = 0.65f
21
21
  private var statusBarHeight = -1
22
22
  var navigationBarDefaultColor = -1
23
23
  private set
@@ -124,7 +124,8 @@ object SystemUiUtils {
124
124
  val opaqueColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
125
125
  Color.BLACK
126
126
  }else{
127
- val alpha = if (translucent) STATUS_BAR_HEIGHT_TRANSLUCENCY else 1f
127
+ val colorAlpha = Color.alpha(color)
128
+ val alpha = if (translucent && colorAlpha == 255) STATUS_BAR_HEIGHT_TRANSLUCENCY else colorAlpha/255.0f
128
129
  val red: Int = Color.red(color)
129
130
  val green: Int = Color.green(color)
130
131
  val blue: Int = Color.blue(color)
@@ -274,6 +274,7 @@ public class BottomTabsController extends ParentController<BottomTabsLayout> imp
274
274
  getCurrentView().setVisibility(View.INVISIBLE);
275
275
  bottomTabs.setCurrentItem(newIndex, false);
276
276
  getCurrentView().setVisibility(View.VISIBLE);
277
+ getCurrentChild().onViewWillAppear();
277
278
  getCurrentChild().onViewDidAppear();
278
279
  }
279
280
 
@@ -84,6 +84,7 @@ public class ComponentViewController extends ChildController<ComponentLayout> {
84
84
 
85
85
  @Override
86
86
  public void onViewDisappear() {
87
+ if(lastVisibilityState == VisibilityState.Disappear)return;
87
88
  lastVisibilityState = VisibilityState.Disappear;
88
89
  if (view != null) view.sendComponentStop();
89
90
  super.onViewDisappear();
@@ -90,12 +90,10 @@ public class ModalPresenter {
90
90
  }
91
91
 
92
92
  private void onShowModalEnd(ViewController<?> toAdd, @Nullable ViewController<?> toRemove, CommandListener listener) {
93
- toAdd.addOnAppearedListener(()->{
94
- toAdd.onViewDidAppear();
95
- if (toRemove != null && toAdd.resolveCurrentOptions(defaultOptions).modal.presentationStyle != ModalPresentationStyle.OverCurrentContext) {
96
- toRemove.detachView();
97
- }
98
- });
93
+ toAdd.onViewDidAppear();
94
+ if (toRemove != null && toAdd.resolveCurrentOptions(defaultOptions).modal.presentationStyle != ModalPresentationStyle.OverCurrentContext) {
95
+ toRemove.detachView();
96
+ }
99
97
  listener.onSuccess(toAdd.getId());
100
98
  }
101
99
 
@@ -190,10 +190,8 @@ public class StackController extends ParentController<StackLayout> {
190
190
  }
191
191
 
192
192
  private void onPushAnimationComplete(ViewController<?> toAdd, ViewController<?> toRemove, CommandListener listener) {
193
- toAdd.addOnAppearedListener(() -> {
194
- toAdd.onViewDidAppear();
195
- if (!peek().equals(toRemove)) getView().removeView(toRemove.getView());
196
- });
193
+ toAdd.onViewDidAppear();
194
+ if (!peek().equals(toRemove)) getView().removeView(toRemove.getView());
197
195
  listener.onSuccess(toAdd.getId());
198
196
  }
199
197
 
@@ -88,6 +88,12 @@ public class BottomTabs extends AHBottomNavigation {
88
88
  if (getDefaultBackgroundColor() != color) setDefaultBackgroundColor(color);
89
89
  }
90
90
 
91
+ @Override
92
+ public void restoreBottomNavigation(boolean withAnimation) {
93
+ super.restoreBottomNavigation(withAnimation);
94
+ if (!withAnimation) setVisibility(View.VISIBLE);
95
+ }
96
+
91
97
  @Override
92
98
  public void hideBottomNavigation(boolean withAnimation) {
93
99
  super.hideBottomNavigation(withAnimation);
@@ -0,0 +1,27 @@
1
+ package com.reactnativenavigation.utils
2
+
3
+ import android.graphics.Color
4
+ import android.view.Window
5
+ import com.reactnativenavigation.BaseTest
6
+ import com.reactnativenavigation.utils.SystemUiUtils.STATUS_BAR_HEIGHT_TRANSLUCENCY
7
+ import org.junit.Test
8
+ import org.mockito.Mockito
9
+ import org.mockito.kotlin.verify
10
+ import kotlin.math.ceil
11
+
12
+ class SystemUiUtilsTest : BaseTest() {
13
+
14
+ @Test
15
+ fun `setStatusBarColor - should change color considering alpha`() {
16
+ val window = Mockito.mock(Window::class.java)
17
+ val alphaColor = Color.argb(44, 22, 255, 255)
18
+ val color = Color.argb(255, 22, 255, 255)
19
+ SystemUiUtils.setStatusBarColor(window, alphaColor, false)
20
+
21
+ verify(window).statusBarColor = alphaColor
22
+
23
+ SystemUiUtils.setStatusBarColor(window, color, true)
24
+
25
+ verify(window).statusBarColor = Color.argb(ceil(STATUS_BAR_HEIGHT_TRANSLUCENCY*255).toInt(), 22, 255, 255)
26
+ }
27
+ }
@@ -316,7 +316,24 @@ class BottomTabsControllerTest : BaseTest() {
316
316
  ), ArgumentMatchers.any(Int::class.java)
317
317
  )
318
318
  }
319
+ @Test
320
+ fun `mergeOptions - select tab calls onViewWillAppear to apply options on the selected child`(){
321
+ uut.ensureViewIsCreated()
322
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
323
+
324
+ val options = Options()
325
+ options.bottomTabsOptions.currentTabIndex = Number(1)
326
+ uut.mergeOptions(options)
327
+ Java6Assertions.assertThat(uut.selectedIndex).isOne
328
+ Mockito.verify(child2).onViewWillAppear()
329
+ Mockito.verify(child2).onViewDidAppear()
319
330
 
331
+ options.bottomTabsOptions.currentTabIndex = Number(0)
332
+ uut.mergeOptions(options)
333
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
334
+ Mockito.verify(child1).onViewWillAppear()
335
+ Mockito.verify(child1).onViewDidAppear()
336
+ }
320
337
  @Test
321
338
  fun mergeOptions_drawBehind() {
322
339
  Java6Assertions.assertThat(uut.getBottomInset(child1)).isEqualTo(uut.bottomTabs.height)
@@ -94,6 +94,24 @@ public class ComponentViewControllerTest extends BaseTest {
94
94
  Mockito.verify(view, Mockito.times(1)).sendComponentStop();
95
95
  }
96
96
 
97
+ @Test
98
+ public void shouldNotSendDidDisappearAboutDisappearedView() {
99
+ uut.ensureViewIsCreated();
100
+ uut.onViewDisappear();
101
+ Mockito.verify(view, Mockito.times(0)).sendComponentStart();
102
+ Mockito.verify(view, Mockito.times(0)).sendComponentStop();
103
+
104
+ uut.onViewWillAppear();
105
+ uut.onViewDidAppear();
106
+ uut.onViewDisappear();
107
+ Mockito.verify(view, Mockito.times(1)).sendComponentStart();
108
+ Mockito.verify(view, Mockito.times(1)).sendComponentStop();
109
+
110
+ uut.onViewDisappear();
111
+ Mockito.verify(view, Mockito.times(1)).sendComponentStart();
112
+ Mockito.verify(view, Mockito.times(1)).sendComponentStop();
113
+ }
114
+
97
115
  @Test
98
116
  public void onViewDidAppear_componentStartIsEmittedOnlyIfComponentIsNotAppeared() {
99
117
  uut.ensureViewIsCreated();
@@ -84,10 +84,9 @@ public class ModalStackTest extends BaseTest {
84
84
  }
85
85
 
86
86
  @Test
87
- public void showModal_DidAppearEventShouldWaitForReactViewToBeShown(){
87
+ public void showModal_DidAppearEventShouldBeCallled(){
88
88
  CommandListener listener = spy(new CommandListenerAdapter());
89
89
  uut.showModal(modal1, root, listener);
90
- verify(modal1).addOnAppearedListener(any());
91
90
  verify(listener).onSuccess(modal1.getId());
92
91
  idleMainLooper();
93
92
  verify(modal1).onViewDidAppear();
@@ -24,6 +24,7 @@ import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
24
24
  import com.reactnativenavigation.views.toptabs.TopTabsLayoutCreator;
25
25
  import com.reactnativenavigation.views.toptabs.TopTabsViewPager;
26
26
 
27
+ import org.junit.Ignore;
27
28
  import org.junit.Test;
28
29
  import org.mockito.Mockito;
29
30
 
@@ -123,6 +124,7 @@ public class TopTabsViewControllerTest extends BaseTest {
123
124
  }
124
125
 
125
126
  @Test
127
+ @Ignore("TopTabs not yet well supported")
126
128
  public void lifecycleMethodsSentWhenSelectedTabChanges() {
127
129
  stack.ensureViewIsCreated();
128
130
  uut.ensureViewIsCreated();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.24.0",
3
+ "version": "7.24.1",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,