hybrid-navigation 2.15.3 → 2.15.5
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/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +6 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +6 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +3 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +32 -8
- package/lib/Navigator.js +4 -0
- package/lib/Options.d.ts +1 -0
- package/package.json +1 -1
- package/src/Navigator.ts +12 -0
- package/src/Options.ts +2 -1
package/android/build.gradle
CHANGED
|
@@ -33,5 +33,5 @@ dependencies {
|
|
|
33
33
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
34
34
|
implementation 'com.facebook.react:react-native:+'
|
|
35
35
|
// api project(':navigation')
|
|
36
|
-
api 'io.github.listenzz:AndroidNavigation:13.5.
|
|
36
|
+
api 'io.github.listenzz:AndroidNavigation:13.5.4'
|
|
37
37
|
}
|
|
@@ -65,8 +65,6 @@ public class Garden {
|
|
|
65
65
|
|
|
66
66
|
boolean forceTransparentDialogWindow;
|
|
67
67
|
|
|
68
|
-
boolean fitsOpaqueNavigationBar;
|
|
69
|
-
|
|
70
68
|
Garden(@NonNull HybridFragment fragment, Style style) {
|
|
71
69
|
// 构造 garden 实例时,Toolbar 还没有被创建
|
|
72
70
|
|
|
@@ -81,8 +79,12 @@ public class Garden {
|
|
|
81
79
|
Bundle tabItem = options.getBundle("tabItem");
|
|
82
80
|
this.hidesBottomBarWhenPushed = tabItem == null || tabItem.getBoolean("hideTabBarWhenPush", true);
|
|
83
81
|
this.extendedLayoutIncludesTopBar = options.getBoolean("extendedLayoutIncludesTopBar", false);
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
|
|
83
|
+
if (options.get("fitsOpaqueNavigationBarAndroid") != null) {
|
|
84
|
+
boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid");
|
|
85
|
+
style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
|
|
86
|
+
}
|
|
87
|
+
|
|
86
88
|
String screenColor = options.getString("screenBackgroundColor");
|
|
87
89
|
if (!TextUtils.isEmpty(screenColor)) {
|
|
88
90
|
style.setScreenBackgroundColor(Color.parseColor(screenColor));
|
|
@@ -31,7 +31,7 @@ public class GlobalStyle {
|
|
|
31
31
|
public GlobalStyle(Bundle options) {
|
|
32
32
|
this.options = options;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
public void inflateStyle(Context context, Style style) {
|
|
36
36
|
if (options == null) {
|
|
37
37
|
FLog.w(TAG, "Style options is null");
|
|
@@ -210,6 +210,11 @@ public class GlobalStyle {
|
|
|
210
210
|
if (scrimAlpha != -1) {
|
|
211
211
|
style.setScrimAlpha((int) scrimAlpha);
|
|
212
212
|
}
|
|
213
|
+
|
|
214
|
+
// fitsOpaqueNavigationBarAndroid
|
|
215
|
+
boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid", false);
|
|
216
|
+
style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
|
|
217
|
+
|
|
213
218
|
}
|
|
214
219
|
|
|
215
220
|
private void setBarBarShadowImage(@NonNull Context context, @NonNull Style style, @NonNull Bundle shadowImage) {
|
|
@@ -49,7 +49,7 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
49
49
|
public ReactInstanceManager getReactInstanceManager() {
|
|
50
50
|
return bridgeManager.getReactInstanceManager();
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
@Nullable
|
|
54
54
|
public ReactContext getCurrentReactContext() {
|
|
55
55
|
return bridgeManager.getCurrentReactContext();
|
|
@@ -167,9 +167,9 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
167
167
|
return true;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
return AppUtils.isOpaque(preferredNavigationBarColor())
|
|
170
|
+
return mStyle.shouldFitsOpaqueNavigationBar() && AppUtils.isOpaque(preferredNavigationBarColor());
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
protected boolean shouldPassThroughTouches() {
|
|
174
174
|
Bundle options = getOptions();
|
|
175
175
|
return options.getBoolean("passThroughTouches");
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java
CHANGED
|
@@ -115,8 +115,14 @@ public class ScreenNavigator implements Navigator {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
private void handleShowModalLayout(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Callback callback) {
|
|
118
|
+
AwesomeFragment presented = presenting.getPresentedFragment();
|
|
119
|
+
if (presented != null) {
|
|
120
|
+
callback.invoke(null, false);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
ReadableMap layout = extras.getMap("layout");
|
|
119
|
-
|
|
125
|
+
presented = getReactBridgeManager().createFragment(layout);
|
|
120
126
|
if (presented == null) {
|
|
121
127
|
callback.invoke(null, false);
|
|
122
128
|
return;
|
|
@@ -127,8 +133,14 @@ public class ScreenNavigator implements Navigator {
|
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
private void handlePresentLayout(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Callback callback) {
|
|
136
|
+
AwesomeFragment presented = presenting.getPresentedFragment();
|
|
137
|
+
if (presented != null) {
|
|
138
|
+
callback.invoke(null, false);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
130
142
|
ReadableMap layout = extras.getMap("layout");
|
|
131
|
-
|
|
143
|
+
presented = getReactBridgeManager().createFragment(layout);
|
|
132
144
|
if (presented == null) {
|
|
133
145
|
callback.invoke(null, false);
|
|
134
146
|
return;
|
|
@@ -138,7 +150,13 @@ public class ScreenNavigator implements Navigator {
|
|
|
138
150
|
}
|
|
139
151
|
|
|
140
152
|
private void handleShowModal(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Callback callback) {
|
|
141
|
-
AwesomeFragment presented =
|
|
153
|
+
AwesomeFragment presented = presenting.getPresentedFragment();
|
|
154
|
+
if (presented != null) {
|
|
155
|
+
callback.invoke(null, false);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
presented = createFragmentWithExtras(extras);
|
|
142
160
|
if (presented == null) {
|
|
143
161
|
callback.invoke(null, false);
|
|
144
162
|
return;
|
|
@@ -156,16 +174,22 @@ public class ScreenNavigator implements Navigator {
|
|
|
156
174
|
target.dismissFragment(() -> callback.invoke(null, true));
|
|
157
175
|
}
|
|
158
176
|
|
|
159
|
-
private void handlePresent(@NonNull AwesomeFragment
|
|
160
|
-
AwesomeFragment
|
|
161
|
-
if (
|
|
177
|
+
private void handlePresent(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Callback callback) {
|
|
178
|
+
AwesomeFragment presented = presenting.getPresentedFragment();
|
|
179
|
+
if (presented != null) {
|
|
180
|
+
callback.invoke(null, false);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
presented = createFragmentWithExtras(extras);
|
|
185
|
+
if (presented == null) {
|
|
162
186
|
callback.invoke(null, false);
|
|
163
187
|
return;
|
|
164
188
|
}
|
|
165
189
|
int requestCode = extras.getInt("requestCode");
|
|
166
190
|
ReactStackFragment stackFragment = new ReactStackFragment();
|
|
167
|
-
stackFragment.setRootFragment(
|
|
168
|
-
|
|
191
|
+
stackFragment.setRootFragment(presented);
|
|
192
|
+
presenting.presentFragment(stackFragment, requestCode, () -> callback.invoke(null, true));
|
|
169
193
|
}
|
|
170
194
|
|
|
171
195
|
private AwesomeFragment createFragmentWithExtras(@NonNull ReadableMap extras) {
|
package/lib/Navigator.js
CHANGED
|
@@ -151,6 +151,7 @@ export class Navigator {
|
|
|
151
151
|
requestCode,
|
|
152
152
|
});
|
|
153
153
|
if (!success) {
|
|
154
|
+
console.warn(`present from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
154
155
|
return [RESULT_CANCEL, null];
|
|
155
156
|
}
|
|
156
157
|
return Navigation.result(this.sceneId, requestCode);
|
|
@@ -163,6 +164,7 @@ export class Navigator {
|
|
|
163
164
|
requestCode,
|
|
164
165
|
});
|
|
165
166
|
if (!success) {
|
|
167
|
+
console.warn(`presentLayout from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
166
168
|
return [RESULT_CANCEL, null];
|
|
167
169
|
}
|
|
168
170
|
return Navigation.result(this.sceneId, requestCode);
|
|
@@ -179,6 +181,7 @@ export class Navigator {
|
|
|
179
181
|
requestCode,
|
|
180
182
|
});
|
|
181
183
|
if (!success) {
|
|
184
|
+
console.warn(`showModal from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
182
185
|
return [RESULT_CANCEL, null];
|
|
183
186
|
}
|
|
184
187
|
return Navigation.result(this.sceneId, requestCode);
|
|
@@ -191,6 +194,7 @@ export class Navigator {
|
|
|
191
194
|
requestCode,
|
|
192
195
|
});
|
|
193
196
|
if (!success) {
|
|
197
|
+
console.warn(`showModal from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
194
198
|
return [RESULT_CANCEL, null];
|
|
195
199
|
}
|
|
196
200
|
return Navigation.result(this.sceneId, requestCode);
|
package/lib/Options.d.ts
CHANGED
|
@@ -107,6 +107,7 @@ export interface DefaultOptions {
|
|
|
107
107
|
swipeBackEnabledAndroid?: boolean;
|
|
108
108
|
splitTopBarTransitionIOS?: boolean;
|
|
109
109
|
scrimAlphaAndroid?: number;
|
|
110
|
+
fitsOpaqueNavigationBarAndroid?: boolean;
|
|
110
111
|
displayCutoutWhenLandscapeAndroid?: boolean;
|
|
111
112
|
tabBarColor?: Color;
|
|
112
113
|
tabBarShadowImage?: ShadowImage;
|
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.15.
|
|
4
|
+
"version": "2.15.5",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
package/src/Navigator.ts
CHANGED
|
@@ -209,6 +209,9 @@ export class Navigator implements Navigator {
|
|
|
209
209
|
requestCode,
|
|
210
210
|
})
|
|
211
211
|
if (!success) {
|
|
212
|
+
console.warn(
|
|
213
|
+
`present from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
214
|
+
)
|
|
212
215
|
return [RESULT_CANCEL, null] as [number, T]
|
|
213
216
|
}
|
|
214
217
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
@@ -222,6 +225,9 @@ export class Navigator implements Navigator {
|
|
|
222
225
|
requestCode,
|
|
223
226
|
})
|
|
224
227
|
if (!success) {
|
|
228
|
+
console.warn(
|
|
229
|
+
`presentLayout from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
230
|
+
)
|
|
225
231
|
return [RESULT_CANCEL, null] as [number, T]
|
|
226
232
|
}
|
|
227
233
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
@@ -244,6 +250,9 @@ export class Navigator implements Navigator {
|
|
|
244
250
|
requestCode,
|
|
245
251
|
})
|
|
246
252
|
if (!success) {
|
|
253
|
+
console.warn(
|
|
254
|
+
`showModal from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
255
|
+
)
|
|
247
256
|
return [RESULT_CANCEL, null] as [number, T]
|
|
248
257
|
}
|
|
249
258
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
@@ -257,6 +266,9 @@ export class Navigator implements Navigator {
|
|
|
257
266
|
requestCode,
|
|
258
267
|
})
|
|
259
268
|
if (!success) {
|
|
269
|
+
console.warn(
|
|
270
|
+
`showModal from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
271
|
+
)
|
|
260
272
|
return [RESULT_CANCEL, null] as [number, T]
|
|
261
273
|
}
|
|
262
274
|
return Navigation.result<T>(this.sceneId, requestCode)
|
package/src/Options.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface NavigationOption {
|
|
|
34
34
|
titleTextSize?: number // TopBar 标题字体大小
|
|
35
35
|
navigationBarColorAndroid?: Color // Android 底部虚拟按钮背景颜色
|
|
36
36
|
navigationBarHiddenAndroid?: boolean // 是否隐藏 Android 底部的虚拟导航栏
|
|
37
|
-
fitsOpaqueNavigationBarAndroid?: boolean //
|
|
37
|
+
fitsOpaqueNavigationBarAndroid?: boolean // 适配不透明的导航栏边衬区,默认为 false
|
|
38
38
|
displayCutoutWhenLandscapeAndroid?: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
|
|
39
39
|
homeIndicatorAutoHiddenIOS?: boolean // 是否隐藏 Home 指示器,默认 false
|
|
40
40
|
|
|
@@ -114,6 +114,7 @@ export interface DefaultOptions {
|
|
|
114
114
|
swipeBackEnabledAndroid?: boolean // Android 是否开启右滑返回,默认是 false
|
|
115
115
|
splitTopBarTransitionIOS?: boolean // iOS 侧滑返回时,是否总是割裂导航栏背景
|
|
116
116
|
scrimAlphaAndroid?: number // Android 侧滑返回遮罩效果 [0 - 255]
|
|
117
|
+
fitsOpaqueNavigationBarAndroid?: boolean // 适配不透明的导航栏边衬区,默认为 false
|
|
117
118
|
displayCutoutWhenLandscapeAndroid?: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
|
|
118
119
|
|
|
119
120
|
tabBarColor?: Color // 底部 TabBar 背景颜色,请勿使用带透明度的颜色。
|