hybrid-navigation 2.8.2 → 2.10.0
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/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.name +1 -0
- package/android/.idea/gradle.xml +16 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules/android.iml +18 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +4 -4
- package/android/local.properties +8 -0
- 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 +18 -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 +5 -3
- package/lib/ReactRegistry.js +14 -10
- package/lib/typing.d.ts +8 -8
- package/package.json +24 -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 +140 -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 -393
- 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
|
@@ -46,14 +46,21 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
46
46
|
activityDelegate.onCreate(savedInstanceState);
|
|
47
47
|
getReactBridgeManager().addReactModuleRegisterListener(this);
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
ensureViewHierarchy(savedInstanceState);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private void ensureViewHierarchy(Bundle savedInstanceState) {
|
|
53
|
+
if (!isReactModuleRegisterCompleted()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (savedInstanceState == null) {
|
|
58
|
+
createMainComponent();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (getSupportFragmentManager().getFragments().size() > 0) {
|
|
63
|
+
getReactBridgeManager().setViewHierarchyReady(true);
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
|
|
@@ -99,24 +106,34 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
99
106
|
ReactStackFragment stackFragment = new ReactStackFragment();
|
|
100
107
|
stackFragment.setRootFragment(fragment);
|
|
101
108
|
setActivityRootFragment(stackFragment);
|
|
102
|
-
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (bridgeManager.hasPendingLayout()) {
|
|
103
113
|
FLog.i(TAG, "Set root Fragment from pending layout when create main component");
|
|
104
114
|
setActivityRootFragment(bridgeManager);
|
|
105
|
-
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (bridgeManager.hasStickyLayout()) {
|
|
106
119
|
FLog.i(TAG, "Set root Fragment from sticky layout when create main component");
|
|
107
120
|
AwesomeFragment fragment = bridgeManager.createFragment(bridgeManager.getStickyLayout());
|
|
108
121
|
if (fragment != null) {
|
|
109
122
|
setActivityRootFragment(fragment);
|
|
110
123
|
}
|
|
111
|
-
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (bridgeManager.hasRootLayout()) {
|
|
112
128
|
FLog.i(TAG, "Set root Fragment from last root layout when create main component");
|
|
113
129
|
AwesomeFragment fragment = bridgeManager.createFragment(bridgeManager.getRootLayout());
|
|
114
130
|
if (fragment != null) {
|
|
115
131
|
setActivityRootFragment(fragment);
|
|
116
132
|
}
|
|
117
|
-
|
|
118
|
-
FLog.w(TAG, "No layout to set when create main component");
|
|
133
|
+
return;
|
|
119
134
|
}
|
|
135
|
+
|
|
136
|
+
FLog.w(TAG, "No layout to set when create main component");
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
protected String getMainComponentName() {
|
|
@@ -131,26 +148,31 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
131
148
|
private void setActivityRootFragment(ReactBridgeManager bridgeManager) {
|
|
132
149
|
int pendingTag = bridgeManager.getPendingTag();
|
|
133
150
|
ReadableMap pendingLayout = bridgeManager.getPendingLayout();
|
|
134
|
-
if (pendingTag
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
if (pendingTag == 0 || pendingLayout == null) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
AwesomeFragment fragment = bridgeManager.createFragment(pendingLayout);
|
|
156
|
+
if (fragment == null) {
|
|
157
|
+
FLog.e(TAG, "Could not create fragment from pending layout.");
|
|
158
|
+
return;
|
|
141
159
|
}
|
|
160
|
+
setActivityRootFragment(fragment, pendingTag);
|
|
142
161
|
}
|
|
143
162
|
|
|
144
|
-
|
|
163
|
+
protected void setActivityRootFragment(@NonNull AwesomeFragment rootFragment, int tag) {
|
|
164
|
+
if (isFinishing()) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
145
168
|
if (getSupportFragmentManager().isStateSaved()) {
|
|
146
169
|
FLog.i(TAG, "Schedule to set Activity root Fragment.");
|
|
147
170
|
scheduleTaskAtStarted(() -> setActivityRootFragmentSync(rootFragment, tag));
|
|
148
|
-
|
|
149
|
-
if (!isFinishing()) {
|
|
150
|
-
FLog.i(TAG, "Set Activity root Fragment immediately.");
|
|
151
|
-
setActivityRootFragmentSync(rootFragment, tag);
|
|
152
|
-
}
|
|
171
|
+
return;
|
|
153
172
|
}
|
|
173
|
+
|
|
174
|
+
FLog.i(TAG, "Set Activity root Fragment immediately.");
|
|
175
|
+
setActivityRootFragmentSync(rootFragment, tag);
|
|
154
176
|
}
|
|
155
177
|
|
|
156
178
|
protected void setActivityRootFragmentSync(AwesomeFragment fragment, int tag) {
|
|
@@ -160,17 +182,25 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
160
182
|
throw new IllegalStateException("Style hasn't inflated yet. Did you forgot to call `Garden.setStyle` before `Navigator.setRoot` ?");
|
|
161
183
|
}
|
|
162
184
|
}
|
|
163
|
-
|
|
164
|
-
bridgeManager.setPendingLayout(null, 0);
|
|
185
|
+
|
|
165
186
|
ReactContext reactContext = getCurrentReactContext();
|
|
166
|
-
if (reactContext
|
|
167
|
-
|
|
168
|
-
setActivityRootFragmentSync(fragment);
|
|
169
|
-
bridgeManager.setViewHierarchyReady(true);
|
|
170
|
-
WritableMap map = Arguments.createMap();
|
|
171
|
-
map.putInt("tag", tag);
|
|
172
|
-
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_DID_SET_ROOT, map);
|
|
187
|
+
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
|
|
188
|
+
return;
|
|
173
189
|
}
|
|
190
|
+
|
|
191
|
+
// will
|
|
192
|
+
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_WILL_SET_ROOT, Arguments.createMap());
|
|
193
|
+
|
|
194
|
+
// do
|
|
195
|
+
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
196
|
+
bridgeManager.setPendingLayout(null, 0);
|
|
197
|
+
setActivityRootFragmentSync(fragment);
|
|
198
|
+
bridgeManager.setViewHierarchyReady(true);
|
|
199
|
+
|
|
200
|
+
// did
|
|
201
|
+
WritableMap map = Arguments.createMap();
|
|
202
|
+
map.putInt("tag", tag);
|
|
203
|
+
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_DID_SET_ROOT, map);
|
|
174
204
|
}
|
|
175
205
|
|
|
176
206
|
@Override
|
|
@@ -77,6 +77,8 @@ public class ReactBridgeManager {
|
|
|
77
77
|
pendingTag = 0;
|
|
78
78
|
stickyLayout = null;
|
|
79
79
|
pendingLayout = null;
|
|
80
|
+
reactBridgeReloadListeners.clear();
|
|
81
|
+
|
|
80
82
|
setViewHierarchyReady(false);
|
|
81
83
|
});
|
|
82
84
|
|
|
@@ -174,9 +176,18 @@ public class ReactBridgeManager {
|
|
|
174
176
|
public void removeReactBridgeReloadListener(@NonNull ReactBridgeReloadListener listener) {
|
|
175
177
|
reactBridgeReloadListeners.remove(listener);
|
|
176
178
|
}
|
|
177
|
-
|
|
178
|
-
public
|
|
179
|
-
|
|
179
|
+
|
|
180
|
+
public void handleReload() {
|
|
181
|
+
invokeReloadListeners();
|
|
182
|
+
setPendingLayout(null, 0);
|
|
183
|
+
setReactModuleRegisterCompleted(false);
|
|
184
|
+
setViewHierarchyReady(false);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private void invokeReloadListeners() {
|
|
188
|
+
for (ReactBridgeManager.ReactBridgeReloadListener listener : reactBridgeReloadListeners) {
|
|
189
|
+
listener.onReload();
|
|
190
|
+
}
|
|
180
191
|
}
|
|
181
192
|
|
|
182
193
|
public void setRootLayout(@NonNull ReadableMap root, boolean sticky) {
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
2
|
|
|
3
|
-
import android.
|
|
3
|
+
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
4
|
+
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
5
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.EVENT_NAVIGATION;
|
|
6
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_ON;
|
|
7
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_REQUEST_CODE;
|
|
8
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_RESULT_CODE;
|
|
9
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_RESULT_DATA;
|
|
10
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_SCENE_ID;
|
|
11
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_APPEAR;
|
|
12
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_DISAPPEAR;
|
|
13
|
+
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_RESULT;
|
|
14
|
+
|
|
4
15
|
import android.graphics.Color;
|
|
5
16
|
import android.os.Bundle;
|
|
6
17
|
import android.view.Gravity;
|
|
@@ -12,7 +23,6 @@ import androidx.annotation.NonNull;
|
|
|
12
23
|
import androidx.annotation.Nullable;
|
|
13
24
|
import androidx.appcompat.widget.Toolbar;
|
|
14
25
|
|
|
15
|
-
import com.facebook.react.ReactRootView;
|
|
16
26
|
import com.facebook.react.bridge.Arguments;
|
|
17
27
|
import com.facebook.react.bridge.ReactContext;
|
|
18
28
|
import com.facebook.react.common.LifecycleState;
|
|
@@ -20,17 +30,6 @@ import com.navigation.androidx.FragmentHelper;
|
|
|
20
30
|
import com.navigation.androidx.Style;
|
|
21
31
|
import com.navigation.androidx.TransitionAnimation;
|
|
22
32
|
|
|
23
|
-
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
24
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.EVENT_NAVIGATION;
|
|
25
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_ON;
|
|
26
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_REQUEST_CODE;
|
|
27
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_RESULT_CODE;
|
|
28
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_RESULT_DATA;
|
|
29
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_SCENE_ID;
|
|
30
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_APPEAR;
|
|
31
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_DISAPPEAR;
|
|
32
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_RESULT;
|
|
33
|
-
|
|
34
33
|
/**
|
|
35
34
|
* Created by Listen on 2018/1/15.
|
|
36
35
|
*/
|
|
@@ -58,7 +57,7 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
58
57
|
if (getAnimation() != TransitionAnimation.None) {
|
|
59
58
|
postponeEnterTransition();
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
initReactRootView();
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
return view;
|
|
@@ -70,24 +69,27 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
70
69
|
float alpha = mStyle.getToolbarAlpha();
|
|
71
70
|
Garden garden = getGarden();
|
|
72
71
|
return Color.alpha(color) < 255
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
|| alpha < 1.0
|
|
73
|
+
|| garden.toolbarHidden
|
|
74
|
+
|| garden.extendedLayoutIncludesTopBar;
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
@Override
|
|
79
78
|
protected void onCustomStyle(@NonNull Style style) {
|
|
79
|
+
super.onCustomStyle(style);
|
|
80
80
|
if (shouldPassThroughTouches()) {
|
|
81
81
|
style.setScrimAlpha(0);
|
|
82
82
|
}
|
|
83
|
-
super.onCustomStyle(style);
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
@Override
|
|
87
86
|
public void inspectVisibility(int visibility) {
|
|
88
|
-
if (visibility
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
if (visibility != View.VISIBLE) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (reactRootView == null) {
|
|
91
|
+
initReactRootView();
|
|
92
|
+
initReactTitleView();
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -95,11 +97,11 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
95
97
|
public void onResume() {
|
|
96
98
|
super.onResume();
|
|
97
99
|
if (reactRootView == null) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
initReactRootView();
|
|
101
|
+
initReactTitleView();
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
if (
|
|
104
|
+
if (isViewReady()) {
|
|
103
105
|
reactRootView.addOnGlobalLayoutListener();
|
|
104
106
|
sendViewAppearEvent(true);
|
|
105
107
|
}
|
|
@@ -108,40 +110,53 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
108
110
|
@Override
|
|
109
111
|
public void onPause() {
|
|
110
112
|
super.onPause();
|
|
111
|
-
if (
|
|
113
|
+
if (isViewReady()) {
|
|
112
114
|
sendViewAppearEvent(false);
|
|
113
115
|
reactRootView.removeOnGlobalLayoutListener();
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
private boolean isViewReady() {
|
|
120
|
+
if (reactRootView == null) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return firstRenderCompleted;
|
|
124
|
+
}
|
|
125
|
+
|
|
117
126
|
private boolean reactViewAppeared = false;
|
|
118
127
|
|
|
119
128
|
private void sendViewAppearEvent(boolean appear) {
|
|
129
|
+
if (!isReactModuleRegisterCompleted()) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
120
133
|
// 当从前台进入后台时,不会触发 disappear, 这和 iOS 保持一致
|
|
121
134
|
ReactContext reactContext = getCurrentReactContext();
|
|
122
135
|
boolean isResumed = reactContext != null && reactContext.getLifecycleState() == LifecycleState.RESUMED;
|
|
123
|
-
if (isResumed
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
reactViewAppeared = appear;
|
|
136
|
+
if (!isResumed) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
128
139
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
bundle.putString(KEY_ON, appear ? ON_COMPONENT_APPEAR : ON_COMPONENT_DISAPPEAR);
|
|
132
|
-
HBDEventEmitter.sendEvent(EVENT_NAVIGATION, Arguments.fromBundle(bundle));
|
|
140
|
+
if (reactViewAppeared == appear) {
|
|
141
|
+
return;
|
|
133
142
|
}
|
|
143
|
+
reactViewAppeared = appear;
|
|
144
|
+
|
|
145
|
+
Bundle bundle = new Bundle();
|
|
146
|
+
bundle.putString(KEY_SCENE_ID, getSceneId());
|
|
147
|
+
bundle.putString(KEY_ON, appear ? ON_COMPONENT_APPEAR : ON_COMPONENT_DISAPPEAR);
|
|
148
|
+
HBDEventEmitter.sendEvent(EVENT_NAVIGATION, Arguments.fromBundle(bundle));
|
|
134
149
|
}
|
|
135
150
|
|
|
136
151
|
@Override
|
|
137
152
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
138
153
|
super.onViewCreated(view, savedInstanceState);
|
|
139
154
|
if (!FragmentHelper.isHidden(this)) {
|
|
140
|
-
|
|
155
|
+
initReactTitleView();
|
|
141
156
|
}
|
|
142
157
|
getReactBridgeManager().addReactBridgeReloadListener(this);
|
|
143
158
|
}
|
|
144
|
-
|
|
159
|
+
|
|
145
160
|
@Override
|
|
146
161
|
public void onDestroyView() {
|
|
147
162
|
super.onDestroyView();
|
|
@@ -150,7 +165,7 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
150
165
|
}
|
|
151
166
|
unmountReactView();
|
|
152
167
|
}
|
|
153
|
-
|
|
168
|
+
|
|
154
169
|
@Override
|
|
155
170
|
public void onReload() {
|
|
156
171
|
unmountReactView();
|
|
@@ -160,16 +175,18 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
160
175
|
getReactBridgeManager().removeReactBridgeReloadListener(this);
|
|
161
176
|
|
|
162
177
|
ReactContext reactContext = getCurrentReactContext();
|
|
163
|
-
if (reactContext
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
reactRootView = null;
|
|
167
|
-
}
|
|
178
|
+
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
168
181
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
182
|
+
if (reactRootView != null) {
|
|
183
|
+
reactRootView.unmountReactApplication();
|
|
184
|
+
reactRootView = null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (reactTitleView != null) {
|
|
188
|
+
reactTitleView.unmountReactApplication();
|
|
189
|
+
reactTitleView = null;
|
|
173
190
|
}
|
|
174
191
|
}
|
|
175
192
|
|
|
@@ -186,11 +203,10 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
186
203
|
if (firstRenderCompleted) {
|
|
187
204
|
return;
|
|
188
205
|
}
|
|
189
|
-
|
|
190
206
|
firstRenderCompleted = true;
|
|
191
207
|
startPostponedEnterTransition();
|
|
192
208
|
|
|
193
|
-
if (
|
|
209
|
+
if (isViewReady() && isResumed()) {
|
|
194
210
|
sendViewAppearEvent(true);
|
|
195
211
|
reactRootView.addOnGlobalLayoutListener();
|
|
196
212
|
}
|
|
@@ -215,85 +231,113 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
215
231
|
@Override
|
|
216
232
|
public void setAppProperties(@NonNull Bundle props) {
|
|
217
233
|
super.setAppProperties(props);
|
|
218
|
-
if (reactRootView
|
|
234
|
+
if (reactRootView == null) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (isReactModuleRegisterCompleted()) {
|
|
219
239
|
this.reactRootView.setAppProperties(getProps());
|
|
220
240
|
}
|
|
221
241
|
}
|
|
222
242
|
|
|
223
|
-
private void
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (!shouldCreateReactView(context, reactRootView)) {
|
|
243
|
+
private void initReactRootView() {
|
|
244
|
+
if (reactRootView != null) {
|
|
227
245
|
return;
|
|
228
246
|
}
|
|
247
|
+
|
|
248
|
+
if (getContext() == null) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!isReactModuleRegisterCompleted()) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
reactRootView = createReactRootView();
|
|
257
|
+
reactRootView.startReactApplication(getReactInstanceManager(), getModuleName(), getProps());
|
|
258
|
+
}
|
|
229
259
|
|
|
230
|
-
|
|
260
|
+
@NonNull
|
|
261
|
+
private HBDReactRootView createReactRootView() {
|
|
262
|
+
HBDReactRootView reactRootView = new HBDReactRootView(getContext());
|
|
231
263
|
reactRootView.setShouldConsumeTouchEvent(!shouldPassThroughTouches());
|
|
232
|
-
this.reactRootView = reactRootView;
|
|
233
|
-
|
|
234
264
|
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
|
|
235
265
|
containerLayout.addView(reactRootView, layoutParams);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
reactRootView.startReactApplication(getReactInstanceManager(), moduleName, getProps());
|
|
266
|
+
return reactRootView;
|
|
239
267
|
}
|
|
240
268
|
|
|
241
|
-
private void
|
|
242
|
-
|
|
269
|
+
private void initReactTitleView() {
|
|
270
|
+
if (reactTitleView != null) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (getContext() == null) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
243
277
|
|
|
244
|
-
if (!
|
|
278
|
+
if (!isReactModuleRegisterCompleted()) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (getToolbar() == null) {
|
|
245
283
|
return;
|
|
246
284
|
}
|
|
247
285
|
|
|
248
286
|
Bundle titleItem = getOptions().getBundle("titleItem");
|
|
249
|
-
if (titleItem
|
|
250
|
-
|
|
251
|
-
if (moduleName != null) {
|
|
252
|
-
String fitting = titleItem.getString("layoutFitting");
|
|
253
|
-
boolean expanded = "expanded".equals(fitting);
|
|
254
|
-
reactTitleView = new HBDReactRootView(context);
|
|
255
|
-
Toolbar.LayoutParams layoutParams;
|
|
256
|
-
if (expanded) {
|
|
257
|
-
layoutParams = new Toolbar.LayoutParams(-1, -1, Gravity.CENTER);
|
|
258
|
-
} else {
|
|
259
|
-
layoutParams = new Toolbar.LayoutParams(-2, -2, Gravity.CENTER);
|
|
260
|
-
}
|
|
261
|
-
getToolbar().addView(reactTitleView, layoutParams);
|
|
262
|
-
reactTitleView.startReactApplication(getReactInstanceManager(), moduleName, getProps());
|
|
263
|
-
}
|
|
287
|
+
if (titleItem == null) {
|
|
288
|
+
return;
|
|
264
289
|
}
|
|
265
|
-
}
|
|
266
290
|
|
|
267
|
-
|
|
268
|
-
|
|
291
|
+
String moduleName = titleItem.getString("moduleName");
|
|
292
|
+
if (moduleName == null) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
String fitting = titleItem.getString("layoutFitting");
|
|
297
|
+
boolean expanded = "expanded".equals(fitting);
|
|
298
|
+
reactTitleView = createReactTitleView(expanded);
|
|
299
|
+
reactTitleView.startReactApplication(getReactInstanceManager(), moduleName, getProps());
|
|
269
300
|
}
|
|
270
301
|
|
|
271
|
-
boolean
|
|
272
|
-
|
|
302
|
+
private HBDReactRootView createReactTitleView( boolean expanded) {
|
|
303
|
+
Toolbar.LayoutParams layoutParams = createTitleLayoutParams(expanded);
|
|
304
|
+
HBDReactRootView reactTitleView = new HBDReactRootView(getContext());
|
|
305
|
+
Toolbar toolbar = getToolbar();
|
|
306
|
+
toolbar.addView(reactTitleView, layoutParams);
|
|
307
|
+
return reactTitleView;
|
|
273
308
|
}
|
|
274
309
|
|
|
310
|
+
@NonNull
|
|
311
|
+
private Toolbar.LayoutParams createTitleLayoutParams(boolean expanded) {
|
|
312
|
+
if (expanded) {
|
|
313
|
+
return new Toolbar.LayoutParams(MATCH_PARENT, MATCH_PARENT, Gravity.CENTER);
|
|
314
|
+
}
|
|
315
|
+
return new Toolbar.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, Gravity.CENTER);
|
|
316
|
+
}
|
|
317
|
+
|
|
275
318
|
@Override
|
|
276
319
|
public void postponeEnterTransition() {
|
|
277
320
|
super.postponeEnterTransition();
|
|
278
|
-
if (getActivity()
|
|
279
|
-
|
|
321
|
+
if (getActivity() == null) {
|
|
322
|
+
return;
|
|
280
323
|
}
|
|
324
|
+
getActivity().supportPostponeEnterTransition();
|
|
281
325
|
}
|
|
282
326
|
|
|
283
327
|
@Override
|
|
284
328
|
public void startPostponedEnterTransition() {
|
|
285
329
|
super.startPostponedEnterTransition();
|
|
286
|
-
if (getActivity()
|
|
287
|
-
|
|
330
|
+
if (getActivity() == null) {
|
|
331
|
+
return;
|
|
288
332
|
}
|
|
333
|
+
getActivity().supportStartPostponedEnterTransition();
|
|
289
334
|
}
|
|
290
335
|
|
|
291
336
|
@Override
|
|
292
337
|
protected int preferredNavigationBarColor() {
|
|
293
|
-
if (mStyle.getNavigationBarColor()
|
|
294
|
-
return mStyle.getNavigationBarColor();
|
|
295
|
-
} else {
|
|
338
|
+
if (mStyle.getNavigationBarColor() == Style.INVALID_COLOR) {
|
|
296
339
|
return mStyle.getScreenBackgroundColor();
|
|
297
340
|
}
|
|
341
|
+
return mStyle.getNavigationBarColor();
|
|
298
342
|
}
|
|
299
343
|
}
|