react-native-navigation 7.23.1-snapshot.394 → 7.23.1-snapshot.398
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/dist/Mock/Components/ComponentScreen.js +11 -1
- package/lib/dist/Mock/Stores/EventsStore.d.ts +3 -0
- package/lib/dist/Mock/Stores/EventsStore.js +7 -0
- package/lib/dist/Mock/mocks/NativeEventsReceiver.d.ts +1 -1
- package/lib/dist/Mock/mocks/NativeEventsReceiver.js +5 -2
- package/lib/src/Mock/Components/ComponentScreen.tsx +12 -1
- package/lib/src/Mock/Stores/EventsStore.ts +8 -0
- package/lib/src/Mock/mocks/NativeEventsReceiver.ts +5 -2
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@ const constants_1 = require("../constants");
|
|
|
9
9
|
const LayoutStore_1 = require("../Stores/LayoutStore");
|
|
10
10
|
const connect_1 = require("../connect");
|
|
11
11
|
const TopBar_1 = require("./TopBar");
|
|
12
|
+
const EventsStore_1 = require("../Stores/EventsStore");
|
|
13
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
14
|
exports.ComponentScreen = connect_1.connect(class extends react_1.Component {
|
|
13
15
|
constructor(props) {
|
|
14
16
|
super(props);
|
|
@@ -29,13 +31,21 @@ exports.ComponentScreen = connect_1.connect(class extends react_1.Component {
|
|
|
29
31
|
const buttons = bottomTabs.children.map((child, i) => {
|
|
30
32
|
const bottomTabOptions = child.resolveOptions().bottomTab;
|
|
31
33
|
return (react_1.default.createElement(react_native_1.View, { key: `tab-${i}` },
|
|
32
|
-
react_1.default.createElement(react_native_1.Button, { testID: bottomTabOptions?.testID, title: bottomTabOptions?.text || '', onPress: () =>
|
|
34
|
+
react_1.default.createElement(react_native_1.Button, { testID: bottomTabOptions?.testID, title: bottomTabOptions?.text || '', onPress: () => {
|
|
35
|
+
EventsStore_1.events.invokeBottomTabPressed({
|
|
36
|
+
tabIndex: i,
|
|
37
|
+
});
|
|
38
|
+
if (lodash_1.default.defaultTo(bottomTabOptions?.selectTabOnPress, true))
|
|
39
|
+
LayoutStore_1.LayoutStore.selectTabIndex(this.props.layoutNode.getBottomTabs(), i);
|
|
40
|
+
} }),
|
|
33
41
|
react_1.default.createElement(react_native_1.Text, null, bottomTabOptions?.badge)));
|
|
34
42
|
});
|
|
35
43
|
return react_1.default.createElement(react_native_1.View, { testID: bottomTabsOptions?.testID }, buttons);
|
|
36
44
|
}
|
|
37
45
|
render() {
|
|
38
46
|
const Component = __1.Navigation.mock.store.getWrappedComponent(this.props.layoutNode.data.name);
|
|
47
|
+
if (!Component)
|
|
48
|
+
throw new Error(`${this.props.layoutNode.data.name} has not been registered.`);
|
|
39
49
|
return (react_1.default.createElement(react_native_1.View, { testID: this.isVisible() ? constants_1.VISIBLE_SCREEN_TEST_ID : undefined },
|
|
40
50
|
this.props.layoutNode.getStack() && (react_1.default.createElement(TopBar_1.TopBar, { layoutNode: this.props.layoutNode, topBarOptions: this.props.layoutNode.resolveOptions().topBar, backButtonOptions: this.props.layoutNode.resolveOptions().topBar?.backButton })),
|
|
41
51
|
this.renderTabBar(),
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ComponentDidDisappearEvent, ComponentWillAppearEvent, ModalDismissedEvent } from '../../interfaces/ComponentEvents';
|
|
2
2
|
import { ComponentDidAppearEvent, NavigationButtonPressedEvent } from '../../index';
|
|
3
|
+
import { BottomTabPressedEvent } from '../../interfaces/Events';
|
|
3
4
|
export declare const events: {
|
|
4
5
|
navigationButtonPressed: ((_event: NavigationButtonPressedEvent) => void)[];
|
|
5
6
|
componentWillAppear: ((_event: ComponentWillAppearEvent) => void)[];
|
|
6
7
|
componentDidAppear: ((_event: ComponentDidAppearEvent) => void)[];
|
|
7
8
|
componentDidDisappear: ((_event: ComponentDidDisappearEvent) => void)[];
|
|
8
9
|
modalDismissed: ((_event: ModalDismissedEvent) => void)[];
|
|
10
|
+
bottomTabPressed: ((_event: BottomTabPressedEvent) => void)[];
|
|
9
11
|
invokeComponentWillAppear: (event: ComponentWillAppearEvent) => void;
|
|
10
12
|
invokeComponentDidAppear: (event: ComponentDidAppearEvent) => void;
|
|
11
13
|
invokeComponentDidDisappear: (event: ComponentDidDisappearEvent) => void;
|
|
12
14
|
invokeModalDismissed: (event: ModalDismissedEvent) => void;
|
|
13
15
|
invokeNavigationButtonPressed: (event: NavigationButtonPressedEvent) => void;
|
|
16
|
+
invokeBottomTabPressed: (event: BottomTabPressedEvent) => void;
|
|
14
17
|
};
|
|
@@ -7,6 +7,7 @@ exports.events = {
|
|
|
7
7
|
componentDidAppear: [(_event) => { }],
|
|
8
8
|
componentDidDisappear: [(_event) => { }],
|
|
9
9
|
modalDismissed: [(_event) => { }],
|
|
10
|
+
bottomTabPressed: [(_event) => { }],
|
|
10
11
|
invokeComponentWillAppear: (event) => {
|
|
11
12
|
exports.events.componentWillAppear &&
|
|
12
13
|
exports.events.componentWillAppear.forEach((listener) => {
|
|
@@ -37,4 +38,10 @@ exports.events = {
|
|
|
37
38
|
listener(event);
|
|
38
39
|
});
|
|
39
40
|
},
|
|
41
|
+
invokeBottomTabPressed: (event) => {
|
|
42
|
+
exports.events.bottomTabPressed &&
|
|
43
|
+
exports.events.bottomTabPressed?.forEach((listener) => {
|
|
44
|
+
listener(event);
|
|
45
|
+
});
|
|
46
|
+
},
|
|
40
47
|
};
|
|
@@ -7,7 +7,7 @@ export declare class NativeEventsReceiver {
|
|
|
7
7
|
registerComponentDidAppearListener(callback: (event: ComponentDidAppearEvent) => void): EmitterSubscription;
|
|
8
8
|
registerComponentDidDisappearListener(callback: (event: ComponentDidDisappearEvent) => void): EmitterSubscription;
|
|
9
9
|
registerNavigationButtonPressedListener(callback: (event: NavigationButtonPressedEvent) => void): EmitterSubscription;
|
|
10
|
-
registerBottomTabPressedListener(
|
|
10
|
+
registerBottomTabPressedListener(callback: (data: BottomTabPressedEvent) => void): EmitterSubscription;
|
|
11
11
|
registerModalDismissedListener(callback: (event: ModalDismissedEvent) => void): EmitterSubscription;
|
|
12
12
|
registerModalAttemptedToDismissListener(_callback: (event: ModalAttemptedToDismissEvent) => void): EmitterSubscription;
|
|
13
13
|
registerSearchBarUpdatedListener(_callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription;
|
|
@@ -43,9 +43,12 @@ class NativeEventsReceiver {
|
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
registerBottomTabPressedListener(
|
|
46
|
+
registerBottomTabPressedListener(callback) {
|
|
47
|
+
EventsStore_1.events.bottomTabPressed.push(callback);
|
|
47
48
|
return {
|
|
48
|
-
remove: () => {
|
|
49
|
+
remove: () => {
|
|
50
|
+
lodash_1.default.remove(EventsStore_1.events.bottomTabPressed, (value) => value === callback);
|
|
51
|
+
},
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
54
|
registerModalDismissedListener(callback) {
|
|
@@ -6,6 +6,8 @@ import { VISIBLE_SCREEN_TEST_ID } from '../constants';
|
|
|
6
6
|
import { LayoutStore } from '../Stores/LayoutStore';
|
|
7
7
|
import { connect } from '../connect';
|
|
8
8
|
import { TopBar } from './TopBar';
|
|
9
|
+
import { events } from '../Stores/EventsStore';
|
|
10
|
+
import _ from 'lodash';
|
|
9
11
|
|
|
10
12
|
export const ComponentScreen = connect(
|
|
11
13
|
class extends Component<ComponentProps> {
|
|
@@ -34,7 +36,13 @@ export const ComponentScreen = connect(
|
|
|
34
36
|
<Button
|
|
35
37
|
testID={bottomTabOptions?.testID}
|
|
36
38
|
title={bottomTabOptions?.text || ''}
|
|
37
|
-
onPress={() =>
|
|
39
|
+
onPress={() => {
|
|
40
|
+
events.invokeBottomTabPressed({
|
|
41
|
+
tabIndex: i,
|
|
42
|
+
});
|
|
43
|
+
if (_.defaultTo(bottomTabOptions?.selectTabOnPress, true))
|
|
44
|
+
LayoutStore.selectTabIndex(this.props.layoutNode.getBottomTabs(), i);
|
|
45
|
+
}}
|
|
38
46
|
/>
|
|
39
47
|
<Text>{bottomTabOptions?.badge}</Text>
|
|
40
48
|
</View>
|
|
@@ -46,6 +54,9 @@ export const ComponentScreen = connect(
|
|
|
46
54
|
|
|
47
55
|
render() {
|
|
48
56
|
const Component = Navigation.mock.store.getWrappedComponent(this.props.layoutNode.data.name);
|
|
57
|
+
if (!Component)
|
|
58
|
+
throw new Error(`${this.props.layoutNode.data.name} has not been registered.`);
|
|
59
|
+
|
|
49
60
|
return (
|
|
50
61
|
<View testID={this.isVisible() ? VISIBLE_SCREEN_TEST_ID : undefined}>
|
|
51
62
|
{this.props.layoutNode.getStack() && (
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ModalDismissedEvent,
|
|
5
5
|
} from '../../interfaces/ComponentEvents';
|
|
6
6
|
import { ComponentDidAppearEvent, NavigationButtonPressedEvent } from '../../index';
|
|
7
|
+
import { BottomTabPressedEvent } from '../../interfaces/Events';
|
|
7
8
|
|
|
8
9
|
export const events = {
|
|
9
10
|
navigationButtonPressed: [(_event: NavigationButtonPressedEvent) => {}],
|
|
@@ -11,6 +12,7 @@ export const events = {
|
|
|
11
12
|
componentDidAppear: [(_event: ComponentDidAppearEvent) => {}],
|
|
12
13
|
componentDidDisappear: [(_event: ComponentDidDisappearEvent) => {}],
|
|
13
14
|
modalDismissed: [(_event: ModalDismissedEvent) => {}],
|
|
15
|
+
bottomTabPressed: [(_event: BottomTabPressedEvent) => {}],
|
|
14
16
|
invokeComponentWillAppear: (event: ComponentWillAppearEvent) => {
|
|
15
17
|
events.componentWillAppear &&
|
|
16
18
|
events.componentWillAppear.forEach((listener) => {
|
|
@@ -41,4 +43,10 @@ export const events = {
|
|
|
41
43
|
listener(event);
|
|
42
44
|
});
|
|
43
45
|
},
|
|
46
|
+
invokeBottomTabPressed: (event: BottomTabPressedEvent) => {
|
|
47
|
+
events.bottomTabPressed &&
|
|
48
|
+
events.bottomTabPressed?.forEach((listener) => {
|
|
49
|
+
listener(event);
|
|
50
|
+
});
|
|
51
|
+
},
|
|
44
52
|
};
|
|
@@ -73,10 +73,13 @@ export class NativeEventsReceiver {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
public registerBottomTabPressedListener(
|
|
76
|
-
|
|
76
|
+
callback: (data: BottomTabPressedEvent) => void
|
|
77
77
|
): EmitterSubscription {
|
|
78
|
+
events.bottomTabPressed.push(callback);
|
|
78
79
|
return {
|
|
79
|
-
remove: () => {
|
|
80
|
+
remove: () => {
|
|
81
|
+
_.remove(events.bottomTabPressed, (value) => value === callback);
|
|
82
|
+
},
|
|
80
83
|
} as EmitterSubscription;
|
|
81
84
|
}
|
|
82
85
|
|
package/package.json
CHANGED