hybrid-navigation 2.13.7 → 2.13.9
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/local.properties +8 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +31 -47
- package/lib/Navigator.js +6 -6
- package/package.json +1 -1
- package/src/Navigator.ts +6 -6
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
## This file must *NOT* be checked into Version Control Systems,
|
|
2
|
+
# as it contains information specific to your local configuration.
|
|
3
|
+
#
|
|
4
|
+
# Location of the SDK. This is only used by Gradle.
|
|
5
|
+
# For customization when using a Version Control System, please read the
|
|
6
|
+
# header note.
|
|
7
|
+
#Tue Sep 06 15:08:32 CST 2022
|
|
8
|
+
sdk.dir=/Users/listen/Library/Android/sdk
|
|
@@ -34,6 +34,11 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
34
34
|
|
|
35
35
|
private Garden garden;
|
|
36
36
|
|
|
37
|
+
@NonNull
|
|
38
|
+
public ReactBridgeManager getReactBridgeManager() {
|
|
39
|
+
return bridgeManager;
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
@NonNull
|
|
38
43
|
public ReactNativeHost getReactNativeHost() {
|
|
39
44
|
return bridgeManager.getReactNativeHost();
|
|
@@ -43,12 +48,7 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
43
48
|
public ReactInstanceManager getReactInstanceManager() {
|
|
44
49
|
return bridgeManager.getReactInstanceManager();
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
@NonNull
|
|
48
|
-
public ReactBridgeManager getReactBridgeManager() {
|
|
49
|
-
return bridgeManager;
|
|
50
|
-
}
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
@Nullable
|
|
53
53
|
public ReactContext getCurrentReactContext() {
|
|
54
54
|
return bridgeManager.getCurrentReactContext();
|
|
@@ -5,9 +5,10 @@ import android.os.Bundle;
|
|
|
5
5
|
import android.view.KeyEvent;
|
|
6
6
|
|
|
7
7
|
import androidx.annotation.NonNull;
|
|
8
|
-
import androidx.
|
|
8
|
+
import androidx.fragment.app.Fragment;
|
|
9
9
|
|
|
10
10
|
import com.facebook.common.logging.FLog;
|
|
11
|
+
import com.facebook.infer.annotation.Assertions;
|
|
11
12
|
import com.facebook.react.ReactInstanceManager;
|
|
12
13
|
import com.facebook.react.ReactNativeHost;
|
|
13
14
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -39,37 +40,31 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
39
40
|
protected void onCreate(Bundle savedInstanceState) {
|
|
40
41
|
super.onCreate(savedInstanceState);
|
|
41
42
|
activityDelegate.onCreate(savedInstanceState);
|
|
42
|
-
getReactBridgeManager()
|
|
43
|
-
|
|
43
|
+
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
44
|
+
bridgeManager.addReactModuleRegisterListener(this);
|
|
45
|
+
ensureViewHierarchy(bridgeManager, savedInstanceState);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
private void ensureViewHierarchy(Bundle savedInstanceState) {
|
|
48
|
+
private void ensureViewHierarchy(ReactBridgeManager bridgeManager, Bundle savedInstanceState) {
|
|
47
49
|
if (!isReactModuleRegisterCompleted()) {
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (savedInstanceState == null) {
|
|
52
|
-
|
|
54
|
+
onReactModuleRegisterCompleted();
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
|
|
59
|
+
if (fragment instanceof AwesomeFragment) {
|
|
60
|
+
bridgeManager.setViewHierarchyReady(true);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
private boolean styleInflated;
|
|
62
|
-
|
|
63
|
-
@Override
|
|
64
|
-
protected void onCustomStyle(@NonNull Style style) {
|
|
65
|
-
inflateStyle();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
64
|
public void inflateStyle() {
|
|
69
65
|
Style style = getStyle();
|
|
70
66
|
GlobalStyle globalStyle = Garden.getGlobalStyle();
|
|
71
67
|
if (style != null && !isFinishing()) {
|
|
72
|
-
styleInflated = true;
|
|
73
68
|
FLog.i(TAG, "ReactAppCompatActivity#inflateStyle");
|
|
74
69
|
globalStyle.inflateStyle(this, style);
|
|
75
70
|
}
|
|
@@ -85,10 +80,11 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
85
80
|
@Override
|
|
86
81
|
public void onReactModuleRegisterCompleted() {
|
|
87
82
|
FLog.i(TAG, "ReactAppCompatActivity#onReactModuleRegisterCompleted");
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
ReactContext reactContext = Assertions.assertNotNull(getCurrentReactContext());
|
|
84
|
+
if (isResumed && reactContext.getCurrentActivity() == null) {
|
|
90
85
|
activityDelegate.onResume();
|
|
91
86
|
}
|
|
87
|
+
inflateStyle();
|
|
92
88
|
createMainComponent();
|
|
93
89
|
}
|
|
94
90
|
|
|
@@ -140,17 +136,6 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
140
136
|
setActivityRootFragment(fragment);
|
|
141
137
|
}
|
|
142
138
|
|
|
143
|
-
@Override
|
|
144
|
-
public void setActivityRootFragment(@NonNull AwesomeFragment rootFragment) {
|
|
145
|
-
if (!styleInflated) {
|
|
146
|
-
inflateStyle();
|
|
147
|
-
if (!styleInflated) {
|
|
148
|
-
throw new IllegalStateException("Style hasn't inflated yet. Did you forgot to call `Navigation.setDefaultOptions` before `Navigation.setRoot` ?");
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
super.setActivityRootFragment(rootFragment);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
139
|
@Override
|
|
155
140
|
protected void setActivityRootFragmentSync(AwesomeFragment fragment) {
|
|
156
141
|
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
@@ -165,25 +150,16 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
165
150
|
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_DID_SET_ROOT, Arguments.createMap());
|
|
166
151
|
}
|
|
167
152
|
|
|
168
|
-
|
|
169
|
-
protected void onPause() {
|
|
170
|
-
ReactContext reactContext = getCurrentReactContext();
|
|
171
|
-
if (reactContext != null) {
|
|
172
|
-
activityDelegate.onPause();
|
|
173
|
-
}
|
|
174
|
-
super.onPause();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
private boolean isFirstCallResume;
|
|
153
|
+
boolean isResumed = false;
|
|
178
154
|
|
|
179
155
|
@Override
|
|
180
156
|
protected void onResume() {
|
|
181
157
|
super.onResume();
|
|
182
|
-
|
|
183
|
-
|
|
158
|
+
isResumed = true;
|
|
159
|
+
if (getCurrentReactContext() != null) {
|
|
184
160
|
activityDelegate.onResume();
|
|
185
161
|
}
|
|
186
|
-
|
|
162
|
+
|
|
187
163
|
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
188
164
|
if (bridgeManager.hasPendingLayout()) {
|
|
189
165
|
FLog.i(TAG, "Set root Fragment from pending layout when resume.");
|
|
@@ -191,6 +167,15 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
191
167
|
}
|
|
192
168
|
}
|
|
193
169
|
|
|
170
|
+
@Override
|
|
171
|
+
protected void onPause() {
|
|
172
|
+
isResumed = false;
|
|
173
|
+
if (getCurrentReactContext() != null) {
|
|
174
|
+
activityDelegate.onPause();
|
|
175
|
+
}
|
|
176
|
+
super.onPause();
|
|
177
|
+
}
|
|
178
|
+
|
|
194
179
|
@Override
|
|
195
180
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
196
181
|
activityDelegate.onActivityResult(requestCode, resultCode, data);
|
|
@@ -247,7 +232,11 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
247
232
|
}
|
|
248
233
|
|
|
249
234
|
protected final ReactInstanceManager getReactInstanceManager() {
|
|
250
|
-
return
|
|
235
|
+
return getReactNativeHost().getReactInstanceManager();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public ReactContext getCurrentReactContext() {
|
|
239
|
+
return getReactInstanceManager().getCurrentReactContext();
|
|
251
240
|
}
|
|
252
241
|
|
|
253
242
|
@NonNull
|
|
@@ -258,9 +247,4 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
258
247
|
protected boolean isReactModuleRegisterCompleted() {
|
|
259
248
|
return getReactBridgeManager().isReactModuleRegisterCompleted();
|
|
260
249
|
}
|
|
261
|
-
|
|
262
|
-
@Nullable
|
|
263
|
-
public ReactContext getCurrentReactContext() {
|
|
264
|
-
return getReactBridgeManager().getCurrentReactContext();
|
|
265
|
-
}
|
|
266
250
|
}
|
package/lib/Navigator.js
CHANGED
|
@@ -118,7 +118,7 @@ export class Navigator {
|
|
|
118
118
|
if (!success) {
|
|
119
119
|
return [RESULT_CANCEL, null];
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return Navigation.result(this.sceneId, 0);
|
|
122
122
|
};
|
|
123
123
|
pushLayout = async (layout) => {
|
|
124
124
|
const success = await Navigation.dispatch(this.sceneId, 'pushLayout', {
|
|
@@ -128,7 +128,7 @@ export class Navigator {
|
|
|
128
128
|
if (!success) {
|
|
129
129
|
return [RESULT_CANCEL, null];
|
|
130
130
|
}
|
|
131
|
-
return
|
|
131
|
+
return Navigation.result(this.sceneId, 0);
|
|
132
132
|
};
|
|
133
133
|
pop = () => Navigation.dispatch(this.sceneId, 'pop', { from: this.moduleName });
|
|
134
134
|
popTo = (moduleName, inclusive = false) => Navigation.dispatch(this.sceneId, 'popTo', { moduleName, inclusive, from: this.moduleName });
|
|
@@ -153,7 +153,7 @@ export class Navigator {
|
|
|
153
153
|
if (!success) {
|
|
154
154
|
return [RESULT_CANCEL, null];
|
|
155
155
|
}
|
|
156
|
-
return
|
|
156
|
+
return Navigation.result(this.sceneId, requestCode);
|
|
157
157
|
};
|
|
158
158
|
presentLayout = async (layout) => {
|
|
159
159
|
const requestCode = --tagGenerator;
|
|
@@ -165,7 +165,7 @@ export class Navigator {
|
|
|
165
165
|
if (!success) {
|
|
166
166
|
return [RESULT_CANCEL, null];
|
|
167
167
|
}
|
|
168
|
-
return
|
|
168
|
+
return Navigation.result(this.sceneId, requestCode);
|
|
169
169
|
};
|
|
170
170
|
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss', { from: this.moduleName });
|
|
171
171
|
showModal = async (moduleName, props = {}, options = {}) => {
|
|
@@ -181,7 +181,7 @@ export class Navigator {
|
|
|
181
181
|
if (!success) {
|
|
182
182
|
return [RESULT_CANCEL, null];
|
|
183
183
|
}
|
|
184
|
-
return
|
|
184
|
+
return Navigation.result(this.sceneId, requestCode);
|
|
185
185
|
};
|
|
186
186
|
showModalLayout = async (layout) => {
|
|
187
187
|
const requestCode = --tagGenerator;
|
|
@@ -193,7 +193,7 @@ export class Navigator {
|
|
|
193
193
|
if (!success) {
|
|
194
194
|
return [RESULT_CANCEL, null];
|
|
195
195
|
}
|
|
196
|
-
return
|
|
196
|
+
return Navigation.result(this.sceneId, requestCode);
|
|
197
197
|
};
|
|
198
198
|
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal', { from: this.moduleName });
|
|
199
199
|
setResult = (resultCode, data = null) => Navigation.setResult(this.sceneId, resultCode, data);
|
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.13.
|
|
4
|
+
"version": "2.13.9",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
package/src/Navigator.ts
CHANGED
|
@@ -160,7 +160,7 @@ export class Navigator implements Navigator {
|
|
|
160
160
|
if (!success) {
|
|
161
161
|
return [RESULT_CANCEL, null] as [number, T]
|
|
162
162
|
}
|
|
163
|
-
return
|
|
163
|
+
return Navigation.result<T>(this.sceneId, 0)
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
pushLayout = async <T extends ResultType>(layout: BuildInLayout | Layout) => {
|
|
@@ -171,7 +171,7 @@ export class Navigator implements Navigator {
|
|
|
171
171
|
if (!success) {
|
|
172
172
|
return [RESULT_CANCEL, null] as [number, T]
|
|
173
173
|
}
|
|
174
|
-
return
|
|
174
|
+
return Navigation.result<T>(this.sceneId, 0)
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
pop = () => Navigation.dispatch(this.sceneId, 'pop', { from: this.moduleName })
|
|
@@ -211,7 +211,7 @@ export class Navigator implements Navigator {
|
|
|
211
211
|
if (!success) {
|
|
212
212
|
return [RESULT_CANCEL, null] as [number, T]
|
|
213
213
|
}
|
|
214
|
-
return
|
|
214
|
+
return Navigation.result<T>(this.sceneId, requestCode)
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
presentLayout = async <T extends ResultType>(layout: BuildInLayout | Layout) => {
|
|
@@ -224,7 +224,7 @@ export class Navigator implements Navigator {
|
|
|
224
224
|
if (!success) {
|
|
225
225
|
return [RESULT_CANCEL, null] as [number, T]
|
|
226
226
|
}
|
|
227
|
-
return
|
|
227
|
+
return Navigation.result<T>(this.sceneId, requestCode)
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss', { from: this.moduleName })
|
|
@@ -246,7 +246,7 @@ export class Navigator implements Navigator {
|
|
|
246
246
|
if (!success) {
|
|
247
247
|
return [RESULT_CANCEL, null] as [number, T]
|
|
248
248
|
}
|
|
249
|
-
return
|
|
249
|
+
return Navigation.result<T>(this.sceneId, requestCode)
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
showModalLayout = async <T extends ResultType>(layout: BuildInLayout | Layout) => {
|
|
@@ -259,7 +259,7 @@ export class Navigator implements Navigator {
|
|
|
259
259
|
if (!success) {
|
|
260
260
|
return [RESULT_CANCEL, null] as [number, T]
|
|
261
261
|
}
|
|
262
|
-
return
|
|
262
|
+
return Navigation.result<T>(this.sceneId, requestCode)
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal', { from: this.moduleName })
|