react-native-navigation 7.24.0 → 7.24.3
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.
- package/lib/Mock/Components/ComponentScreen.tsx +1 -1
- package/lib/Mock/Components/NavigationButton.tsx +1 -1
- package/lib/Mock/Components/TopBar.tsx +6 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java +13 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/SystemUiUtils.kt +3 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +1 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenter.java +4 -6
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +2 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java +6 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/SystemUiUtilsTest.kt +27 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +17 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +25 -0
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +1 -2
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +2 -0
- package/lib/dist/Mock/Components/ComponentScreen.js +2 -2
- package/lib/dist/Mock/Components/NavigationButton.d.ts +1 -1
- package/lib/dist/Mock/Components/NavigationButton.js +3 -3
- package/lib/dist/Mock/Components/TopBar.d.ts +1 -2
- package/lib/dist/Mock/Components/TopBar.js +3 -3
- package/lib/ios/RNNComponentRootView.m +0 -14
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Button, View, Text } from 'react-native';
|
|
3
|
-
import { Navigation } from '
|
|
3
|
+
import { Navigation } from 'react-native-navigation';
|
|
4
4
|
import { ComponentProps } from '../ComponentProps';
|
|
5
5
|
import { VISIBLE_SCREEN_TEST_ID } from '../constants';
|
|
6
6
|
import { LayoutStore } from '../Stores/LayoutStore';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Button, TouchableOpacity } from 'react-native';
|
|
3
|
-
import { Navigation, OptionsTopBarButton } from '
|
|
3
|
+
import { Navigation, OptionsTopBarButton } from 'react-native-navigation';
|
|
4
4
|
import { events } from '../Stores/EventsStore';
|
|
5
5
|
|
|
6
6
|
interface ButtonProps {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Button, View, Text } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
Navigation,
|
|
5
|
+
OptionsTopBar,
|
|
6
|
+
OptionsTopBarBackButton,
|
|
7
|
+
OptionsTopBarButton,
|
|
8
|
+
} from 'react-native-navigation';
|
|
5
9
|
import ParentNode from '../Layouts/ParentNode';
|
|
6
10
|
import { LayoutStore } from '../Stores/LayoutStore';
|
|
7
11
|
import { NavigationButton } from './NavigationButton';
|
|
@@ -66,18 +66,22 @@ public class ReactView extends ReactRootView implements IReactView, Renderable {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
public void sendComponentWillStart(ComponentType type) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
|
@@ -78,12 +78,14 @@ public class ComponentViewController extends ChildController<ComponentLayout> {
|
|
|
78
78
|
if (view != null)
|
|
79
79
|
view.sendComponentWillStart();
|
|
80
80
|
super.onViewDidAppear();
|
|
81
|
+
view.requestApplyInsets();
|
|
81
82
|
if (view != null && lastVisibilityState == VisibilityState.Disappear) view.sendComponentStart();
|
|
82
83
|
lastVisibilityState = VisibilityState.Appear;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
@Override
|
|
86
87
|
public void onViewDisappear() {
|
|
88
|
+
if(lastVisibilityState == VisibilityState.Disappear)return;
|
|
87
89
|
lastVisibilityState = VisibilityState.Disappear;
|
|
88
90
|
if (view != null) view.sendComponentStop();
|
|
89
91
|
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.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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.
|
|
194
|
-
|
|
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
|
|
package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java
CHANGED
|
@@ -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();
|
|
@@ -109,6 +127,13 @@ public class ComponentViewControllerTest extends BaseTest {
|
|
|
109
127
|
Mockito.verify(view, Mockito.times(2)).sendComponentStart();
|
|
110
128
|
}
|
|
111
129
|
|
|
130
|
+
@Test
|
|
131
|
+
public void shouldCallApplyWindowInsetsWhenViewFullyAppeared(){
|
|
132
|
+
uut.ensureViewIsCreated();
|
|
133
|
+
uut.onViewDidAppear();
|
|
134
|
+
Mockito.verify(view).requestApplyInsets();
|
|
135
|
+
}
|
|
136
|
+
|
|
112
137
|
@Test
|
|
113
138
|
public void isViewShownOnlyIfComponentViewIsReady() {
|
|
114
139
|
Java6Assertions.assertThat(uut.isViewShown()).isFalse();
|
|
@@ -84,10 +84,9 @@ public class ModalStackTest extends BaseTest {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
@Test
|
|
87
|
-
public void
|
|
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();
|
|
@@ -4,7 +4,7 @@ exports.ComponentScreen = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
const react_native_1 = require("react-native");
|
|
7
|
-
const
|
|
7
|
+
const react_native_navigation_1 = require("react-native-navigation");
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const LayoutStore_1 = require("../Stores/LayoutStore");
|
|
10
10
|
const connect_1 = require("../connect");
|
|
@@ -43,7 +43,7 @@ exports.ComponentScreen = (0, connect_1.connect)(class extends react_1.Component
|
|
|
43
43
|
return react_1.default.createElement(react_native_1.View, { testID: bottomTabsOptions?.testID }, buttons);
|
|
44
44
|
}
|
|
45
45
|
render() {
|
|
46
|
-
const Component =
|
|
46
|
+
const Component = react_native_navigation_1.Navigation.mock.store.getWrappedComponent(this.props.layoutNode.data.name);
|
|
47
47
|
if (!Component)
|
|
48
48
|
throw new Error(`${this.props.layoutNode.data.name} has not been registered.`);
|
|
49
49
|
return (react_1.default.createElement(react_native_1.View, { testID: this.isVisible() ? constants_1.VISIBLE_SCREEN_TEST_ID : undefined },
|
|
@@ -4,7 +4,7 @@ exports.NavigationButton = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
const react_native_1 = require("react-native");
|
|
7
|
-
const
|
|
7
|
+
const react_native_navigation_1 = require("react-native-navigation");
|
|
8
8
|
const EventsStore_1 = require("../Stores/EventsStore");
|
|
9
9
|
const NavigationButton = class extends react_1.Component {
|
|
10
10
|
ref = undefined;
|
|
@@ -23,8 +23,8 @@ const NavigationButton = class extends react_1.Component {
|
|
|
23
23
|
//@ts-ignore
|
|
24
24
|
const buttonComponentId = button.component.componentId;
|
|
25
25
|
//@ts-ignore
|
|
26
|
-
const Component =
|
|
27
|
-
const props =
|
|
26
|
+
const Component = react_native_navigation_1.Navigation.mock.store.getComponentClassForName(button.component.name)();
|
|
27
|
+
const props = react_native_navigation_1.Navigation.mock.store.getPropsForId(buttonComponentId);
|
|
28
28
|
return (react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => {
|
|
29
29
|
if (this.ref) {
|
|
30
30
|
// @ts-ignore
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { OptionsTopBarButton } from '
|
|
3
|
-
import { OptionsTopBar, OptionsTopBarBackButton } from '../../src/interfaces/Options';
|
|
2
|
+
import { OptionsTopBar, OptionsTopBarBackButton, OptionsTopBarButton } from 'react-native-navigation';
|
|
4
3
|
import ParentNode from '../Layouts/ParentNode';
|
|
5
4
|
export interface TopBarProps {
|
|
6
5
|
layoutNode: ParentNode;
|
|
@@ -4,7 +4,7 @@ exports.TopBar = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
const react_native_1 = require("react-native");
|
|
7
|
-
const
|
|
7
|
+
const react_native_navigation_1 = require("react-native-navigation");
|
|
8
8
|
const LayoutStore_1 = require("../Stores/LayoutStore");
|
|
9
9
|
const NavigationButton_1 = require("./NavigationButton");
|
|
10
10
|
const EventsStore_1 = require("../Stores/EventsStore");
|
|
@@ -54,8 +54,8 @@ const TopBar = class extends react_1.Component {
|
|
|
54
54
|
} }));
|
|
55
55
|
}
|
|
56
56
|
renderComponent(id, name, testID) {
|
|
57
|
-
const Component =
|
|
58
|
-
const props =
|
|
57
|
+
const Component = react_native_navigation_1.Navigation.mock.store.getComponentClassForName(name)();
|
|
58
|
+
const props = react_native_navigation_1.Navigation.mock.store.getPropsForId(id);
|
|
59
59
|
return (react_1.default.createElement(react_native_1.View, { key: id, testID: testID },
|
|
60
60
|
react_1.default.createElement(Component, { ...props, componentId: id })));
|
|
61
61
|
}
|
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
@implementation RNNComponentRootView
|
|
4
4
|
|
|
5
|
-
- (instancetype)initWithBridge:(RCTBridge *)bridge
|
|
6
|
-
moduleName:(NSString *)moduleName
|
|
7
|
-
initialProperties:(NSDictionary *)initialProperties
|
|
8
|
-
eventEmitter:(RNNEventEmitter *)eventEmitter
|
|
9
|
-
reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
|
|
10
|
-
self = [super initWithBridge:bridge
|
|
11
|
-
moduleName:moduleName
|
|
12
|
-
initialProperties:initialProperties
|
|
13
|
-
eventEmitter:eventEmitter
|
|
14
|
-
reactViewReadyBlock:reactViewReadyBlock];
|
|
15
|
-
[bridge.uiManager setAvailableSize:UIScreen.mainScreen.bounds.size forRootView:self];
|
|
16
|
-
return self;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
5
|
- (NSString *)componentType {
|
|
20
6
|
return ComponentTypeScreen;
|
|
21
7
|
}
|