react-native-navigation 7.30.5 → 7.30.6-snapshot.792
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/mocks/NativeCommandsSender.tsx +19 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/UiUtils.java +5 -1
- package/lib/dist/Mock/mocks/NativeCommandsSender.d.ts +3 -0
- package/lib/dist/Mock/mocks/NativeCommandsSender.js +16 -0
- package/lib/dist/src/Navigation.js +2 -2
- package/lib/dist/src/adapters/Constants.d.ts +3 -2
- package/lib/dist/src/adapters/Constants.js +5 -5
- package/lib/dist/src/adapters/NativeCommandsSender.d.ts +3 -0
- package/lib/dist/src/adapters/NativeCommandsSender.js +6 -0
- package/lib/dist/src/commands/Commands.d.ts +4 -4
- package/lib/dist/src/commands/OptionsCrawler.d.ts +1 -1
- package/lib/dist/src/processors/LayoutProcessor.d.ts +1 -1
- package/lib/src/Navigation.ts +3 -3
- package/lib/src/adapters/Constants.ts +6 -5
- package/lib/src/adapters/NativeCommandsSender.ts +11 -0
- package/lib/src/commands/Commands.ts +4 -4
- package/lib/src/commands/OptionsCrawler.ts +1 -1
- package/lib/src/processors/LayoutProcessor.ts +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { LayoutNode } from '../../src/commands/LayoutTreeCrawler';
|
|
|
4
4
|
import { events } from '../Stores/EventsStore';
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
import ComponentNode from '../Layouts/ComponentNode';
|
|
7
|
+
import { Constants } from '../../src/adapters/Constants';
|
|
7
8
|
|
|
8
9
|
export class NativeCommandsSender {
|
|
9
10
|
constructor() {}
|
|
@@ -115,4 +116,22 @@ export class NativeCommandsSender {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
getLaunchArgs(_commandId: string) {}
|
|
119
|
+
|
|
120
|
+
getNavigationConstants(): Promise<Constants> {
|
|
121
|
+
return Promise.resolve({
|
|
122
|
+
topBarHeight: 0,
|
|
123
|
+
backButtonId: 'RNN.back',
|
|
124
|
+
bottomTabsHeight: 0,
|
|
125
|
+
statusBarHeight: 0,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
getNavigationConstantsSync(): Constants {
|
|
130
|
+
return {
|
|
131
|
+
topBarHeight: 0,
|
|
132
|
+
backButtonId: 'RNN.back',
|
|
133
|
+
bottomTabsHeight: 0,
|
|
134
|
+
statusBarHeight: 0,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
118
137
|
}
|
|
@@ -81,7 +81,11 @@ public class UiUtils {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
public static void runOnMainThread(Runnable runnable) {
|
|
84
|
-
|
|
84
|
+
if (Looper.myLooper() == Looper.getMainLooper()) {
|
|
85
|
+
new Handler(Looper.getMainLooper()).postAtFrontOfQueue(runnable);
|
|
86
|
+
} else {
|
|
87
|
+
new Handler(Looper.getMainLooper()).post(runnable);
|
|
88
|
+
}
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
public static float getWindowHeight(Context context) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LayoutNode } from '../../src/commands/LayoutTreeCrawler';
|
|
2
|
+
import { Constants } from '../../src/adapters/Constants';
|
|
2
3
|
export declare class NativeCommandsSender {
|
|
3
4
|
constructor();
|
|
4
5
|
setRoot(_commandId: string, layout: {
|
|
@@ -20,4 +21,6 @@ export declare class NativeCommandsSender {
|
|
|
20
21
|
dismissOverlay(_commandId: string, componentId: string): void;
|
|
21
22
|
dismissAllOverlays(_commandId: string): void;
|
|
22
23
|
getLaunchArgs(_commandId: string): void;
|
|
24
|
+
getNavigationConstants(): Promise<Constants>;
|
|
25
|
+
getNavigationConstantsSync(): Constants;
|
|
23
26
|
}
|
|
@@ -99,5 +99,21 @@ class NativeCommandsSender {
|
|
|
99
99
|
LayoutStore_1.LayoutStore.dismissAllOverlays();
|
|
100
100
|
}
|
|
101
101
|
getLaunchArgs(_commandId) { }
|
|
102
|
+
getNavigationConstants() {
|
|
103
|
+
return Promise.resolve({
|
|
104
|
+
topBarHeight: 0,
|
|
105
|
+
backButtonId: 'RNN.back',
|
|
106
|
+
bottomTabsHeight: 0,
|
|
107
|
+
statusBarHeight: 0,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getNavigationConstantsSync() {
|
|
111
|
+
return {
|
|
112
|
+
topBarHeight: 0,
|
|
113
|
+
backButtonId: 'RNN.back',
|
|
114
|
+
bottomTabsHeight: 0,
|
|
115
|
+
statusBarHeight: 0,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
102
118
|
}
|
|
103
119
|
exports.NativeCommandsSender = NativeCommandsSender;
|
|
@@ -200,13 +200,13 @@ class NavigationRoot {
|
|
|
200
200
|
* Constants coming from native
|
|
201
201
|
*/
|
|
202
202
|
async constants() {
|
|
203
|
-
return await Constants_1.Constants.get();
|
|
203
|
+
return await Constants_1.Constants.get(this.nativeCommandsSender);
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* Constants coming from native (synchronized call)
|
|
207
207
|
*/
|
|
208
208
|
constantsSync() {
|
|
209
|
-
return Constants_1.Constants.getSync();
|
|
209
|
+
return Constants_1.Constants.getSync(this.nativeCommandsSender);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
exports.NavigationRoot = NavigationRoot;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NativeCommandsSender } from './NativeCommandsSender';
|
|
1
2
|
export interface NavigationConstants {
|
|
2
3
|
statusBarHeight: number;
|
|
3
4
|
backButtonId: string;
|
|
@@ -5,8 +6,8 @@ export interface NavigationConstants {
|
|
|
5
6
|
bottomTabsHeight: number;
|
|
6
7
|
}
|
|
7
8
|
export declare class Constants {
|
|
8
|
-
static get(): Promise<NavigationConstants>;
|
|
9
|
-
static getSync(): NavigationConstants;
|
|
9
|
+
static get(nativeCommandSender: NativeCommandsSender): Promise<NavigationConstants>;
|
|
10
|
+
static getSync(nativeCommandSender: NativeCommandsSender): NavigationConstants;
|
|
10
11
|
readonly statusBarHeight: number;
|
|
11
12
|
readonly backButtonId: string;
|
|
12
13
|
readonly topBarHeight: number;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Constants = void 0;
|
|
4
|
-
const react_native_1 = require("react-native");
|
|
5
4
|
class Constants {
|
|
6
|
-
static async get() {
|
|
7
|
-
const constants = await
|
|
5
|
+
static async get(nativeCommandSender) {
|
|
6
|
+
const constants = await nativeCommandSender.getNavigationConstants();
|
|
8
7
|
return new Constants(constants);
|
|
9
8
|
}
|
|
10
|
-
static getSync() {
|
|
11
|
-
|
|
9
|
+
static getSync(nativeCommandSender) {
|
|
10
|
+
const constants = nativeCommandSender.getNavigationConstantsSync();
|
|
11
|
+
return new Constants(constants);
|
|
12
12
|
}
|
|
13
13
|
statusBarHeight;
|
|
14
14
|
backButtonId;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NavigationConstants } from './Constants';
|
|
1
2
|
export declare class NativeCommandsSender {
|
|
2
3
|
private readonly nativeCommandsModule;
|
|
3
4
|
constructor();
|
|
@@ -20,4 +21,6 @@ export declare class NativeCommandsSender {
|
|
|
20
21
|
dismissOverlay(commandId: string, componentId: string): Promise<any>;
|
|
21
22
|
dismissAllOverlays(commandId: string): Promise<any>;
|
|
22
23
|
getLaunchArgs(commandId: string): Promise<any>;
|
|
24
|
+
getNavigationConstants(): Promise<NavigationConstants>;
|
|
25
|
+
getNavigationConstantsSync(): NavigationConstants;
|
|
23
26
|
}
|
|
@@ -52,5 +52,11 @@ class NativeCommandsSender {
|
|
|
52
52
|
getLaunchArgs(commandId) {
|
|
53
53
|
return this.nativeCommandsModule.getLaunchArgs(commandId);
|
|
54
54
|
}
|
|
55
|
+
getNavigationConstants() {
|
|
56
|
+
return this.nativeCommandsModule.getNavigationConstants();
|
|
57
|
+
}
|
|
58
|
+
getNavigationConstantsSync() {
|
|
59
|
+
return this.nativeCommandsModule.getNavigationConstantsSync();
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
exports.NativeCommandsSender = NativeCommandsSender;
|
|
@@ -24,15 +24,15 @@ export declare class Commands {
|
|
|
24
24
|
setDefaultOptions(options: Options): void;
|
|
25
25
|
mergeOptions(componentId: string, options: Options): void;
|
|
26
26
|
updateProps(componentId: string, props: object, callback?: () => void): void;
|
|
27
|
-
showModal(layout: Layout): Promise<any>;
|
|
27
|
+
showModal<P>(layout: Layout<P>): Promise<any>;
|
|
28
28
|
dismissModal(componentId: string, mergeOptions?: Options): Promise<any>;
|
|
29
29
|
dismissAllModals(mergeOptions?: Options): Promise<any>;
|
|
30
|
-
push(componentId: string, simpleApi: Layout): Promise<any>;
|
|
30
|
+
push<P>(componentId: string, simpleApi: Layout<P>): Promise<any>;
|
|
31
31
|
pop(componentId: string, mergeOptions?: Options): Promise<any>;
|
|
32
32
|
popTo(componentId: string, mergeOptions?: Options): Promise<any>;
|
|
33
33
|
popToRoot(componentId: string, mergeOptions?: Options): Promise<any>;
|
|
34
|
-
setStackRoot(componentId: string, children: Layout[]): Promise<any>;
|
|
35
|
-
showOverlay(simpleApi: Layout): Promise<any>;
|
|
34
|
+
setStackRoot<P>(componentId: string, children: Layout<P>[]): Promise<any>;
|
|
35
|
+
showOverlay<P>(simpleApi: Layout<P>): Promise<any>;
|
|
36
36
|
dismissOverlay(componentId: string): Promise<any>;
|
|
37
37
|
dismissAllOverlays(): Promise<any>;
|
|
38
38
|
getLaunchArgs(): Promise<any>;
|
|
@@ -5,7 +5,7 @@ export declare class OptionsCrawler {
|
|
|
5
5
|
readonly store: Store;
|
|
6
6
|
readonly uniqueIdProvider: UniqueIdProvider;
|
|
7
7
|
constructor(store: Store, uniqueIdProvider: UniqueIdProvider);
|
|
8
|
-
crawl(api?: Layout): void;
|
|
8
|
+
crawl(api?: Layout<any>): void;
|
|
9
9
|
private topTabs;
|
|
10
10
|
private sideMenu;
|
|
11
11
|
private bottomTabs;
|
|
@@ -4,5 +4,5 @@ import { CommandName } from '../interfaces/CommandName';
|
|
|
4
4
|
export declare class LayoutProcessor {
|
|
5
5
|
private layoutProcessorsStore;
|
|
6
6
|
constructor(layoutProcessorsStore: LayoutProcessorsStore);
|
|
7
|
-
process(layout: Layout
|
|
7
|
+
process(layout: Layout<any>, commandName: CommandName): Layout;
|
|
8
8
|
}
|
package/lib/src/Navigation.ts
CHANGED
|
@@ -248,7 +248,7 @@ export class NavigationRoot {
|
|
|
248
248
|
componentId: string,
|
|
249
249
|
layout: Layout<P> | Array<Layout<P>>
|
|
250
250
|
): Promise<string> {
|
|
251
|
-
const children: Layout[] = isArray(layout) ? layout : [layout];
|
|
251
|
+
const children: Layout<P | []>[] = isArray(layout) ? layout : [layout];
|
|
252
252
|
return this.commands.setStackRoot(componentId, children);
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -291,13 +291,13 @@ export class NavigationRoot {
|
|
|
291
291
|
* Constants coming from native
|
|
292
292
|
*/
|
|
293
293
|
public async constants(): Promise<NavigationConstants> {
|
|
294
|
-
return await Constants.get();
|
|
294
|
+
return await Constants.get(this.nativeCommandsSender);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
/**
|
|
298
298
|
* Constants coming from native (synchronized call)
|
|
299
299
|
*/
|
|
300
300
|
public constantsSync(): NavigationConstants {
|
|
301
|
-
return Constants.getSync();
|
|
301
|
+
return Constants.getSync(this.nativeCommandsSender);
|
|
302
302
|
}
|
|
303
303
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NativeCommandsSender } from './NativeCommandsSender';
|
|
2
2
|
|
|
3
3
|
export interface NavigationConstants {
|
|
4
4
|
statusBarHeight: number;
|
|
@@ -8,13 +8,14 @@ export interface NavigationConstants {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export class Constants {
|
|
11
|
-
static async get(): Promise<NavigationConstants> {
|
|
12
|
-
const constants: NavigationConstants = await
|
|
11
|
+
static async get(nativeCommandSender: NativeCommandsSender): Promise<NavigationConstants> {
|
|
12
|
+
const constants: NavigationConstants = await nativeCommandSender.getNavigationConstants();
|
|
13
13
|
return new Constants(constants);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
static getSync(): NavigationConstants {
|
|
17
|
-
|
|
16
|
+
static getSync(nativeCommandSender: NativeCommandsSender): NavigationConstants {
|
|
17
|
+
const constants: NavigationConstants = nativeCommandSender.getNavigationConstantsSync();
|
|
18
|
+
return new Constants(constants);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
public readonly statusBarHeight: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NativeModules } from 'react-native';
|
|
2
|
+
import { NavigationConstants } from './Constants';
|
|
2
3
|
|
|
3
4
|
interface NativeCommandsModule {
|
|
4
5
|
setRoot(commandId: string, layout: { root: any; modals: any[]; overlays: any[] }): Promise<any>;
|
|
@@ -16,6 +17,8 @@ interface NativeCommandsModule {
|
|
|
16
17
|
dismissOverlay(commandId: string, componentId: string): Promise<any>;
|
|
17
18
|
dismissAllOverlays(commandId: string): Promise<any>;
|
|
18
19
|
getLaunchArgs(commandId: string): Promise<any>;
|
|
20
|
+
getNavigationConstants(): Promise<NavigationConstants>;
|
|
21
|
+
getNavigationConstantsSync(): NavigationConstants;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export class NativeCommandsSender {
|
|
@@ -83,4 +86,12 @@ export class NativeCommandsSender {
|
|
|
83
86
|
getLaunchArgs(commandId: string) {
|
|
84
87
|
return this.nativeCommandsModule.getLaunchArgs(commandId);
|
|
85
88
|
}
|
|
89
|
+
|
|
90
|
+
getNavigationConstants() {
|
|
91
|
+
return this.nativeCommandsModule.getNavigationConstants();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getNavigationConstantsSync() {
|
|
95
|
+
return this.nativeCommandsModule.getNavigationConstantsSync();
|
|
96
|
+
}
|
|
86
97
|
}
|
|
@@ -91,7 +91,7 @@ export class Commands {
|
|
|
91
91
|
this.commandsObserver.notify(CommandName.UpdateProps, { componentId, props });
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
public showModal(layout: Layout) {
|
|
94
|
+
public showModal<P>(layout: Layout<P>) {
|
|
95
95
|
const layoutCloned = cloneLayout(layout);
|
|
96
96
|
this.optionsCrawler.crawl(layoutCloned);
|
|
97
97
|
const layoutProcessed = this.layoutProcessor.process(layoutCloned, CommandName.ShowModal);
|
|
@@ -125,7 +125,7 @@ export class Commands {
|
|
|
125
125
|
return result;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
public push(componentId: string, simpleApi: Layout) {
|
|
128
|
+
public push<P>(componentId: string, simpleApi: Layout<P>) {
|
|
129
129
|
const input = cloneLayout(simpleApi);
|
|
130
130
|
this.optionsCrawler.crawl(input);
|
|
131
131
|
const layoutProcessed = this.layoutProcessor.process(input, CommandName.Push);
|
|
@@ -163,7 +163,7 @@ export class Commands {
|
|
|
163
163
|
return result;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
public setStackRoot(componentId: string, children: Layout[]) {
|
|
166
|
+
public setStackRoot<P>(componentId: string, children: Layout<P>[]) {
|
|
167
167
|
const input = map(cloneLayout(children), (simpleApi) => {
|
|
168
168
|
this.optionsCrawler.crawl(simpleApi);
|
|
169
169
|
const layoutProcessed = this.layoutProcessor.process(simpleApi, CommandName.SetStackRoot);
|
|
@@ -185,7 +185,7 @@ export class Commands {
|
|
|
185
185
|
return result;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
public showOverlay(simpleApi: Layout) {
|
|
188
|
+
public showOverlay<P>(simpleApi: Layout<P>) {
|
|
189
189
|
const input = cloneLayout(simpleApi);
|
|
190
190
|
this.optionsCrawler.crawl(input);
|
|
191
191
|
const layoutProcessed = this.layoutProcessor.process(input, CommandName.ShowOverlay);
|
|
@@ -6,7 +6,7 @@ import { CommandName } from '../interfaces/CommandName';
|
|
|
6
6
|
export class LayoutProcessor {
|
|
7
7
|
constructor(private layoutProcessorsStore: LayoutProcessorsStore) {}
|
|
8
8
|
|
|
9
|
-
public process(layout: Layout
|
|
9
|
+
public process(layout: Layout<any>, commandName: CommandName): Layout {
|
|
10
10
|
const processors: ILayoutProcessor[] = this.layoutProcessorsStore.getProcessors();
|
|
11
11
|
processors.forEach((processor) => {
|
|
12
12
|
layout = processor(layout, commandName);
|