hybrid-navigation 2.8.3 → 2.10.1
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/HybridNavigation.podspec +6 -6
- package/LICENSE +1 -1
- package/android/build.gradle +4 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +27 -40
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +77 -48
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +4 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +1 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +94 -43
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +134 -117
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +65 -35
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +14 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +133 -89
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +161 -126
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +145 -114
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +40 -28
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +96 -75
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/Navigator.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +111 -79
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +187 -117
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +137 -96
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +7 -0
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +16 -0
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcuserdata/listen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/HybridNavigation.xcodeproj/xcuserdata/listen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/Navigator.d.ts +6 -6
- package/lib/ReactRegistry.d.ts +3 -3
- package/lib/ReactRegistry.js +14 -10
- package/lib/typing.d.ts +8 -8
- package/package.json +27 -16
- package/src/DeepLink.ts +60 -0
- package/src/Garden.ts +171 -0
- package/src/NavigationModule.ts +33 -0
- package/src/Navigator.ts +404 -0
- package/src/ReactRegistry.tsx +138 -0
- package/src/hooks.ts +83 -0
- package/src/index.ts +9 -0
- package/src/router/drawer.ts +34 -0
- package/src/router/index.ts +166 -0
- package/src/router/screen.ts +12 -0
- package/src/router/stack.ts +80 -0
- package/src/router/tabs.ts +49 -0
- package/src/router/typing.ts +45 -0
- package/src/store.ts +49 -0
- package/src/typing.ts +148 -0
- package/src/utils.ts +83 -0
- package/.buckconfig +0 -6
- package/.editorconfig +0 -16
- package/.eslintignore +0 -5
- package/.gitattributes +0 -1
- package/.github/workflows/docs.yml +0 -25
- package/CHANGELOG.md +0 -399
- package/babel.config.js +0 -15
- package/docs/README.md +0 -109
- package/docs/custom-tabbar.md +0 -138
- package/docs/deeplink.md +0 -148
- package/docs/integration-native.md +0 -390
- package/docs/integration-react.md +0 -194
- package/docs/lifecycle.md +0 -85
- package/docs/navigation.md +0 -589
- package/docs/pass-and-return-value.md +0 -163
- package/docs/qa.md +0 -57
- package/docs/style.md +0 -533
- package/jest.config.js +0 -4
- package/metro.config.js +0 -17
- package/screenshot/android.png +0 -0
- package/screenshot/bulge.jpg +0 -0
- package/screenshot/controller-base.jpg +0 -0
- package/screenshot/demo-qrcode.png +0 -0
- package/screenshot/header-search-paths.jpg +0 -0
- package/screenshot/ios-react-script.png +0 -0
- package/screenshot/ios-run-script.jpg +0 -0
- package/screenshot/statusbar-inperfect.png +0 -0
- package/screenshot/statusbar-setup-step-1.png +0 -0
- package/screenshot/statusbar-setup-step-2.png +0 -0
- package/screenshot/tabbar.jpg +0 -0
- package/screenshot/topbar-default.png +0 -0
- package/screenshot/xcode-linking.png +0 -0
package/HybridNavigation.podspec
CHANGED
|
@@ -7,12 +7,12 @@ Pod::Spec.new do |s|
|
|
|
7
7
|
s.version = package["version"]
|
|
8
8
|
s.summary = package["description"]
|
|
9
9
|
|
|
10
|
-
s.homepage = "
|
|
11
|
-
s.license = "
|
|
12
|
-
s.authors =
|
|
13
|
-
s.platforms = { :ios => "10.0"
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
s.platforms = { :ios => "10.0" }
|
|
14
14
|
s.source = { :git => "https://github.com/listenzz/hybrid-navigation.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
|
-
s.source_files = "ios/HybridNavigation/**/*.{h,m,
|
|
17
|
-
s.dependency "React"
|
|
16
|
+
s.source_files = "ios/HybridNavigation/**/*.{h,m,mm}"
|
|
17
|
+
s.dependency "React-Core"
|
|
18
18
|
end
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2022 listen <listenzz@163.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/android/build.gradle
CHANGED
|
@@ -12,12 +12,12 @@ android {
|
|
|
12
12
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
compileSdkVersion safeExtGet('compileSdkVersion',
|
|
16
|
-
buildToolsVersion safeExtGet('buildToolsVersion', '
|
|
15
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
16
|
+
buildToolsVersion safeExtGet('buildToolsVersion', '30.0.2')
|
|
17
17
|
|
|
18
18
|
defaultConfig {
|
|
19
19
|
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
20
|
-
targetSdkVersion safeExtGet('targetSdkVersion',
|
|
20
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 30)
|
|
21
21
|
versionCode 1
|
|
22
22
|
versionName "1.0.0"
|
|
23
23
|
}
|
|
@@ -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:12.
|
|
36
|
+
api 'io.github.listenzz:AndroidNavigation:12.2.0'
|
|
37
37
|
}
|
|
@@ -63,7 +63,7 @@ public class Garden {
|
|
|
63
63
|
boolean extendedLayoutIncludesTopBar;
|
|
64
64
|
|
|
65
65
|
boolean forceTransparentDialogWindow;
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
Garden(@NonNull HybridFragment fragment, Style style) {
|
|
68
68
|
// 构造 garden 实例时,Toolbar 还没有被创建
|
|
69
69
|
|
|
@@ -83,13 +83,13 @@ public class Garden {
|
|
|
83
83
|
if (!TextUtils.isEmpty(screenColor)) {
|
|
84
84
|
style.setScreenBackgroundColor(Color.parseColor(screenColor));
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
this.forceTransparentDialogWindow = options.getBoolean("forceTransparentDialogWindow");
|
|
88
86
|
|
|
87
|
+
this.forceTransparentDialogWindow = options.getBoolean("forceTransparentDialogWindow");
|
|
88
|
+
|
|
89
89
|
applyOptions(options);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
void
|
|
92
|
+
void setupToolbar() {
|
|
93
93
|
|
|
94
94
|
if (fragment.getView() == null || fragment.getContext() == null) {
|
|
95
95
|
return;
|
|
@@ -112,7 +112,7 @@ public class Garden {
|
|
|
112
112
|
} else if (rightBarButtonItem != null) {
|
|
113
113
|
setRightBarButtonItem(rightBarButtonItem);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
Bundle leftBarButtonItem = options.getBundle("leftBarButtonItem");
|
|
117
117
|
ArrayList<Bundle> leftBarButtonItems = options.getParcelableArrayList("leftBarButtonItems");
|
|
118
118
|
if (leftBarButtonItems != null) {
|
|
@@ -124,26 +124,27 @@ public class Garden {
|
|
|
124
124
|
|
|
125
125
|
void setTitleItem(@NonNull Bundle titleItem) {
|
|
126
126
|
String moduleName = titleItem.getString("moduleName");
|
|
127
|
-
if (moduleName
|
|
128
|
-
|
|
129
|
-
fragment.setTitle(title);
|
|
127
|
+
if (moduleName != null) {
|
|
128
|
+
return;
|
|
130
129
|
}
|
|
130
|
+
String title = titleItem.getString("title");
|
|
131
|
+
fragment.setTitle(title);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
void setLeftBarButtonItems(ArrayList<Bundle> items) {
|
|
134
|
-
if (items
|
|
135
|
-
fragment.setLeftBarButtonItems(barButtonItemsFromBundle(items));
|
|
136
|
-
} else {
|
|
135
|
+
if (items == null) {
|
|
137
136
|
fragment.setLeftBarButtonItems(null);
|
|
137
|
+
return;
|
|
138
138
|
}
|
|
139
|
+
fragment.setLeftBarButtonItems(barButtonItemsFromBundle(items));
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
void setRightBarButtonItems(ArrayList<Bundle> items) {
|
|
142
|
-
if (items
|
|
143
|
-
fragment.setRightBarButtonItems(barButtonItemsFromBundle(items));
|
|
144
|
-
} else {
|
|
143
|
+
if (items == null) {
|
|
145
144
|
fragment.setRightBarButtonItems(null);
|
|
145
|
+
return;
|
|
146
146
|
}
|
|
147
|
+
fragment.setRightBarButtonItems(barButtonItemsFromBundle(items));
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
private ToolbarButtonItem[] barButtonItemsFromBundle(ArrayList<Bundle> items) {
|
|
@@ -156,19 +157,19 @@ public class Garden {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
void setLeftBarButtonItem(@Nullable Bundle item) {
|
|
159
|
-
if (item
|
|
160
|
-
fragment.setLeftBarButtonItem(barButtonItemFromBundle(item));
|
|
161
|
-
} else {
|
|
160
|
+
if (item == null) {
|
|
162
161
|
fragment.setLeftBarButtonItem(null);
|
|
162
|
+
return;
|
|
163
163
|
}
|
|
164
|
+
fragment.setLeftBarButtonItem(barButtonItemFromBundle(item));
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
void setRightBarButtonItem(@Nullable Bundle item) {
|
|
167
|
-
if (item
|
|
168
|
-
fragment.setRightBarButtonItem(barButtonItemFromBundle(item));
|
|
169
|
-
} else {
|
|
168
|
+
if (item == null) {
|
|
170
169
|
fragment.setRightBarButtonItem(null);
|
|
170
|
+
return;
|
|
171
171
|
}
|
|
172
|
+
fragment.setRightBarButtonItem(barButtonItemFromBundle(item));
|
|
172
173
|
}
|
|
173
174
|
|
|
174
175
|
private ToolbarButtonItem barButtonItemFromBundle(@NonNull Bundle item) {
|
|
@@ -268,7 +269,6 @@ public class Garden {
|
|
|
268
269
|
|
|
269
270
|
void updateOptions(@NonNull ReadableMap readableMap) {
|
|
270
271
|
Bundle patches = toBundle(readableMap);
|
|
271
|
-
|
|
272
272
|
applyOptions(patches);
|
|
273
273
|
|
|
274
274
|
if (readableMap.hasKey("screenBackgroundColor")) {
|
|
@@ -291,13 +291,9 @@ public class Garden {
|
|
|
291
291
|
if (shouldUpdateNavigationBar(readableMap)) {
|
|
292
292
|
fragment.setNeedsNavigationBarAppearanceUpdate();
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
if (readableMap.hasKey("passThroughTouches")) {
|
|
296
|
-
boolean passThroughTouches = readableMap.getBoolean("passThroughTouches");
|
|
297
|
-
setPassThroughTouches(passThroughTouches);
|
|
298
|
-
}
|
|
299
|
-
|
|
294
|
+
|
|
300
295
|
Bundle options = mergeOptions(fragment.getOptions(), patches);
|
|
296
|
+
fragment.setOptions(options);
|
|
301
297
|
|
|
302
298
|
if (readableMap.hasKey("leftBarButtonItem")) {
|
|
303
299
|
Bundle bundle = options.getBundle("leftBarButtonItem");
|
|
@@ -323,8 +319,6 @@ public class Garden {
|
|
|
323
319
|
Bundle titleItem = options.getBundle("titleItem");
|
|
324
320
|
setTitleItem(titleItem);
|
|
325
321
|
}
|
|
326
|
-
|
|
327
|
-
fragment.setOptions(options);
|
|
328
322
|
}
|
|
329
323
|
|
|
330
324
|
private boolean shouldUpdateStatusBar(@NonNull ReadableMap readableMap) {
|
|
@@ -339,9 +333,9 @@ public class Garden {
|
|
|
339
333
|
|
|
340
334
|
private boolean shouldUpdateToolbar(@NonNull ReadableMap readableMap) {
|
|
341
335
|
String[] keys = new String[]{
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
336
|
+
"topBarStyle",
|
|
337
|
+
"topBarColor", "topBarAlpha", "topBarShadowHidden", "topBarTintColor",
|
|
338
|
+
"titleTextSize", "titleTextColor", "backButtonHidden"
|
|
345
339
|
};
|
|
346
340
|
|
|
347
341
|
for (String key : keys) {
|
|
@@ -361,12 +355,5 @@ public class Garden {
|
|
|
361
355
|
}
|
|
362
356
|
return false;
|
|
363
357
|
}
|
|
364
|
-
|
|
365
|
-
void setPassThroughTouches(boolean passThroughTouches) {
|
|
366
|
-
View view = fragment.getView();
|
|
367
|
-
if (view instanceof HBDReactRootView) {
|
|
368
|
-
((HBDReactRootView) view).setShouldConsumeTouchEvent(!passThroughTouches);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
358
|
+
|
|
372
359
|
}
|
|
@@ -45,7 +45,7 @@ public class GardenModule extends ReactContextBaseJavaModule {
|
|
|
45
45
|
super(reactContext);
|
|
46
46
|
this.bridgeManager = bridgeManager;
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
@NonNull
|
|
50
50
|
@Override
|
|
51
51
|
public String getName() {
|
|
@@ -65,17 +65,16 @@ public class GardenModule extends ReactContextBaseJavaModule {
|
|
|
65
65
|
UiThreadUtil.runOnUiThread(() -> {
|
|
66
66
|
FLog.i(TAG, "GardenModule#setStyle");
|
|
67
67
|
Garden.createGlobalStyle(toBundle(style));
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
if (activity != null) {
|
|
73
|
-
activity.inflateStyle();
|
|
74
|
-
}
|
|
68
|
+
|
|
69
|
+
ReactAppCompatActivity activity = getActiveActivity();
|
|
70
|
+
if (activity == null) {
|
|
71
|
+
return;
|
|
75
72
|
}
|
|
73
|
+
|
|
74
|
+
activity.inflateStyle();
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
|
-
|
|
77
|
+
|
|
79
78
|
@ReactMethod
|
|
80
79
|
public void setLeftBarButtonItem(final String sceneId, @Nullable final ReadableMap readableMap) {
|
|
81
80
|
updateOptions(sceneId, readableMap, "leftBarButtonItem");
|
|
@@ -106,9 +105,10 @@ public class GardenModule extends ReactContextBaseJavaModule {
|
|
|
106
105
|
FLog.i(TAG, "update options:" + readableMap);
|
|
107
106
|
UiThreadUtil.runOnUiThread(() -> {
|
|
108
107
|
HybridFragment fragment = findHybridFragmentBySceneId(sceneId);
|
|
109
|
-
if (fragment
|
|
110
|
-
|
|
108
|
+
if (fragment == null) {
|
|
109
|
+
return;
|
|
111
110
|
}
|
|
111
|
+
fragment.getGarden().updateOptions(readableMap);
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -136,16 +136,15 @@ public class GardenModule extends ReactContextBaseJavaModule {
|
|
|
136
136
|
public void updateTabBar(final String sceneId, final ReadableMap readableMap) {
|
|
137
137
|
FLog.i(TAG, "updateTabBar:" + readableMap);
|
|
138
138
|
UiThreadUtil.runOnUiThread(() -> {
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
if (tabBarFragment != null) {
|
|
143
|
-
Bundle bundle = new Bundle();
|
|
144
|
-
bundle.putString(ARG_ACTION, ACTION_UPDATE_TAB_BAR);
|
|
145
|
-
bundle.putBundle(ARG_OPTIONS, toBundle(readableMap));
|
|
146
|
-
tabBarFragment.updateTabBar(bundle);
|
|
147
|
-
}
|
|
139
|
+
TabBarFragment tabBarFragment = getTabBarFragment(sceneId);
|
|
140
|
+
if (tabBarFragment == null) {
|
|
141
|
+
return;
|
|
148
142
|
}
|
|
143
|
+
|
|
144
|
+
Bundle bundle = new Bundle();
|
|
145
|
+
bundle.putString(ARG_ACTION, ACTION_UPDATE_TAB_BAR);
|
|
146
|
+
bundle.putBundle(ARG_OPTIONS, toBundle(readableMap));
|
|
147
|
+
tabBarFragment.updateTabBar(bundle);
|
|
149
148
|
});
|
|
150
149
|
}
|
|
151
150
|
|
|
@@ -153,57 +152,87 @@ public class GardenModule extends ReactContextBaseJavaModule {
|
|
|
153
152
|
public void setTabItem(final String sceneId, @NonNull final ReadableArray options) {
|
|
154
153
|
FLog.i(TAG, "setTabItem:" + options);
|
|
155
154
|
UiThreadUtil.runOnUiThread(() -> {
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
if (tabBarFragment != null) {
|
|
160
|
-
Bundle bundle = new Bundle();
|
|
161
|
-
bundle.putString(ARG_ACTION, ACTION_SET_TAB_ITEM);
|
|
162
|
-
bundle.putSerializable(ARG_OPTIONS, toList(options));
|
|
163
|
-
tabBarFragment.updateTabBar(bundle);
|
|
164
|
-
}
|
|
155
|
+
TabBarFragment tabBarFragment = getTabBarFragment(sceneId);
|
|
156
|
+
if (tabBarFragment == null) {
|
|
157
|
+
return;
|
|
165
158
|
}
|
|
159
|
+
|
|
160
|
+
Bundle bundle = new Bundle();
|
|
161
|
+
bundle.putString(ARG_ACTION, ACTION_SET_TAB_ITEM);
|
|
162
|
+
bundle.putSerializable(ARG_OPTIONS, toList(options));
|
|
163
|
+
tabBarFragment.updateTabBar(bundle);
|
|
166
164
|
});
|
|
167
165
|
}
|
|
168
166
|
|
|
167
|
+
@Nullable
|
|
168
|
+
private TabBarFragment getTabBarFragment(String sceneId) {
|
|
169
|
+
AwesomeFragment fragment = findFragmentBySceneId(sceneId);
|
|
170
|
+
if (fragment == null) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
if (fragment.getView() == null) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return fragment.getTabBarFragment();
|
|
178
|
+
}
|
|
179
|
+
|
|
169
180
|
@ReactMethod
|
|
170
181
|
public void setMenuInteractive(final String sceneId, final boolean enabled) {
|
|
171
182
|
UiThreadUtil.runOnUiThread(() -> {
|
|
172
|
-
AwesomeFragment
|
|
173
|
-
if (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
183
|
+
AwesomeFragment fragment = findFragmentBySceneId(sceneId);
|
|
184
|
+
if (fragment == null) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
DrawerFragment drawerFragment = fragment.getDrawerFragment();
|
|
189
|
+
if (drawerFragment == null) {
|
|
190
|
+
return;
|
|
178
191
|
}
|
|
192
|
+
|
|
193
|
+
drawerFragment.setDrawerLockMode(enabled ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
|
179
194
|
});
|
|
180
195
|
}
|
|
181
196
|
|
|
182
197
|
private AwesomeFragment findFragmentBySceneId(String sceneId) {
|
|
183
|
-
ReactContext reactContext = getReactApplicationContextIfActiveOrWarn();
|
|
184
|
-
if (reactContext == null) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
198
|
if (!bridgeManager.isViewHierarchyReady()) {
|
|
188
199
|
FLog.w(TAG, "View hierarchy is not ready now.");
|
|
189
200
|
return null;
|
|
190
201
|
}
|
|
191
202
|
|
|
192
|
-
|
|
193
|
-
if (activity
|
|
194
|
-
|
|
195
|
-
FragmentManager fragmentManager = reactActivity.getSupportFragmentManager();
|
|
196
|
-
return FragmentHelper.findAwesomeFragment(fragmentManager, sceneId);
|
|
203
|
+
ReactAppCompatActivity activity = getActiveActivity();
|
|
204
|
+
if (activity == null) {
|
|
205
|
+
return null;
|
|
197
206
|
}
|
|
198
|
-
|
|
207
|
+
|
|
208
|
+
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
209
|
+
return FragmentHelper.findAwesomeFragment(fragmentManager, sceneId);
|
|
199
210
|
}
|
|
200
211
|
|
|
212
|
+
@Nullable
|
|
213
|
+
private ReactAppCompatActivity getActiveActivity() {
|
|
214
|
+
ReactContext reactContext = getReactApplicationContextIfActiveOrWarn();
|
|
215
|
+
if (reactContext == null) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
Activity activity = reactContext.getCurrentActivity();
|
|
220
|
+
if (!(activity instanceof ReactAppCompatActivity)) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return (ReactAppCompatActivity) activity;
|
|
225
|
+
}
|
|
226
|
+
|
|
201
227
|
private HybridFragment findHybridFragmentBySceneId(String sceneId) {
|
|
202
228
|
AwesomeFragment fragment = findFragmentBySceneId(sceneId);
|
|
203
|
-
if (fragment instanceof HybridFragment) {
|
|
204
|
-
return
|
|
229
|
+
if (!(fragment instanceof HybridFragment)) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
if (!fragment.isAdded()) {
|
|
233
|
+
return null;
|
|
205
234
|
}
|
|
206
|
-
return
|
|
235
|
+
return (HybridFragment) fragment;
|
|
207
236
|
}
|
|
208
237
|
|
|
209
238
|
}
|
|
@@ -78,11 +78,11 @@ public class HBDEventEmitter extends ReactContextBaseJavaModule {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
public static void sendEvent(@NonNull String eventName, @NonNull WritableMap params) {
|
|
81
|
-
ReactBridgeManager
|
|
82
|
-
ReactContext reactContext =
|
|
83
|
-
if (reactContext != null && reactContext.hasActiveCatalystInstance() &&
|
|
81
|
+
ReactBridgeManager bridgeManager = ReactBridgeManager.get();
|
|
82
|
+
ReactContext reactContext = bridgeManager.getCurrentReactContext();
|
|
83
|
+
if (reactContext != null && reactContext.hasActiveCatalystInstance() && bridgeManager.isReactModuleRegisterCompleted()) {
|
|
84
84
|
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
85
|
-
|
|
85
|
+
.emit(eventName, params);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -2,9 +2,7 @@ package com.reactnative.hybridnavigation;
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context;
|
|
4
4
|
import android.os.Bundle;
|
|
5
|
-
import android.os.SystemClock;
|
|
6
5
|
import android.util.AttributeSet;
|
|
7
|
-
import android.view.InputDevice;
|
|
8
6
|
import android.view.MotionEvent;
|
|
9
7
|
import android.view.ViewTreeObserver;
|
|
10
8
|
|
|
@@ -13,7 +11,6 @@ import androidx.annotation.Nullable;
|
|
|
13
11
|
import com.facebook.react.ReactInstanceManager;
|
|
14
12
|
import com.facebook.react.ReactRootView;
|
|
15
13
|
|
|
16
|
-
import java.lang.reflect.InvocationTargetException;
|
|
17
14
|
import java.lang.reflect.Method;
|
|
18
15
|
|
|
19
16
|
|
|
@@ -97,11 +94,7 @@ public class HBDReactRootView extends ReactRootView {
|
|
|
97
94
|
Method method = ReactRootView.class.getDeclaredMethod("getCustomGlobalLayoutListener");
|
|
98
95
|
method.setAccessible(true);
|
|
99
96
|
mGlobalLayoutListener = (ViewTreeObserver.OnGlobalLayoutListener) method.invoke(this);
|
|
100
|
-
} catch (
|
|
101
|
-
e.printStackTrace();
|
|
102
|
-
} catch (IllegalAccessException e) {
|
|
103
|
-
e.printStackTrace();
|
|
104
|
-
} catch (InvocationTargetException e) {
|
|
97
|
+
} catch (Exception e) {
|
|
105
98
|
e.printStackTrace();
|
|
106
99
|
}
|
|
107
100
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
2
|
|
|
3
|
+
import static com.reactnative.hybridnavigation.Constants.ARG_MODULE_NAME;
|
|
4
|
+
import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
5
|
+
import static com.reactnative.hybridnavigation.Constants.ARG_PROPS;
|
|
6
|
+
import static com.reactnative.hybridnavigation.Constants.ARG_SCENE_ID;
|
|
7
|
+
|
|
8
|
+
import android.app.Dialog;
|
|
9
|
+
import android.graphics.Color;
|
|
10
|
+
import android.graphics.drawable.ColorDrawable;
|
|
3
11
|
import android.os.Bundle;
|
|
4
12
|
import android.view.View;
|
|
5
13
|
import android.view.Window;
|
|
@@ -13,15 +21,12 @@ import com.facebook.react.ReactNativeHost;
|
|
|
13
21
|
import com.facebook.react.bridge.ReactContext;
|
|
14
22
|
import com.navigation.androidx.AwesomeFragment;
|
|
15
23
|
import com.navigation.androidx.AwesomeToolbar;
|
|
24
|
+
import com.navigation.androidx.BarStyle;
|
|
16
25
|
import com.navigation.androidx.FragmentHelper;
|
|
17
26
|
import com.navigation.androidx.Style;
|
|
27
|
+
import com.navigation.androidx.SystemUI;
|
|
18
28
|
import com.navigation.androidx.TabBarItem;
|
|
19
29
|
|
|
20
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_MODULE_NAME;
|
|
21
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
22
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_PROPS;
|
|
23
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_SCENE_ID;
|
|
24
|
-
|
|
25
30
|
/**
|
|
26
31
|
* Created by Listen on 2018/1/15.
|
|
27
32
|
*/
|
|
@@ -90,14 +95,34 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
90
95
|
@Override
|
|
91
96
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
92
97
|
super.onViewCreated(view, savedInstanceState);
|
|
93
|
-
garden.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
garden.setupToolbar();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@NonNull
|
|
102
|
+
@Override
|
|
103
|
+
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
104
|
+
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
|
105
|
+
Window window = dialog.getWindow();
|
|
106
|
+
|
|
107
|
+
if (forceTransparentDialogWindow()) {
|
|
97
108
|
window.setDimAmount(0);
|
|
109
|
+
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return dialog;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@NonNull
|
|
116
|
+
@Override
|
|
117
|
+
protected BarStyle preferredStatusBarStyle() {
|
|
118
|
+
if (getShowsDialog() && forceTransparentDialogWindow()) {
|
|
119
|
+
if (SystemUI.isStatusBarStyleDark(requireActivity().getWindow())) {
|
|
120
|
+
return BarStyle.DarkContent;
|
|
121
|
+
}
|
|
98
122
|
}
|
|
123
|
+
return super.preferredStatusBarStyle();
|
|
99
124
|
}
|
|
100
|
-
|
|
125
|
+
|
|
101
126
|
public Garden getGarden() {
|
|
102
127
|
return garden;
|
|
103
128
|
}
|
|
@@ -122,6 +147,15 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
122
147
|
return garden.hidesBottomBarWhenPushed;
|
|
123
148
|
}
|
|
124
149
|
|
|
150
|
+
protected boolean shouldPassThroughTouches() {
|
|
151
|
+
Bundle options = getOptions();
|
|
152
|
+
return options.getBoolean("passThroughTouches");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
protected boolean forceTransparentDialogWindow() {
|
|
156
|
+
return garden.forceTransparentDialogWindow;
|
|
157
|
+
}
|
|
158
|
+
|
|
125
159
|
@Override
|
|
126
160
|
protected AwesomeToolbar onCreateToolbar(View parent) {
|
|
127
161
|
if (garden.toolbarHidden) {
|
|
@@ -151,37 +185,54 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
151
185
|
@Override
|
|
152
186
|
public void setArguments(@Nullable Bundle args) {
|
|
153
187
|
super.setArguments(args);
|
|
188
|
+
setTabBarItemIfNeeded(args);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private void setTabBarItemIfNeeded(@Nullable Bundle args) {
|
|
192
|
+
if (args == null) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
154
195
|
TabBarItem tabBarItem = getTabBarItem();
|
|
155
|
-
if (tabBarItem
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
tabBarItem = new TabBarItem(title);
|
|
163
|
-
Bundle icon = tabItem.getBundle("icon");
|
|
164
|
-
if (icon != null) {
|
|
165
|
-
String uri = icon.getString("uri");
|
|
166
|
-
if (uri != null) {
|
|
167
|
-
tabBarItem = new TabBarItem(title, uri);
|
|
168
|
-
Bundle unselectedIcon = tabItem.getBundle("unselectedIcon");
|
|
169
|
-
if (unselectedIcon != null) {
|
|
170
|
-
String unselectedUri = unselectedIcon.getString("uri");
|
|
171
|
-
if (unselectedUri != null) {
|
|
172
|
-
tabBarItem = new TabBarItem(title, uri, unselectedUri);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (tabBarItem != null) {
|
|
180
|
-
setTabBarItem(tabBarItem);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
196
|
+
if (tabBarItem != null) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
Bundle options = args.getBundle(Constants.ARG_OPTIONS);
|
|
201
|
+
if (options == null) {
|
|
202
|
+
return;
|
|
184
203
|
}
|
|
204
|
+
Bundle tabItem = options.getBundle("tabItem");
|
|
205
|
+
if (tabItem == null) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
String title = tabItem.getString("title");
|
|
209
|
+
if (title == null) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
Bundle icon = tabItem.getBundle("icon");
|
|
214
|
+
if (icon == null) {
|
|
215
|
+
setTabBarItem(new TabBarItem(title));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
String uri = icon.getString("uri");
|
|
219
|
+
if (uri == null) {
|
|
220
|
+
setTabBarItem(new TabBarItem(title));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
Bundle unselectedIcon = tabItem.getBundle("unselectedIcon");
|
|
225
|
+
if (unselectedIcon == null) {
|
|
226
|
+
setTabBarItem(new TabBarItem(title, uri));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
String unselectedUri = unselectedIcon.getString("uri");
|
|
230
|
+
if (unselectedUri == null) {
|
|
231
|
+
setTabBarItem(new TabBarItem(title, uri));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
setTabBarItem(new TabBarItem(title, uri, unselectedUri));
|
|
185
236
|
}
|
|
186
237
|
|
|
187
238
|
private Bundle props;
|
|
@@ -201,13 +252,13 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
201
252
|
|
|
202
253
|
@CallSuper
|
|
203
254
|
public void setAppProperties(@NonNull Bundle props) {
|
|
204
|
-
if (isAdded()) {
|
|
205
|
-
props.putString(ARG_SCENE_ID, getSceneId());
|
|
206
|
-
this.props = props;
|
|
207
|
-
} else {
|
|
255
|
+
if (!isAdded()) {
|
|
208
256
|
Bundle args = FragmentHelper.getArguments(this);
|
|
209
257
|
args.putBundle(ARG_PROPS, props);
|
|
258
|
+
return;
|
|
210
259
|
}
|
|
260
|
+
props.putString(ARG_SCENE_ID, getSceneId());
|
|
261
|
+
this.props = props;
|
|
211
262
|
}
|
|
212
263
|
|
|
213
264
|
public String getModuleName() {
|