hybrid-navigation 2.18.1 → 2.18.3
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/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +7 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +3 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +11 -1
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +4 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +3 -1
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.h +1 -0
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.m +1 -0
- package/lib/Navigation.d.ts +1 -1
- package/lib/Navigation.js +7 -2
- package/lib/NavigationModule.d.ts +1 -0
- package/lib/Navigator.js +7 -7
- package/lib/Route.d.ts +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/Navigation.ts +9 -2
- package/src/NavigationModule.ts +1 -0
- package/src/Navigator.ts +7 -7
- package/src/Route.ts +1 -0
- package/src/index.ts +1 -1
|
@@ -20,6 +20,7 @@ import com.navigation.androidx.AwesomeFragment;
|
|
|
20
20
|
import com.navigation.androidx.AwesomeToolbar;
|
|
21
21
|
import com.navigation.androidx.BarStyle;
|
|
22
22
|
import com.navigation.androidx.FragmentHelper;
|
|
23
|
+
import com.navigation.androidx.PresentableActivity;
|
|
23
24
|
import com.navigation.androidx.PresentationStyle;
|
|
24
25
|
import com.navigation.androidx.Style;
|
|
25
26
|
import com.navigation.androidx.SystemUI;
|
|
@@ -309,5 +310,10 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
309
310
|
Bundle args = FragmentHelper.getArguments(this);
|
|
310
311
|
return args.getString(ARG_MODULE_NAME);
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
+
|
|
314
|
+
public String getPresentingSceneId() {
|
|
315
|
+
Bundle args = FragmentHelper.getArguments(this);
|
|
316
|
+
return args.getString(PresentableActivity.ARG_PRESENTING_SCENE_ID);
|
|
317
|
+
}
|
|
318
|
+
|
|
313
319
|
}
|
|
@@ -66,6 +66,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
66
66
|
HashMap<String, Object> constants = new HashMap<>();
|
|
67
67
|
constants.put("RESULT_OK", Activity.RESULT_OK);
|
|
68
68
|
constants.put("RESULT_CANCEL", Activity.RESULT_CANCELED);
|
|
69
|
+
constants.put("RESULT_BLOCK", -2);
|
|
69
70
|
return constants;
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -300,6 +301,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
300
301
|
bundle.putString("moduleName", current.getModuleName());
|
|
301
302
|
bundle.putString("sceneId", current.getSceneId());
|
|
302
303
|
bundle.putString("mode", Navigator.Util.getMode(current));
|
|
304
|
+
bundle.putString("presentingId", current.getPresentingSceneId());
|
|
303
305
|
bundle.putInt("requestCode", current.getRequestCode());
|
|
304
306
|
callback.invoke(null, Arguments.fromBundle(bundle));
|
|
305
307
|
});
|
|
@@ -323,7 +325,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
323
325
|
activity.scheduleTaskAtStarted(() -> {
|
|
324
326
|
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
325
327
|
ArrayList<Bundle> graph = bridgeManager.buildRouteGraph(fragmentManager);
|
|
326
|
-
if (graph.
|
|
328
|
+
if (graph.isEmpty()) {
|
|
327
329
|
UiThreadUtil.runOnUiThread(this, 16);
|
|
328
330
|
return;
|
|
329
331
|
}
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java
CHANGED
|
@@ -10,6 +10,7 @@ import com.facebook.react.bridge.Callback;
|
|
|
10
10
|
import com.facebook.react.bridge.ReadableMap;
|
|
11
11
|
import com.navigation.androidx.AwesomeFragment;
|
|
12
12
|
import com.navigation.androidx.FragmentHelper;
|
|
13
|
+
import com.navigation.androidx.PresentableActivity;
|
|
13
14
|
import com.navigation.androidx.PresentationStyle;
|
|
14
15
|
import com.navigation.androidx.TransitionAnimation;
|
|
15
16
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
@@ -161,9 +162,13 @@ public class ScreenNavigator implements Navigator {
|
|
|
161
162
|
callback.invoke(null, false);
|
|
162
163
|
return;
|
|
163
164
|
}
|
|
165
|
+
|
|
166
|
+
Bundle args = FragmentHelper.getArguments(presented);
|
|
167
|
+
args.putString(PresentableActivity.ARG_PRESENTING_SCENE_ID, presenting.getSceneId());
|
|
168
|
+
presented.setArguments(args);
|
|
164
169
|
presented.setPresentationStyle(PresentationStyle.OverFullScreen);
|
|
170
|
+
|
|
165
171
|
int requestCode = extras.getInt("requestCode");
|
|
166
|
-
|
|
167
172
|
presenting.presentFragment(presented, requestCode, () -> callback.invoke(null, true), TransitionAnimation.None);
|
|
168
173
|
}
|
|
169
174
|
|
|
@@ -187,6 +192,11 @@ public class ScreenNavigator implements Navigator {
|
|
|
187
192
|
callback.invoke(null, false);
|
|
188
193
|
return;
|
|
189
194
|
}
|
|
195
|
+
|
|
196
|
+
Bundle args = FragmentHelper.getArguments(presented);
|
|
197
|
+
args.putString(PresentableActivity.ARG_PRESENTING_SCENE_ID, presenting.getSceneId());
|
|
198
|
+
presented.setArguments(args);
|
|
199
|
+
|
|
190
200
|
int requestCode = extras.getInt("requestCode");
|
|
191
201
|
ReactStackFragment stackFragment = new ReactStackFragment();
|
|
192
202
|
stackFragment.setRootFragment(presented);
|
|
@@ -93,6 +93,9 @@
|
|
|
93
93
|
HBDNavigationController *nav = [[HBDNavigationController alloc] initWithRootViewController:vc];
|
|
94
94
|
nav.modalPresentationStyle = UIModalPresentationCurrentContext;
|
|
95
95
|
[nav setRequestCode:requestCode];
|
|
96
|
+
[vc setRequestCode:requestCode];
|
|
97
|
+
[vc setPresentingSceneId:presenting.sceneId];
|
|
98
|
+
|
|
96
99
|
[[HBDAnimationObserver sharedObserver] beginAnimation];
|
|
97
100
|
[presenting presentViewController:nav animated:YES completion:^{
|
|
98
101
|
callback(@[NSNull.null, @YES]);
|
|
@@ -116,6 +119,7 @@
|
|
|
116
119
|
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
117
120
|
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
118
121
|
[vc setRequestCode:requestCode];
|
|
122
|
+
|
|
119
123
|
[[HBDAnimationObserver sharedObserver] beginAnimation];
|
|
120
124
|
[presenting presentViewController:vc animated:YES completion:^{
|
|
121
125
|
callback(@[NSNull.null, @YES]);
|
|
@@ -41,7 +41,8 @@ RCT_EXPORT_MODULE(NavigationModule)
|
|
|
41
41
|
- (NSDictionary *)constantsToExport {
|
|
42
42
|
return @{
|
|
43
43
|
@"RESULT_OK": @(ResultOK),
|
|
44
|
-
@"RESULT_CANCEL": @(ResultCancel)
|
|
44
|
+
@"RESULT_CANCEL": @(ResultCancel),
|
|
45
|
+
@"RESULT_BLOCK": @(ResultBlock)
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -219,6 +220,7 @@ RCT_EXPORT_METHOD(currentRoute:(RCTResponseSenderBlock)callback) {
|
|
|
219
220
|
callback(@[[NSNull null], @{
|
|
220
221
|
@"moduleName": RCTNullIfNil(current.moduleName),
|
|
221
222
|
@"sceneId": current.sceneId,
|
|
223
|
+
@"presentingId": RCTNullIfNil(current.presentingSceneId),
|
|
222
224
|
@"mode": [current hbd_mode],
|
|
223
225
|
@"requestCode": @(current.requestCode),
|
|
224
226
|
}]);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
NSString *const ReactModuleRegistryDidCompletedNotification = @"ReactModuleRegistryDidCompletedNotification";
|
|
11
11
|
const NSInteger ResultOK = -1;
|
|
12
12
|
const NSInteger ResultCancel = 0;
|
|
13
|
+
const NSInteger ResultBlock = -2;
|
|
13
14
|
|
|
14
15
|
@interface HBDReactBridgeManager ()
|
|
15
16
|
|
package/lib/Navigation.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type BarButtonClickEventListener = (sceneId: string, value: Function) => void;
|
|
|
11
11
|
type Nullable<T> = {
|
|
12
12
|
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P];
|
|
13
13
|
};
|
|
14
|
-
export declare const RESULT_CANCEL: number, RESULT_OK: number;
|
|
14
|
+
export declare const RESULT_CANCEL: number, RESULT_OK: number, RESULT_BLOCK: number;
|
|
15
15
|
export type NavigationSubscription = {
|
|
16
16
|
remove: () => void;
|
|
17
17
|
};
|
package/lib/Navigation.js
CHANGED
|
@@ -7,7 +7,7 @@ import VisibilityEventHandler from './handler/VisibilityEventHandler';
|
|
|
7
7
|
import Event from './Event';
|
|
8
8
|
import GardenModule from './GardenModule';
|
|
9
9
|
import NavigationModule from './NavigationModule';
|
|
10
|
-
export const { RESULT_CANCEL, RESULT_OK } = NavigationModule.getConstants();
|
|
10
|
+
export const { RESULT_CANCEL, RESULT_OK, RESULT_BLOCK } = NavigationModule.getConstants();
|
|
11
11
|
class NavigationImpl {
|
|
12
12
|
dispatchHandler = new DispatchCommandHandler();
|
|
13
13
|
resultHandler = new ResultEventHandler();
|
|
@@ -83,7 +83,12 @@ class NavigationImpl {
|
|
|
83
83
|
setInterceptor(interceptor) {
|
|
84
84
|
this.dispatchHandler.setInterceptor(interceptor);
|
|
85
85
|
}
|
|
86
|
-
setResult = (sceneId, resultCode, data = null) =>
|
|
86
|
+
setResult = (sceneId, resultCode, data = null) => {
|
|
87
|
+
if (resultCode < RESULT_OK) {
|
|
88
|
+
console.warn('`resultCode` can only be `RESULT_OK`, `RESULT_CANCEL` or an integer greater than 0.');
|
|
89
|
+
}
|
|
90
|
+
NavigationModule.setResult(sceneId, resultCode, data);
|
|
91
|
+
};
|
|
87
92
|
result(sceneId, resultCode) {
|
|
88
93
|
return this.resultHandler.waitResult(sceneId, resultCode);
|
|
89
94
|
}
|
package/lib/Navigator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
import store from './store';
|
|
3
|
-
import Navigation, {
|
|
3
|
+
import Navigation, { RESULT_BLOCK } from './Navigation';
|
|
4
4
|
export const NavigationContext = createContext(null);
|
|
5
5
|
let tagGenerator = 0;
|
|
6
6
|
Navigation.addGlobalVisibilityEventListener((sceneId, visibility) => {
|
|
@@ -58,7 +58,7 @@ export class Navigator {
|
|
|
58
58
|
options,
|
|
59
59
|
});
|
|
60
60
|
if (!success) {
|
|
61
|
-
return [
|
|
61
|
+
return [RESULT_BLOCK, null];
|
|
62
62
|
}
|
|
63
63
|
return Navigation.result(this.sceneId, 0);
|
|
64
64
|
};
|
|
@@ -68,7 +68,7 @@ export class Navigator {
|
|
|
68
68
|
layout,
|
|
69
69
|
});
|
|
70
70
|
if (!success) {
|
|
71
|
-
return [
|
|
71
|
+
return [RESULT_BLOCK, null];
|
|
72
72
|
}
|
|
73
73
|
return Navigation.result(this.sceneId, 0);
|
|
74
74
|
};
|
|
@@ -94,7 +94,7 @@ export class Navigator {
|
|
|
94
94
|
});
|
|
95
95
|
if (!success) {
|
|
96
96
|
console.warn(`present from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
97
|
-
return [
|
|
97
|
+
return [RESULT_BLOCK, null];
|
|
98
98
|
}
|
|
99
99
|
return Navigation.result(this.sceneId, requestCode);
|
|
100
100
|
};
|
|
@@ -107,7 +107,7 @@ export class Navigator {
|
|
|
107
107
|
});
|
|
108
108
|
if (!success) {
|
|
109
109
|
console.warn(`presentLayout from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
110
|
-
return [
|
|
110
|
+
return [RESULT_BLOCK, null];
|
|
111
111
|
}
|
|
112
112
|
return Navigation.result(this.sceneId, requestCode);
|
|
113
113
|
};
|
|
@@ -124,7 +124,7 @@ export class Navigator {
|
|
|
124
124
|
});
|
|
125
125
|
if (!success) {
|
|
126
126
|
console.warn(`showModal from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
127
|
-
return [
|
|
127
|
+
return [RESULT_BLOCK, null];
|
|
128
128
|
}
|
|
129
129
|
return Navigation.result(this.sceneId, requestCode);
|
|
130
130
|
};
|
|
@@ -137,7 +137,7 @@ export class Navigator {
|
|
|
137
137
|
});
|
|
138
138
|
if (!success) {
|
|
139
139
|
console.warn(`showModal from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
140
|
-
return [
|
|
140
|
+
return [RESULT_BLOCK, null];
|
|
141
141
|
}
|
|
142
142
|
return Navigation.result(this.sceneId, requestCode);
|
|
143
143
|
};
|
package/lib/Route.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const Navigation: import("./Navigation").Navigation;
|
|
2
2
|
export default Navigation;
|
|
3
|
-
export { RESULT_OK, RESULT_CANCEL } from './Navigation';
|
|
3
|
+
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation';
|
|
4
4
|
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule';
|
|
5
5
|
export { withNavigationItem } from './NavigationComponentWrap';
|
|
6
6
|
export type { NavigationProps } from './NavigationComponentWrap';
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import navigation from './Navigation';
|
|
|
3
3
|
navigation.setNavigationComponentWrap(withNavigation);
|
|
4
4
|
const Navigation = navigation;
|
|
5
5
|
export default Navigation;
|
|
6
|
-
export { RESULT_OK, RESULT_CANCEL } from './Navigation';
|
|
6
|
+
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation';
|
|
7
7
|
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule';
|
|
8
8
|
export { withNavigationItem } from './NavigationComponentWrap';
|
|
9
9
|
export * from './Navigator';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hybrid-navigation",
|
|
3
3
|
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
-
"version": "2.18.
|
|
4
|
+
"version": "2.18.3",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
package/src/Navigation.ts
CHANGED
|
@@ -34,7 +34,7 @@ type Nullable<T> = {
|
|
|
34
34
|
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P]
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export const { RESULT_CANCEL, RESULT_OK } = NavigationModule.getConstants()
|
|
37
|
+
export const { RESULT_CANCEL, RESULT_OK, RESULT_BLOCK } = NavigationModule.getConstants()
|
|
38
38
|
|
|
39
39
|
export type NavigationSubscription = {
|
|
40
40
|
remove: () => void
|
|
@@ -191,7 +191,14 @@ class NavigationImpl implements Navigation {
|
|
|
191
191
|
sceneId: string,
|
|
192
192
|
resultCode: number,
|
|
193
193
|
data: T = null as T,
|
|
194
|
-
): void =>
|
|
194
|
+
): void => {
|
|
195
|
+
if (resultCode < RESULT_OK) {
|
|
196
|
+
console.warn(
|
|
197
|
+
'`resultCode` can only be `RESULT_OK`, `RESULT_CANCEL` or an integer greater than 0.',
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
NavigationModule.setResult(sceneId, resultCode, data)
|
|
201
|
+
}
|
|
195
202
|
|
|
196
203
|
result<T extends ResultType>(sceneId: string, resultCode: number) {
|
|
197
204
|
return this.resultHandler.waitResult<T>(sceneId, resultCode)
|
package/src/NavigationModule.ts
CHANGED
package/src/Navigator.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createContext } from 'react'
|
|
|
3
3
|
import store from './store'
|
|
4
4
|
import type { Visibility, Layout, BuildInLayout } from './Route'
|
|
5
5
|
import type { NavigationItem } from './Options'
|
|
6
|
-
import Navigation, { ResultType,
|
|
6
|
+
import Navigation, { ResultType, RESULT_BLOCK } from './Navigation'
|
|
7
7
|
|
|
8
8
|
export const NavigationContext = createContext<any>(null)
|
|
9
9
|
|
|
@@ -83,7 +83,7 @@ export class Navigator implements Navigator {
|
|
|
83
83
|
options,
|
|
84
84
|
})
|
|
85
85
|
if (!success) {
|
|
86
|
-
return [
|
|
86
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
87
87
|
}
|
|
88
88
|
return Navigation.result<T>(this.sceneId, 0)
|
|
89
89
|
}
|
|
@@ -94,7 +94,7 @@ export class Navigator implements Navigator {
|
|
|
94
94
|
layout,
|
|
95
95
|
})
|
|
96
96
|
if (!success) {
|
|
97
|
-
return [
|
|
97
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
98
98
|
}
|
|
99
99
|
return Navigation.result<T>(this.sceneId, 0)
|
|
100
100
|
}
|
|
@@ -137,7 +137,7 @@ export class Navigator implements Navigator {
|
|
|
137
137
|
console.warn(
|
|
138
138
|
`present from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
139
139
|
)
|
|
140
|
-
return [
|
|
140
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
141
141
|
}
|
|
142
142
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
143
143
|
}
|
|
@@ -153,7 +153,7 @@ export class Navigator implements Navigator {
|
|
|
153
153
|
console.warn(
|
|
154
154
|
`presentLayout from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
155
155
|
)
|
|
156
|
-
return [
|
|
156
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
157
157
|
}
|
|
158
158
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
159
159
|
}
|
|
@@ -178,7 +178,7 @@ export class Navigator implements Navigator {
|
|
|
178
178
|
console.warn(
|
|
179
179
|
`showModal from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
180
180
|
)
|
|
181
|
-
return [
|
|
181
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
182
182
|
}
|
|
183
183
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
184
184
|
}
|
|
@@ -194,7 +194,7 @@ export class Navigator implements Navigator {
|
|
|
194
194
|
console.warn(
|
|
195
195
|
`showModal from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
196
196
|
)
|
|
197
|
-
return [
|
|
197
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
198
198
|
}
|
|
199
199
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
200
200
|
}
|
package/src/Route.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import navigation from './Navigation'
|
|
|
3
3
|
navigation.setNavigationComponentWrap(withNavigation)
|
|
4
4
|
const Navigation = navigation
|
|
5
5
|
export default Navigation
|
|
6
|
-
export { RESULT_OK, RESULT_CANCEL } from './Navigation'
|
|
6
|
+
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation'
|
|
7
7
|
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule'
|
|
8
8
|
export { withNavigationItem } from './NavigationComponentWrap'
|
|
9
9
|
export type { NavigationProps } from './NavigationComponentWrap'
|