react-native-navigation 7.23.1-snapshot.393 → 7.23.1-snapshot.405

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/README.md CHANGED
@@ -8,7 +8,6 @@
8
8
  <a href="https://www.npmjs.com/package/react-native-navigation"><img src="https://img.shields.io/npm/v/react-native-navigation/latest.svg?style=flat-square" alt="NPM latest version"></a>
9
9
  <a href="https://www.npmjs.com/package/react-native-navigation"><img src="https://img.shields.io/npm/v/react-native-navigation/snapshot.svg?style=flat-square" alt="NPM snapshot version"></a>
10
10
  <a href="https://jenkins-oss.wixpress.com/job/multi-react-native-navigation-master/"><img src="https://img.shields.io/jenkins/s/http/jenkins-oss.wixpress.com:8080/job/multi-react-native-navigation-master.svg?style=flat-square" alt="NPM snapshot version"></a>
11
- <a href="https://github.com/wix/react-native-navigation/pulls"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fmerge-chance.info%2Fbadge%3Frepo%3Dwix/react-native-navigation"></a>
12
11
 
13
12
  </p>
14
13
  <p align="center">
@@ -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: () => LayoutStore_1.LayoutStore.selectTabIndex(this.props.layoutNode.getBottomTabs(), i) }),
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(_callback: (data: BottomTabPressedEvent) => void): EmitterSubscription;
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(_callback) {
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) {
@@ -113,7 +113,6 @@
113
113
  - (void)onBridgeWillReload {
114
114
  dispatch_async(dispatch_get_main_queue(), ^{
115
115
  [self->_overlayManager dismissAllOverlays];
116
- [self->_modalManager dismissAllModalsSynchronosly];
117
116
  [self->_componentRegistry clear];
118
117
  UIApplication.sharedApplication.delegate.window.rootViewController = nil;
119
118
  });
@@ -22,7 +22,6 @@ typedef void (^RNNTransitionRejectionBlock)(NSString *_Nonnull code, NSString *_
22
22
  animated:(BOOL)animated
23
23
  completion:(RNNTransitionCompletionBlock _Nullable)completion;
24
24
  - (void)dismissAllModalsAnimated:(BOOL)animated completion:(void (^__nullable)(void))completion;
25
- - (void)dismissAllModalsSynchronosly;
26
25
 
27
26
  - (void)reset;
28
27
 
@@ -130,21 +130,6 @@
130
130
  completion();
131
131
  }
132
132
 
133
- - (void)dismissAllModalsSynchronosly {
134
- if (_presentedModals.count) {
135
- dispatch_semaphore_t sem = dispatch_semaphore_create(0);
136
- [self dismissAllModalsAnimated:NO
137
- completion:^{
138
- dispatch_semaphore_signal(sem);
139
- }];
140
-
141
- while (dispatch_semaphore_wait(sem, DISPATCH_TIME_NOW)) {
142
- [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
143
- beforeDate:[NSDate dateWithTimeIntervalSinceNow:0]];
144
- }
145
- }
146
- }
147
-
148
133
  - (void)reset {
149
134
  [_presentedModals removeAllObjects];
150
135
  [_pendingModalIdsToDismiss removeAllObjects];
@@ -177,8 +162,7 @@
177
162
  _dismissModalTransitionDelegate;
178
163
  }
179
164
 
180
- if ((modalToDismiss == topPresentedVC ||
181
- [[topPresentedVC childViewControllers] containsObject:modalToDismiss])) {
165
+ if ((modalToDismiss == topPresentedVC || [topPresentedVC findViewController:modalToDismiss])) {
182
166
  [self dismissSearchController:modalToDismiss];
183
167
  [modalToDismiss
184
168
  dismissViewControllerAnimated:animated
@@ -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={() => LayoutStore.selectTabIndex(this.props.layoutNode.getBottomTabs(), i)}
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
- _callback: (data: BottomTabPressedEvent) => void
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.23.1-snapshot.393",
3
+ "version": "7.23.1-snapshot.405",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,