react-native-navigation 7.28.1 → 7.29.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.
- package/lib/Mock/Components/ComponentScreen.tsx +2 -1
- package/lib/Mock/Components/NavigationButton.tsx +8 -4
- package/lib/Mock/Layouts/BottomTabsNode.ts +3 -3
- package/lib/Mock/actions/layoutActions.ts +10 -0
- package/lib/dist/Mock/Components/ComponentScreen.js +2 -1
- package/lib/dist/Mock/Components/NavigationButton.js +8 -4
- package/lib/dist/Mock/Layouts/BottomTabsNode.js +3 -3
- package/lib/dist/Mock/Layouts/LayoutNodeFactory.d.ts +1 -1
- package/lib/dist/Mock/actions/layoutActions.d.ts +2 -0
- package/lib/dist/Mock/actions/layoutActions.js +12 -0
- package/lib/ios/RNNDynamicIconCreator.m +2 -2
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { connect } from '../connect';
|
|
|
8
8
|
import { TopBar } from './TopBar';
|
|
9
9
|
import { events } from '../Stores/EventsStore';
|
|
10
10
|
import _ from 'lodash';
|
|
11
|
+
import { switchTabByIndex } from '../actions/layoutActions';
|
|
11
12
|
|
|
12
13
|
export const ComponentScreen = connect(
|
|
13
14
|
class extends Component<ComponentProps> {
|
|
@@ -41,7 +42,7 @@ export const ComponentScreen = connect(
|
|
|
41
42
|
tabIndex: i,
|
|
42
43
|
});
|
|
43
44
|
if (_.defaultTo(bottomTabOptions?.selectTabOnPress, true))
|
|
44
|
-
|
|
45
|
+
switchTabByIndex(this.props.layoutNode.getBottomTabs(), i);
|
|
45
46
|
}}
|
|
46
47
|
/>
|
|
47
48
|
<Text>{bottomTabOptions?.badge}</Text>
|
|
@@ -32,10 +32,14 @@ export const NavigationButton = class extends Component<ButtonProps> {
|
|
|
32
32
|
|
|
33
33
|
renderButtonComponent() {
|
|
34
34
|
const { button, componentId } = this.props;
|
|
35
|
-
|
|
35
|
+
// @ts-ignore
|
|
36
36
|
const buttonComponentId = button.component!.componentId;
|
|
37
|
-
|
|
38
|
-
const
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
const ComponentClass = Navigation.mock.store.getComponentClassForName(button.component.name);
|
|
39
|
+
if (!ComponentClass) {
|
|
40
|
+
throw new Error(`Cannot find registered component for: ${button.component?.name}`);
|
|
41
|
+
}
|
|
42
|
+
const ButtonComponent = ComponentClass();
|
|
39
43
|
const props = Navigation.mock.store.getPropsForId(buttonComponentId);
|
|
40
44
|
return (
|
|
41
45
|
<TouchableOpacity
|
|
@@ -52,7 +56,7 @@ export const NavigationButton = class extends Component<ButtonProps> {
|
|
|
52
56
|
}}
|
|
53
57
|
testID={button.testID}
|
|
54
58
|
>
|
|
55
|
-
<
|
|
59
|
+
<ButtonComponent
|
|
56
60
|
key={buttonComponentId}
|
|
57
61
|
{...props}
|
|
58
62
|
componentId={buttonComponentId}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Options } from '../../src/index';
|
|
3
|
-
import {
|
|
3
|
+
import { switchTabByIndex } from '../actions/layoutActions';
|
|
4
4
|
import ParentNode from './ParentNode';
|
|
5
5
|
|
|
6
6
|
export default class BottomTabsNode extends ParentNode {
|
|
@@ -13,7 +13,7 @@ export default class BottomTabsNode extends ParentNode {
|
|
|
13
13
|
super.mergeOptions(options);
|
|
14
14
|
if (options.bottomTabs?.currentTabIndex) {
|
|
15
15
|
this.selectedIndex = options.bottomTabs?.currentTabIndex;
|
|
16
|
-
|
|
16
|
+
switchTabByIndex(this, this.selectedIndex);
|
|
17
17
|
}
|
|
18
18
|
if (options.bottomTabs?.currentTabId) {
|
|
19
19
|
const index = _.findIndex(
|
|
@@ -21,7 +21,7 @@ export default class BottomTabsNode extends ParentNode {
|
|
|
21
21
|
(child) => child.nodeId === options?.bottomTabs?.currentTabId
|
|
22
22
|
);
|
|
23
23
|
if (index !== -1) this.selectedIndex = index;
|
|
24
|
-
|
|
24
|
+
switchTabByIndex(this, this.selectedIndex);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ParentNode from '../Layouts/ParentNode';
|
|
2
|
+
import { LayoutStore } from '../Stores/LayoutStore';
|
|
3
|
+
|
|
4
|
+
export const switchTabByIndex = (bottomTabs: ParentNode | undefined, index: number) => {
|
|
5
|
+
if (bottomTabs) {
|
|
6
|
+
LayoutStore.getVisibleLayout().componentDidDisappear();
|
|
7
|
+
LayoutStore.selectTabIndex(bottomTabs, index);
|
|
8
|
+
LayoutStore.getVisibleLayout().componentDidAppear();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -11,6 +11,7 @@ const connect_1 = require("../connect");
|
|
|
11
11
|
const TopBar_1 = require("./TopBar");
|
|
12
12
|
const EventsStore_1 = require("../Stores/EventsStore");
|
|
13
13
|
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
14
|
+
const layoutActions_1 = require("../actions/layoutActions");
|
|
14
15
|
exports.ComponentScreen = (0, connect_1.connect)(class extends react_1.Component {
|
|
15
16
|
constructor(props) {
|
|
16
17
|
super(props);
|
|
@@ -36,7 +37,7 @@ exports.ComponentScreen = (0, connect_1.connect)(class extends react_1.Component
|
|
|
36
37
|
tabIndex: i,
|
|
37
38
|
});
|
|
38
39
|
if (lodash_1.default.defaultTo(bottomTabOptions?.selectTabOnPress, true))
|
|
39
|
-
|
|
40
|
+
(0, layoutActions_1.switchTabByIndex)(this.props.layoutNode.getBottomTabs(), i);
|
|
40
41
|
} }),
|
|
41
42
|
react_1.default.createElement(react_native_1.Text, null, bottomTabOptions?.badge)));
|
|
42
43
|
});
|
|
@@ -20,10 +20,14 @@ const NavigationButton = class extends react_1.Component {
|
|
|
20
20
|
}
|
|
21
21
|
renderButtonComponent() {
|
|
22
22
|
const { button, componentId } = this.props;
|
|
23
|
-
|
|
23
|
+
// @ts-ignore
|
|
24
24
|
const buttonComponentId = button.component.componentId;
|
|
25
|
-
|
|
26
|
-
const
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
const ComponentClass = react_native_navigation_1.Navigation.mock.store.getComponentClassForName(button.component.name);
|
|
27
|
+
if (!ComponentClass) {
|
|
28
|
+
throw new Error(`Cannot find registered component for: ${button.component?.name}`);
|
|
29
|
+
}
|
|
30
|
+
const ButtonComponent = ComponentClass();
|
|
27
31
|
const props = react_native_navigation_1.Navigation.mock.store.getPropsForId(buttonComponentId);
|
|
28
32
|
return (react_1.default.createElement(react_native_1.TouchableOpacity, { onPress: () => {
|
|
29
33
|
if (this.ref) {
|
|
@@ -35,7 +39,7 @@ const NavigationButton = class extends react_1.Component {
|
|
|
35
39
|
componentId: componentId,
|
|
36
40
|
});
|
|
37
41
|
}, testID: button.testID },
|
|
38
|
-
react_1.default.createElement(
|
|
42
|
+
react_1.default.createElement(ButtonComponent, { key: buttonComponentId, ...props, componentId: buttonComponentId, ref: (ref) => (this.ref = ref) })));
|
|
39
43
|
}
|
|
40
44
|
invokeOnClick(stateNode) {
|
|
41
45
|
if (stateNode.children) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
5
|
-
const
|
|
5
|
+
const layoutActions_1 = require("../actions/layoutActions");
|
|
6
6
|
const ParentNode_1 = (0, tslib_1.__importDefault)(require("./ParentNode"));
|
|
7
7
|
class BottomTabsNode extends ParentNode_1.default {
|
|
8
8
|
selectedIndex = 0;
|
|
@@ -13,13 +13,13 @@ class BottomTabsNode extends ParentNode_1.default {
|
|
|
13
13
|
super.mergeOptions(options);
|
|
14
14
|
if (options.bottomTabs?.currentTabIndex) {
|
|
15
15
|
this.selectedIndex = options.bottomTabs?.currentTabIndex;
|
|
16
|
-
|
|
16
|
+
(0, layoutActions_1.switchTabByIndex)(this, this.selectedIndex);
|
|
17
17
|
}
|
|
18
18
|
if (options.bottomTabs?.currentTabId) {
|
|
19
19
|
const index = lodash_1.default.findIndex(this.children, (child) => child.nodeId === options?.bottomTabs?.currentTabId);
|
|
20
20
|
if (index !== -1)
|
|
21
21
|
this.selectedIndex = index;
|
|
22
|
-
|
|
22
|
+
(0, layoutActions_1.switchTabByIndex)(this, this.selectedIndex);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
getVisibleLayout() {
|
|
@@ -3,5 +3,5 @@ import ComponentNode from './ComponentNode';
|
|
|
3
3
|
import Stack from './StackNode';
|
|
4
4
|
import ParentNode from './ParentNode';
|
|
5
5
|
export default class LayoutNodeFactory {
|
|
6
|
-
static create(layout: any, parentNode?: ParentNode):
|
|
6
|
+
static create(layout: any, parentNode?: ParentNode): Stack | BottomTabs | ComponentNode;
|
|
7
7
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.switchTabByIndex = void 0;
|
|
4
|
+
const LayoutStore_1 = require("../Stores/LayoutStore");
|
|
5
|
+
const switchTabByIndex = (bottomTabs, index) => {
|
|
6
|
+
if (bottomTabs) {
|
|
7
|
+
LayoutStore_1.LayoutStore.getVisibleLayout().componentDidDisappear();
|
|
8
|
+
LayoutStore_1.LayoutStore.selectTabIndex(bottomTabs, index);
|
|
9
|
+
LayoutStore_1.LayoutStore.getVisibleLayout().componentDidAppear();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
exports.switchTabByIndex = switchTabByIndex;
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
UIColor *darkBackgroundColor = [backgroundColor resolvedColorWithTraitCollection:[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|
|
15
15
|
UIImage *darkImage = [[self.iconDrawer draw:iconImage
|
|
16
16
|
imageColor:darkColor
|
|
17
|
-
backgroundColor:
|
|
17
|
+
backgroundColor:darkBackgroundColor
|
|
18
18
|
size:iconSize
|
|
19
19
|
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
20
20
|
UIImage *lightImage = [[self.iconDrawer draw:iconImage
|
|
21
21
|
imageColor:lightColor
|
|
22
|
-
backgroundColor:
|
|
22
|
+
backgroundColor:lightBackgroundColor
|
|
23
23
|
size:iconSize
|
|
24
24
|
cornerRadius:cornerRadius] imageWithInsets:buttonOptions.iconInsets.UIEdgeInsets];
|
|
25
25
|
[lightImage.imageAsset registerImage:darkImage withTraitCollection:[UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]];
|