react-native-navigation 7.31.1 → 7.32.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.
@@ -4,7 +4,7 @@ import {
4
4
  ModalDismissedEvent,
5
5
  } from '../../src/interfaces/ComponentEvents';
6
6
  import { ComponentDidAppearEvent, NavigationButtonPressedEvent } from '../../src/index';
7
- import { BottomTabPressedEvent } from '../../src/interfaces/Events';
7
+ import { BottomTabPressedEvent, CommandCompletedEvent } from '../../src/interfaces/Events';
8
8
 
9
9
  export const events = {
10
10
  navigationButtonPressed: [(_event: NavigationButtonPressedEvent) => {}],
@@ -13,6 +13,7 @@ export const events = {
13
13
  componentDidDisappear: [(_event: ComponentDidDisappearEvent) => {}],
14
14
  modalDismissed: [(_event: ModalDismissedEvent) => {}],
15
15
  bottomTabPressed: [(_event: BottomTabPressedEvent) => {}],
16
+ commandCompleted: [(_event: CommandCompletedEvent) => {}],
16
17
  invokeComponentWillAppear: (event: ComponentWillAppearEvent) => {
17
18
  events.componentWillAppear &&
18
19
  events.componentWillAppear.forEach((listener) => {
@@ -49,4 +50,10 @@ export const events = {
49
50
  listener(event);
50
51
  });
51
52
  },
53
+ invokeCommandCompleted: (event: CommandCompletedEvent) => {
54
+ events.commandCompleted &&
55
+ events.commandCompleted.forEach((listener) => {
56
+ listener(event);
57
+ });
58
+ },
52
59
  };
@@ -5,11 +5,12 @@ import { events } from '../Stores/EventsStore';
5
5
  import _ from 'lodash';
6
6
  import ComponentNode from '../Layouts/ComponentNode';
7
7
  import { Constants } from '../../src/adapters/Constants';
8
+ import { CommandName } from '../../src/interfaces/CommandName';
8
9
 
9
10
  export class NativeCommandsSender {
10
11
  constructor() {}
11
12
 
12
- setRoot(_commandId: string, layout: { root: any; modals: any[]; overlays: any[] }) {
13
+ setRoot(commandId: string, layout: { root: any; modals: any[]; overlays: any[] }) {
13
14
  return new Promise((resolve) => {
14
15
  if (LayoutStore.getVisibleLayout()) {
15
16
  LayoutStore.getVisibleLayout().componentDidDisappear();
@@ -20,6 +21,7 @@ export class NativeCommandsSender {
20
21
  LayoutStore.setRoot(layoutNode);
21
22
  layoutNode.getVisibleLayout().componentDidAppear();
22
23
  resolve(layout.root.nodeId);
24
+ this.reportCommandCompletion(CommandName.SetRoot, commandId);
23
25
  });
24
26
  }
25
27
 
@@ -31,7 +33,7 @@ export class NativeCommandsSender {
31
33
  LayoutStore.mergeOptions(componentId, options);
32
34
  }
33
35
 
34
- push(_commandId: string, onComponentId: string, layout: LayoutNode) {
36
+ push(commandId: string, onComponentId: string, layout: LayoutNode) {
35
37
  return new Promise((resolve) => {
36
38
  const stack = LayoutStore.getLayoutById(onComponentId).getStack();
37
39
  const layoutNode = LayoutNodeFactory.create(layout, stack);
@@ -39,45 +41,51 @@ export class NativeCommandsSender {
39
41
  LayoutStore.push(layoutNode, stack);
40
42
  stack.getVisibleLayout().componentDidAppear();
41
43
  resolve(stack.getVisibleLayout().nodeId);
44
+ this.reportCommandCompletion(CommandName.Push, commandId);
42
45
  });
43
46
  }
44
47
 
45
- pop(_commandId: string, componentId: string, _options?: object) {
48
+ pop(commandId: string, componentId: string, _options?: object) {
46
49
  return new Promise((resolve) => {
47
50
  const poppedChild = _.last(
48
51
  LayoutStore.getLayoutById(componentId).getStack().children
49
52
  ) as ComponentNode;
50
53
  LayoutStore.pop(componentId);
51
54
  resolve(poppedChild.nodeId);
55
+ this.reportCommandCompletion(CommandName.Pop, commandId);
52
56
  });
53
57
  }
54
58
 
55
- popTo(_commandId: string, componentId: string, _options?: object) {
59
+ popTo(commandId: string, componentId: string, _options?: object) {
56
60
  return new Promise((resolve) => {
57
61
  LayoutStore.popTo(componentId);
58
62
  resolve(componentId);
63
+ this.reportCommandCompletion(CommandName.PopTo, commandId);
59
64
  });
60
65
  }
61
66
 
62
- popToRoot(_commandId: string, componentId: string, _options?: object) {
67
+ popToRoot(commandId: string, componentId: string, _options?: object) {
63
68
  LayoutStore.popToRoot(componentId);
69
+ this.reportCommandCompletion(CommandName.PopToRoot, commandId);
64
70
  }
65
71
 
66
- setStackRoot(_commandId: string, onComponentId: string, layout: object) {
72
+ setStackRoot(commandId: string, onComponentId: string, layout: object) {
67
73
  LayoutStore.setStackRoot(onComponentId, layout);
74
+ this.reportCommandCompletion(CommandName.SetStackRoot, commandId);
68
75
  }
69
76
 
70
- showModal(_commandId: string, layout: object) {
77
+ showModal(commandId: string, layout: object) {
71
78
  return new Promise((resolve) => {
72
79
  const layoutNode = LayoutNodeFactory.create(layout);
73
80
  LayoutStore.getVisibleLayout().componentDidDisappear();
74
81
  LayoutStore.showModal(layoutNode);
75
82
  layoutNode.componentDidAppear();
76
83
  resolve(layoutNode.nodeId);
84
+ this.reportCommandCompletion(CommandName.ShowModal, commandId);
77
85
  });
78
86
  }
79
87
 
80
- dismissModal(_commandId: string, componentId: string, _options?: object) {
88
+ dismissModal(commandId: string, componentId: string, _options?: object) {
81
89
  return new Promise((resolve, reject) => {
82
90
  const modal = LayoutStore.getModalById(componentId);
83
91
  if (modal) {
@@ -91,31 +99,38 @@ export class NativeCommandsSender {
91
99
  });
92
100
  resolve(modalTopParent.nodeId);
93
101
  LayoutStore.getVisibleLayout().componentDidAppear();
102
+ this.reportCommandCompletion(CommandName.DismissModal, commandId);
94
103
  } else {
95
104
  reject(`component with id: ${componentId} is not a modal`);
96
105
  }
97
106
  });
98
107
  }
99
108
 
100
- dismissAllModals(_commandId: string, _options?: object) {
109
+ dismissAllModals(commandId: string, _options?: object) {
101
110
  LayoutStore.dismissAllModals();
111
+ this.reportCommandCompletion(CommandName.DismissAllModals, commandId);
102
112
  }
103
113
 
104
- showOverlay(_commandId: string, layout: object) {
114
+ showOverlay(commandId: string, layout: object) {
105
115
  const layoutNode = LayoutNodeFactory.create(layout);
106
116
  LayoutStore.showOverlay(layoutNode);
107
117
  layoutNode.componentDidAppear();
118
+ this.reportCommandCompletion(CommandName.ShowOverlay, commandId);
108
119
  }
109
120
 
110
- dismissOverlay(_commandId: string, componentId: string) {
121
+ dismissOverlay(commandId: string, componentId: string) {
111
122
  LayoutStore.dismissOverlay(componentId);
123
+ this.reportCommandCompletion(CommandName.DismissOverlay, commandId);
112
124
  }
113
125
 
114
- dismissAllOverlays(_commandId: string) {
126
+ dismissAllOverlays(commandId: string) {
115
127
  LayoutStore.dismissAllOverlays();
128
+ this.reportCommandCompletion(CommandName.DismissAllOverlays, commandId);
116
129
  }
117
130
 
118
- getLaunchArgs(_commandId: string) {}
131
+ getLaunchArgs(commandId: string) {
132
+ this.reportCommandCompletion(CommandName.GetLaunchArgs, commandId);
133
+ }
119
134
 
120
135
  getNavigationConstants(): Promise<Constants> {
121
136
  return Promise.resolve({
@@ -134,4 +149,12 @@ export class NativeCommandsSender {
134
149
  statusBarHeight: 0,
135
150
  };
136
151
  }
152
+
153
+ private reportCommandCompletion(commandName: string, commandId: string) {
154
+ events.invokeCommandCompleted({
155
+ commandName,
156
+ commandId,
157
+ completionTime: 0,
158
+ });
159
+ }
137
160
  }
@@ -127,8 +127,9 @@ export class NativeEventsReceiver {
127
127
  }
128
128
 
129
129
  public registerCommandCompletedListener(
130
- _callback: (data: CommandCompletedEvent) => void
130
+ callback: (data: CommandCompletedEvent) => void
131
131
  ): EmitterSubscription {
132
+ events.commandCompleted.push(callback);
132
133
  return {
133
134
  remove: () => {},
134
135
  } as EmitterSubscription;
@@ -208,7 +208,9 @@ public abstract class ParentController<T extends ViewGroup> extends ChildControl
208
208
  super.onConfigurationChanged(newConfig);
209
209
  Collection<? extends ViewController<?>> childControllers = getChildControllers();
210
210
  for(ViewController<?> controller: childControllers){
211
- controller.onConfigurationChanged(newConfig);
211
+ if (controller.isViewShown()) {
212
+ controller.onConfigurationChanged(newConfig);
213
+ }
212
214
  }
213
215
  }
214
216
  }
@@ -1,6 +1,6 @@
1
1
  import { ComponentDidDisappearEvent, ComponentWillAppearEvent, ModalDismissedEvent } from '../../src/interfaces/ComponentEvents';
2
2
  import { ComponentDidAppearEvent, NavigationButtonPressedEvent } from '../../src/index';
3
- import { BottomTabPressedEvent } from '../../src/interfaces/Events';
3
+ import { BottomTabPressedEvent, CommandCompletedEvent } from '../../src/interfaces/Events';
4
4
  export declare const events: {
5
5
  navigationButtonPressed: ((_event: NavigationButtonPressedEvent) => void)[];
6
6
  componentWillAppear: ((_event: ComponentWillAppearEvent) => void)[];
@@ -8,10 +8,12 @@ export declare const events: {
8
8
  componentDidDisappear: ((_event: ComponentDidDisappearEvent) => void)[];
9
9
  modalDismissed: ((_event: ModalDismissedEvent) => void)[];
10
10
  bottomTabPressed: ((_event: BottomTabPressedEvent) => void)[];
11
+ commandCompleted: ((_event: CommandCompletedEvent) => void)[];
11
12
  invokeComponentWillAppear: (event: ComponentWillAppearEvent) => void;
12
13
  invokeComponentDidAppear: (event: ComponentDidAppearEvent) => void;
13
14
  invokeComponentDidDisappear: (event: ComponentDidDisappearEvent) => void;
14
15
  invokeModalDismissed: (event: ModalDismissedEvent) => void;
15
16
  invokeNavigationButtonPressed: (event: NavigationButtonPressedEvent) => void;
16
17
  invokeBottomTabPressed: (event: BottomTabPressedEvent) => void;
18
+ invokeCommandCompleted: (event: CommandCompletedEvent) => void;
17
19
  };
@@ -8,6 +8,7 @@ exports.events = {
8
8
  componentDidDisappear: [(_event) => { }],
9
9
  modalDismissed: [(_event) => { }],
10
10
  bottomTabPressed: [(_event) => { }],
11
+ commandCompleted: [(_event) => { }],
11
12
  invokeComponentWillAppear: (event) => {
12
13
  exports.events.componentWillAppear &&
13
14
  exports.events.componentWillAppear.forEach((listener) => {
@@ -44,4 +45,10 @@ exports.events = {
44
45
  listener(event);
45
46
  });
46
47
  },
48
+ invokeCommandCompleted: (event) => {
49
+ exports.events.commandCompleted &&
50
+ exports.events.commandCompleted.forEach((listener) => {
51
+ listener(event);
52
+ });
53
+ },
47
54
  };
@@ -2,25 +2,26 @@ import { LayoutNode } from '../../src/commands/LayoutTreeCrawler';
2
2
  import { Constants } from '../../src/adapters/Constants';
3
3
  export declare class NativeCommandsSender {
4
4
  constructor();
5
- setRoot(_commandId: string, layout: {
5
+ setRoot(commandId: string, layout: {
6
6
  root: any;
7
7
  modals: any[];
8
8
  overlays: any[];
9
9
  }): Promise<unknown>;
10
10
  setDefaultOptions(options: object): void;
11
11
  mergeOptions(componentId: string, options: object): void;
12
- push(_commandId: string, onComponentId: string, layout: LayoutNode): Promise<unknown>;
13
- pop(_commandId: string, componentId: string, _options?: object): Promise<unknown>;
14
- popTo(_commandId: string, componentId: string, _options?: object): Promise<unknown>;
15
- popToRoot(_commandId: string, componentId: string, _options?: object): void;
16
- setStackRoot(_commandId: string, onComponentId: string, layout: object): void;
17
- showModal(_commandId: string, layout: object): Promise<unknown>;
18
- dismissModal(_commandId: string, componentId: string, _options?: object): Promise<unknown>;
19
- dismissAllModals(_commandId: string, _options?: object): void;
20
- showOverlay(_commandId: string, layout: object): void;
21
- dismissOverlay(_commandId: string, componentId: string): void;
22
- dismissAllOverlays(_commandId: string): void;
23
- getLaunchArgs(_commandId: string): void;
12
+ push(commandId: string, onComponentId: string, layout: LayoutNode): Promise<unknown>;
13
+ pop(commandId: string, componentId: string, _options?: object): Promise<unknown>;
14
+ popTo(commandId: string, componentId: string, _options?: object): Promise<unknown>;
15
+ popToRoot(commandId: string, componentId: string, _options?: object): void;
16
+ setStackRoot(commandId: string, onComponentId: string, layout: object): void;
17
+ showModal(commandId: string, layout: object): Promise<unknown>;
18
+ dismissModal(commandId: string, componentId: string, _options?: object): Promise<unknown>;
19
+ dismissAllModals(commandId: string, _options?: object): void;
20
+ showOverlay(commandId: string, layout: object): void;
21
+ dismissOverlay(commandId: string, componentId: string): void;
22
+ dismissAllOverlays(commandId: string): void;
23
+ getLaunchArgs(commandId: string): void;
24
24
  getNavigationConstants(): Promise<Constants>;
25
25
  getNavigationConstantsSync(): Constants;
26
+ private reportCommandCompletion;
26
27
  }
@@ -6,9 +6,10 @@ const LayoutStore_1 = require("../Stores/LayoutStore");
6
6
  const LayoutNodeFactory_1 = (0, tslib_1.__importDefault)(require("../Layouts/LayoutNodeFactory"));
7
7
  const EventsStore_1 = require("../Stores/EventsStore");
8
8
  const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
9
+ const CommandName_1 = require("../../src/interfaces/CommandName");
9
10
  class NativeCommandsSender {
10
11
  constructor() { }
11
- setRoot(_commandId, layout) {
12
+ setRoot(commandId, layout) {
12
13
  return new Promise((resolve) => {
13
14
  if (LayoutStore_1.LayoutStore.getVisibleLayout()) {
14
15
  LayoutStore_1.LayoutStore.getVisibleLayout().componentDidDisappear();
@@ -18,6 +19,7 @@ class NativeCommandsSender {
18
19
  LayoutStore_1.LayoutStore.setRoot(layoutNode);
19
20
  layoutNode.getVisibleLayout().componentDidAppear();
20
21
  resolve(layout.root.nodeId);
22
+ this.reportCommandCompletion(CommandName_1.CommandName.SetRoot, commandId);
21
23
  });
22
24
  }
23
25
  setDefaultOptions(options) {
@@ -26,7 +28,7 @@ class NativeCommandsSender {
26
28
  mergeOptions(componentId, options) {
27
29
  LayoutStore_1.LayoutStore.mergeOptions(componentId, options);
28
30
  }
29
- push(_commandId, onComponentId, layout) {
31
+ push(commandId, onComponentId, layout) {
30
32
  return new Promise((resolve) => {
31
33
  const stack = LayoutStore_1.LayoutStore.getLayoutById(onComponentId).getStack();
32
34
  const layoutNode = LayoutNodeFactory_1.default.create(layout, stack);
@@ -34,37 +36,43 @@ class NativeCommandsSender {
34
36
  LayoutStore_1.LayoutStore.push(layoutNode, stack);
35
37
  stack.getVisibleLayout().componentDidAppear();
36
38
  resolve(stack.getVisibleLayout().nodeId);
39
+ this.reportCommandCompletion(CommandName_1.CommandName.Push, commandId);
37
40
  });
38
41
  }
39
- pop(_commandId, componentId, _options) {
42
+ pop(commandId, componentId, _options) {
40
43
  return new Promise((resolve) => {
41
44
  const poppedChild = lodash_1.default.last(LayoutStore_1.LayoutStore.getLayoutById(componentId).getStack().children);
42
45
  LayoutStore_1.LayoutStore.pop(componentId);
43
46
  resolve(poppedChild.nodeId);
47
+ this.reportCommandCompletion(CommandName_1.CommandName.Pop, commandId);
44
48
  });
45
49
  }
46
- popTo(_commandId, componentId, _options) {
50
+ popTo(commandId, componentId, _options) {
47
51
  return new Promise((resolve) => {
48
52
  LayoutStore_1.LayoutStore.popTo(componentId);
49
53
  resolve(componentId);
54
+ this.reportCommandCompletion(CommandName_1.CommandName.PopTo, commandId);
50
55
  });
51
56
  }
52
- popToRoot(_commandId, componentId, _options) {
57
+ popToRoot(commandId, componentId, _options) {
53
58
  LayoutStore_1.LayoutStore.popToRoot(componentId);
59
+ this.reportCommandCompletion(CommandName_1.CommandName.PopToRoot, commandId);
54
60
  }
55
- setStackRoot(_commandId, onComponentId, layout) {
61
+ setStackRoot(commandId, onComponentId, layout) {
56
62
  LayoutStore_1.LayoutStore.setStackRoot(onComponentId, layout);
63
+ this.reportCommandCompletion(CommandName_1.CommandName.SetStackRoot, commandId);
57
64
  }
58
- showModal(_commandId, layout) {
65
+ showModal(commandId, layout) {
59
66
  return new Promise((resolve) => {
60
67
  const layoutNode = LayoutNodeFactory_1.default.create(layout);
61
68
  LayoutStore_1.LayoutStore.getVisibleLayout().componentDidDisappear();
62
69
  LayoutStore_1.LayoutStore.showModal(layoutNode);
63
70
  layoutNode.componentDidAppear();
64
71
  resolve(layoutNode.nodeId);
72
+ this.reportCommandCompletion(CommandName_1.CommandName.ShowModal, commandId);
65
73
  });
66
74
  }
67
- dismissModal(_commandId, componentId, _options) {
75
+ dismissModal(commandId, componentId, _options) {
68
76
  return new Promise((resolve, reject) => {
69
77
  const modal = LayoutStore_1.LayoutStore.getModalById(componentId);
70
78
  if (modal) {
@@ -78,27 +86,34 @@ class NativeCommandsSender {
78
86
  });
79
87
  resolve(modalTopParent.nodeId);
80
88
  LayoutStore_1.LayoutStore.getVisibleLayout().componentDidAppear();
89
+ this.reportCommandCompletion(CommandName_1.CommandName.DismissModal, commandId);
81
90
  }
82
91
  else {
83
92
  reject(`component with id: ${componentId} is not a modal`);
84
93
  }
85
94
  });
86
95
  }
87
- dismissAllModals(_commandId, _options) {
96
+ dismissAllModals(commandId, _options) {
88
97
  LayoutStore_1.LayoutStore.dismissAllModals();
98
+ this.reportCommandCompletion(CommandName_1.CommandName.DismissAllModals, commandId);
89
99
  }
90
- showOverlay(_commandId, layout) {
100
+ showOverlay(commandId, layout) {
91
101
  const layoutNode = LayoutNodeFactory_1.default.create(layout);
92
102
  LayoutStore_1.LayoutStore.showOverlay(layoutNode);
93
103
  layoutNode.componentDidAppear();
104
+ this.reportCommandCompletion(CommandName_1.CommandName.ShowOverlay, commandId);
94
105
  }
95
- dismissOverlay(_commandId, componentId) {
106
+ dismissOverlay(commandId, componentId) {
96
107
  LayoutStore_1.LayoutStore.dismissOverlay(componentId);
108
+ this.reportCommandCompletion(CommandName_1.CommandName.DismissOverlay, commandId);
97
109
  }
98
- dismissAllOverlays(_commandId) {
110
+ dismissAllOverlays(commandId) {
99
111
  LayoutStore_1.LayoutStore.dismissAllOverlays();
112
+ this.reportCommandCompletion(CommandName_1.CommandName.DismissAllOverlays, commandId);
113
+ }
114
+ getLaunchArgs(commandId) {
115
+ this.reportCommandCompletion(CommandName_1.CommandName.GetLaunchArgs, commandId);
100
116
  }
101
- getLaunchArgs(_commandId) { }
102
117
  getNavigationConstants() {
103
118
  return Promise.resolve({
104
119
  topBarHeight: 0,
@@ -115,5 +130,12 @@ class NativeCommandsSender {
115
130
  statusBarHeight: 0,
116
131
  };
117
132
  }
133
+ reportCommandCompletion(commandName, commandId) {
134
+ EventsStore_1.events.invokeCommandCompleted({
135
+ commandName,
136
+ commandId,
137
+ completionTime: 0,
138
+ });
139
+ }
118
140
  }
119
141
  exports.NativeCommandsSender = NativeCommandsSender;
@@ -13,7 +13,7 @@ export declare class NativeEventsReceiver {
13
13
  registerSearchBarUpdatedListener(_callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription;
14
14
  registerSearchBarCancelPressedListener(_callback: (event: SearchBarCancelPressedEvent) => void): EmitterSubscription;
15
15
  registerPreviewCompletedListener(_callback: (event: PreviewCompletedEvent) => void): EmitterSubscription;
16
- registerCommandCompletedListener(_callback: (data: CommandCompletedEvent) => void): EmitterSubscription;
16
+ registerCommandCompletedListener(callback: (data: CommandCompletedEvent) => void): EmitterSubscription;
17
17
  registerBottomTabSelectedListener(_callback: (data: BottomTabSelectedEvent) => void): EmitterSubscription;
18
18
  registerBottomTabLongPressedListener(_callback: (data: BottomTabLongPressedEvent) => void): EmitterSubscription;
19
19
  registerScreenPoppedListener(_callback: (event: ScreenPoppedEvent) => void): EmitterSubscription;
@@ -79,7 +79,8 @@ class NativeEventsReceiver {
79
79
  remove: () => { },
80
80
  };
81
81
  }
82
- registerCommandCompletedListener(_callback) {
82
+ registerCommandCompletedListener(callback) {
83
+ EventsStore_1.events.commandCompleted.push(callback);
83
84
  return {
84
85
  remove: () => { },
85
86
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.31.1",
3
+ "version": "7.32.0",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,