hybrid-navigation 2.10.0 → 2.11.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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +28 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/Navigator.java +2 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +28 -14
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +2 -2
- package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.m +3 -54
- package/ios/HybridNavigation/HybridNavigation.h +0 -1
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +19 -12
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.h +0 -2
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +0 -9
- package/ios/HybridNavigation/ViewController/HBDViewController.m +30 -0
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +1 -16
- package/lib/Navigator.js +0 -1
- package/lib/ReactRegistry.d.ts +2 -4
- package/package.json +1 -1
- package/src/Navigator.ts +0 -1
- package/src/ReactRegistry.tsx +5 -7
- 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 +0 -1
- package/android/.idea/gradle.xml +0 -16
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.iml +0 -18
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
- package/ios/HybridNavigation/ViewController/HBDModalViewController.h +0 -121
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +0 -514
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcuserdata/listen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/HybridNavigation.xcodeproj/xcuserdata/listen.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
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:12.
|
|
36
|
+
api 'io.github.listenzz:AndroidNavigation:12.5.0'
|
|
37
37
|
}
|
|
@@ -5,12 +5,10 @@ import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
|
5
5
|
import static com.reactnative.hybridnavigation.Constants.ARG_PROPS;
|
|
6
6
|
import static com.reactnative.hybridnavigation.Constants.ARG_SCENE_ID;
|
|
7
7
|
|
|
8
|
-
import android.app.Dialog;
|
|
9
8
|
import android.graphics.Color;
|
|
10
9
|
import android.graphics.drawable.ColorDrawable;
|
|
11
10
|
import android.os.Bundle;
|
|
12
11
|
import android.view.View;
|
|
13
|
-
import android.view.Window;
|
|
14
12
|
|
|
15
13
|
import androidx.annotation.CallSuper;
|
|
16
14
|
import androidx.annotation.NonNull;
|
|
@@ -23,6 +21,7 @@ import com.navigation.androidx.AwesomeFragment;
|
|
|
23
21
|
import com.navigation.androidx.AwesomeToolbar;
|
|
24
22
|
import com.navigation.androidx.BarStyle;
|
|
25
23
|
import com.navigation.androidx.FragmentHelper;
|
|
24
|
+
import com.navigation.androidx.PresentationStyle;
|
|
26
25
|
import com.navigation.androidx.Style;
|
|
27
26
|
import com.navigation.androidx.SystemUI;
|
|
28
27
|
import com.navigation.androidx.TabBarItem;
|
|
@@ -96,33 +95,46 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
96
95
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
97
96
|
super.onViewCreated(view, savedInstanceState);
|
|
98
97
|
garden.setupToolbar();
|
|
98
|
+
if (getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
99
|
+
setModalBackground(view);
|
|
100
|
+
}
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
@NonNull
|
|
102
|
-
@Override
|
|
103
|
-
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
104
|
-
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
|
105
|
-
Window window = dialog.getWindow();
|
|
106
|
-
|
|
103
|
+
private void setModalBackground(@NonNull View view) {
|
|
107
104
|
if (forceTransparentDialogWindow()) {
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
view.setBackground(new ColorDrawable(Color.TRANSPARENT));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
int color = mStyle.getScreenBackgroundColor();
|
|
109
|
+
if (Color.alpha(color) < 255) {
|
|
110
|
+
view.setBackground(new ColorDrawable(color));
|
|
111
|
+
} else {
|
|
112
|
+
view.setBackground(new ColorDrawable(Color.parseColor("#77000000")));
|
|
110
113
|
}
|
|
111
|
-
|
|
112
|
-
return dialog;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
@NonNull
|
|
116
117
|
@Override
|
|
117
118
|
protected BarStyle preferredStatusBarStyle() {
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
return BarStyle.DarkContent;
|
|
121
|
-
}
|
|
119
|
+
if (forceTransparentDialogWindow() && SystemUI.isStatusBarStyleDark(requireActivity().getWindow())) {
|
|
120
|
+
return BarStyle.DarkContent;
|
|
122
121
|
}
|
|
122
|
+
|
|
123
|
+
if (getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
124
|
+
return BarStyle.LightContent;
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
return super.preferredStatusBarStyle();
|
|
124
128
|
}
|
|
125
129
|
|
|
130
|
+
@Override
|
|
131
|
+
protected boolean preferredNavigationBarHidden() {
|
|
132
|
+
if (getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
133
|
+
return SystemUI.isNavigationBarHidden(requireActivity().getWindow());
|
|
134
|
+
}
|
|
135
|
+
return super.preferredNavigationBarHidden();
|
|
136
|
+
}
|
|
137
|
+
|
|
126
138
|
public Garden getGarden() {
|
|
127
139
|
return garden;
|
|
128
140
|
}
|
|
@@ -226,7 +226,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
226
226
|
private String findSceneIdByModuleName(@NonNull String moduleName, AwesomeFragment parent) {
|
|
227
227
|
String sceneId = findSceneIdFromParent(moduleName, parent);
|
|
228
228
|
if (sceneId == null) {
|
|
229
|
-
return findSceneIdFromChildren(moduleName, parent.
|
|
229
|
+
return findSceneIdFromChildren(moduleName, parent.getChildAwesomeFragments());
|
|
230
230
|
}
|
|
231
231
|
return sceneId;
|
|
232
232
|
}
|
|
@@ -87,7 +87,7 @@ public class ReactTabBarFragment extends TabBarFragment {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
private void improveTransitionForReact(AwesomeFragment current, AwesomeFragment previous) {
|
|
90
|
-
List<AwesomeFragment> children =
|
|
90
|
+
List<AwesomeFragment> children = getChildAwesomeFragments();
|
|
91
91
|
if (children.indexOf(current) > children.indexOf(previous)) {
|
|
92
92
|
current.setAnimation(FadeShort);
|
|
93
93
|
previous.setAnimation(DelayShort);
|
|
@@ -112,7 +112,7 @@ public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.R
|
|
|
112
112
|
private ArrayList<Bundle> createTabs(@NonNull List<TabBarItem> tabBarItems) {
|
|
113
113
|
ArrayList<Bundle> tabs = new ArrayList<>();
|
|
114
114
|
Context context = tabBarFragment.requireContext();
|
|
115
|
-
List<AwesomeFragment> children = tabBarFragment.
|
|
115
|
+
List<AwesomeFragment> children = tabBarFragment.getChildAwesomeFragments();
|
|
116
116
|
for (int i = 0, size = tabBarItems.size(); i < size; i++) {
|
|
117
117
|
TabBarItem tabBarItem = tabBarItems.get(i);
|
|
118
118
|
Bundle tab = new Bundle();
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java
CHANGED
|
@@ -114,7 +114,7 @@ public class DrawerNavigator implements Navigator {
|
|
|
114
114
|
@NonNull
|
|
115
115
|
private ArrayList<Bundle> buildChildrenGraph(DrawerFragment drawer) {
|
|
116
116
|
ArrayList<Bundle> children = new ArrayList<>();
|
|
117
|
-
List<AwesomeFragment> fragments = drawer.
|
|
117
|
+
List<AwesomeFragment> fragments = drawer.getChildAwesomeFragments();
|
|
118
118
|
for (int i = 0; i < fragments.size(); i++) {
|
|
119
119
|
AwesomeFragment child = fragments.get(i);
|
|
120
120
|
Bundle graph = getReactBridgeManager().buildRouteGraph(child);
|
|
@@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
|
|
|
8
8
|
import com.facebook.react.bridge.Promise;
|
|
9
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
10
10
|
import com.navigation.androidx.AwesomeFragment;
|
|
11
|
+
import com.navigation.androidx.PresentationStyle;
|
|
11
12
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
12
13
|
|
|
13
14
|
import java.util.List;
|
|
@@ -20,7 +21,7 @@ public interface Navigator {
|
|
|
20
21
|
|
|
21
22
|
class Util {
|
|
22
23
|
public static String getMode(@NonNull AwesomeFragment fragment) {
|
|
23
|
-
if (fragment.
|
|
24
|
+
if (fragment.getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
24
25
|
return MODE_MODAL;
|
|
25
26
|
} else if (fragment.getPresentingFragment() != null) {
|
|
26
27
|
return MODE_PRESENT;
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java
CHANGED
|
@@ -10,6 +10,8 @@ import com.facebook.react.bridge.Promise;
|
|
|
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.PresentationStyle;
|
|
14
|
+
import com.navigation.androidx.TransitionAnimation;
|
|
13
15
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
14
16
|
import com.reactnative.hybridnavigation.ReactBridgeManager;
|
|
15
17
|
import com.reactnative.hybridnavigation.ReactStackFragment;
|
|
@@ -105,7 +107,7 @@ public class ScreenNavigator implements Navigator {
|
|
|
105
107
|
handleShowModal(target, extras, promise);
|
|
106
108
|
break;
|
|
107
109
|
case "hideModal":
|
|
108
|
-
target
|
|
110
|
+
handleHideModal(target, promise);
|
|
109
111
|
break;
|
|
110
112
|
case "presentLayout":
|
|
111
113
|
handlePresentLayout(target, extras, promise);
|
|
@@ -113,39 +115,51 @@ public class ScreenNavigator implements Navigator {
|
|
|
113
115
|
case "showModalLayout":
|
|
114
116
|
handleShowModalLayout(target, extras, promise);
|
|
115
117
|
break;
|
|
118
|
+
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
private void handleShowModalLayout(@NonNull AwesomeFragment
|
|
122
|
+
private void handleShowModalLayout(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Promise promise) {
|
|
120
123
|
ReadableMap layout = extras.getMap("layout");
|
|
121
|
-
AwesomeFragment
|
|
122
|
-
if (
|
|
124
|
+
AwesomeFragment presented = getReactBridgeManager().createFragment(layout);
|
|
125
|
+
if (presented == null) {
|
|
123
126
|
promise.resolve(false);
|
|
124
127
|
return;
|
|
125
128
|
}
|
|
129
|
+
presented.setPresentationStyle(PresentationStyle.OverFullScreen);
|
|
126
130
|
int requestCode = extras.getInt("requestCode");
|
|
127
|
-
|
|
131
|
+
presenting.presentFragment(presented, requestCode, TransitionAnimation.None, () -> promise.resolve(true));
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
private void handlePresentLayout(@NonNull AwesomeFragment
|
|
134
|
+
private void handlePresentLayout(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Promise promise) {
|
|
131
135
|
ReadableMap layout = extras.getMap("layout");
|
|
132
|
-
AwesomeFragment
|
|
133
|
-
if (
|
|
136
|
+
AwesomeFragment presented = getReactBridgeManager().createFragment(layout);
|
|
137
|
+
if (presented == null) {
|
|
134
138
|
promise.resolve(false);
|
|
135
139
|
return;
|
|
136
140
|
}
|
|
137
141
|
int requestCode = extras.getInt("requestCode");
|
|
138
|
-
|
|
142
|
+
presenting.presentFragment(presented, requestCode, () -> promise.resolve(true));
|
|
139
143
|
}
|
|
140
144
|
|
|
141
|
-
private void handleShowModal(@NonNull AwesomeFragment
|
|
142
|
-
AwesomeFragment
|
|
143
|
-
if (
|
|
145
|
+
private void handleShowModal(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Promise promise) {
|
|
146
|
+
AwesomeFragment presented = createFragmentWithExtras(extras);
|
|
147
|
+
if (presented == null) {
|
|
144
148
|
promise.resolve(false);
|
|
145
149
|
return;
|
|
146
150
|
}
|
|
151
|
+
presented.setPresentationStyle(PresentationStyle.OverFullScreen);
|
|
147
152
|
int requestCode = extras.getInt("requestCode");
|
|
148
|
-
|
|
153
|
+
presenting.presentFragment(presented, requestCode, TransitionAnimation.None, () -> promise.resolve(true));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private void handleHideModal(@NonNull AwesomeFragment target, @NonNull Promise promise) {
|
|
157
|
+
AwesomeFragment presenting = target.getPresentingFragment();
|
|
158
|
+
if (presenting == null) {
|
|
159
|
+
target.dismissFragment(TransitionAnimation.None, () -> promise.resolve(true));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
presenting.dismissFragment(TransitionAnimation.None, () -> promise.resolve(true));
|
|
149
163
|
}
|
|
150
164
|
|
|
151
165
|
private void handleDismiss(@NonNull AwesomeFragment target, @NonNull Promise promise) {
|
|
@@ -168,7 +182,7 @@ public class ScreenNavigator implements Navigator {
|
|
|
168
182
|
stackFragment.setRootFragment(fragment);
|
|
169
183
|
target.presentFragment(stackFragment, requestCode, () -> promise.resolve(true));
|
|
170
184
|
}
|
|
171
|
-
|
|
185
|
+
|
|
172
186
|
private AwesomeFragment createFragmentWithExtras(@NonNull ReadableMap extras) {
|
|
173
187
|
if (!extras.hasKey("moduleName")) {
|
|
174
188
|
return null;
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java
CHANGED
|
@@ -92,7 +92,7 @@ public class StackNavigator implements Navigator {
|
|
|
92
92
|
@NonNull
|
|
93
93
|
private ArrayList<Bundle> buildChildrenGraph(StackFragment stack) {
|
|
94
94
|
ArrayList<Bundle> children = new ArrayList<>();
|
|
95
|
-
List<AwesomeFragment> fragments = stack.
|
|
95
|
+
List<AwesomeFragment> fragments = stack.getChildAwesomeFragments();
|
|
96
96
|
for (int i = 0; i < fragments.size(); i++) {
|
|
97
97
|
AwesomeFragment child = fragments.get(i);
|
|
98
98
|
Bundle graph = getReactBridgeManager().buildRouteGraph(child);
|
|
@@ -133,7 +133,7 @@ public class TabNavigator implements Navigator {
|
|
|
133
133
|
@NonNull
|
|
134
134
|
private ArrayList<Bundle> buildChildrenGraph(TabBarFragment tabs) {
|
|
135
135
|
ArrayList<Bundle> children = new ArrayList<>();
|
|
136
|
-
List<AwesomeFragment> fragments = tabs.
|
|
136
|
+
List<AwesomeFragment> fragments = tabs.getChildAwesomeFragments();
|
|
137
137
|
for (int i = 0; i < fragments.size(); i++) {
|
|
138
138
|
AwesomeFragment child = fragments.get(i);
|
|
139
139
|
Bundle graph = getReactBridgeManager().buildRouteGraph(child);
|
|
@@ -205,7 +205,7 @@ public class TabNavigator implements Navigator {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
StackFragment stackFragment = tabBarFragment.getSelectedFragment().getStackFragment();
|
|
208
|
-
if (stackFragment != null && stackFragment.
|
|
208
|
+
if (stackFragment != null && stackFragment.getChildAwesomeFragments().size() > 1) {
|
|
209
209
|
stackFragment.popToRootFragment(false);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
#import <React/RCTLog.h>
|
|
11
11
|
#import "HBDUtils.h"
|
|
12
12
|
#import "HBDReactViewController.h"
|
|
13
|
-
#import "HBDModalViewController.h"
|
|
14
13
|
#import "HBDNavigatorRegistry.h"
|
|
15
14
|
#import "HBDEventEmitter.h"
|
|
16
15
|
|
|
@@ -69,16 +68,6 @@ const NSInteger ResultCancel = 0;
|
|
|
69
68
|
self.viewHierarchyReady = NO;
|
|
70
69
|
self.reactModuleRegisterCompleted = NO;
|
|
71
70
|
|
|
72
|
-
UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
|
|
73
|
-
for (NSUInteger i = application.windows.count; i > 0; i--) {
|
|
74
|
-
UIWindow *window = application.windows[i - 1];
|
|
75
|
-
UIViewController *controller = window.rootViewController;
|
|
76
|
-
if ([controller isKindOfClass:[HBDModalViewController class]]) {
|
|
77
|
-
HBDModalViewController *modal = (HBDModalViewController *) controller;
|
|
78
|
-
[modal.contentViewController hbd_hideViewControllerAnimated:NO completion:nil];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
71
|
UIWindow *mainWindow = [self mainWindow];
|
|
83
72
|
UIViewController *presentedViewController = mainWindow.rootViewController.presentedViewController;
|
|
84
73
|
if (presentedViewController && !presentedViewController.isBeingDismissed) {
|
|
@@ -196,24 +185,8 @@ const NSInteger ResultCancel = 0;
|
|
|
196
185
|
if (!self.viewHierarchyReady) {
|
|
197
186
|
return nil;
|
|
198
187
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
UIViewController *vc = nil;
|
|
202
|
-
for (UIWindow *window in application.windows) {
|
|
203
|
-
if ([window isKindOfClass:[HBDModalWindow class]]) {
|
|
204
|
-
HBDModalViewController *modal = (HBDModalViewController *) window.rootViewController;
|
|
205
|
-
if (!modal || modal.isBeingHidden) {
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
vc = [self controllerForSceneId:sceneId withController:window.rootViewController];
|
|
211
|
-
|
|
212
|
-
if (vc) {
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return vc;
|
|
188
|
+
UIWindow *window = [self mainWindow];
|
|
189
|
+
return [self controllerForSceneId:sceneId withController:window.rootViewController];
|
|
217
190
|
}
|
|
218
191
|
|
|
219
192
|
- (UIViewController *)controllerForSceneId:(NSString *)sceneId withController:(UIViewController *)controller {
|
|
@@ -223,11 +196,6 @@ const NSInteger ResultCancel = 0;
|
|
|
223
196
|
target = controller;
|
|
224
197
|
}
|
|
225
198
|
|
|
226
|
-
if (!target && [controller isKindOfClass:[HBDModalViewController class]]) {
|
|
227
|
-
HBDModalViewController *modal = (HBDModalViewController *) controller;
|
|
228
|
-
target = [self controllerForSceneId:sceneId withController:modal.contentViewController];
|
|
229
|
-
}
|
|
230
|
-
|
|
231
199
|
if (!target) {
|
|
232
200
|
UIViewController *presentedController = controller.presentedViewController;
|
|
233
201
|
if (presentedController && ![presentedController isBeingDismissed]) {
|
|
@@ -254,16 +222,7 @@ const NSInteger ResultCancel = 0;
|
|
|
254
222
|
|
|
255
223
|
- (void)setRootViewController:(UIViewController *)rootViewController withTag:(NSNumber *)tag {
|
|
256
224
|
[HBDEventEmitter sendEvent:EVENT_WILL_SET_ROOT data:@{}];
|
|
257
|
-
|
|
258
|
-
for (NSUInteger i = application.windows.count; i > 0; i--) {
|
|
259
|
-
UIWindow *window = application.windows[i - 1];
|
|
260
|
-
UIViewController *controller = window.rootViewController;
|
|
261
|
-
if ([controller isKindOfClass:[HBDModalViewController class]]) {
|
|
262
|
-
HBDModalViewController *modal = (HBDModalViewController *) controller;
|
|
263
|
-
[modal.contentViewController hbd_hideViewControllerAnimated:NO completion:nil];
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
225
|
+
|
|
267
226
|
UIWindow *mainWindow = [self mainWindow];
|
|
268
227
|
UIViewController *presentedViewController = mainWindow.rootViewController.presentedViewController;
|
|
269
228
|
if (presentedViewController && !presentedViewController.isBeingDismissed) {
|
|
@@ -309,11 +268,6 @@ const NSInteger ResultCancel = 0;
|
|
|
309
268
|
}
|
|
310
269
|
|
|
311
270
|
- (HBDViewController *)primaryViewControllerWithViewController:(UIViewController *)vc {
|
|
312
|
-
HBDModalViewController *modal = vc.hbd_popupViewController.hbd_modalViewController;
|
|
313
|
-
if (modal && !modal.isBeingHidden) {
|
|
314
|
-
return [self primaryViewControllerWithViewController:modal.contentViewController];
|
|
315
|
-
}
|
|
316
|
-
|
|
317
271
|
UIViewController *presented = vc.presentedViewController;
|
|
318
272
|
if (presented && !presented.beingDismissed && ![presented isKindOfClass:[UIAlertController class]]) {
|
|
319
273
|
return [self primaryViewControllerWithViewController:presented];
|
|
@@ -380,11 +334,6 @@ const NSInteger ResultCancel = 0;
|
|
|
380
334
|
|
|
381
335
|
- (NSMutableDictionary *)buildRouteGraphWithViewController:(UIViewController *)vc {
|
|
382
336
|
NSMutableDictionary *m = nil;
|
|
383
|
-
HBDModalViewController *modal = vc.hbd_popupViewController.hbd_modalViewController;
|
|
384
|
-
if (modal && !modal.isBeingHidden) {
|
|
385
|
-
m = [[self buildRouteGraphWithViewController:modal.contentViewController] mutableCopy];
|
|
386
|
-
}
|
|
387
|
-
|
|
388
337
|
NSMutableDictionary *p = nil;
|
|
389
338
|
UIViewController *presented = vc.presentedViewController;
|
|
390
339
|
if (presented && presented.presentingViewController == vc && !presented.beingDismissed && ![presented isKindOfClass:[UIAlertController class]]) {
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
#import "HBDScreenNavigator.h"
|
|
10
10
|
#import "HBDReactBridgeManager.h"
|
|
11
11
|
#import "HBDNavigationController.h"
|
|
12
|
-
#import "HBDModalViewController.h"
|
|
13
12
|
#import <React/RCTLog.h>
|
|
14
13
|
|
|
15
14
|
@implementation HBDScreenNavigator
|
|
@@ -47,10 +46,7 @@
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
- (HBDViewController *)primaryViewControllerWithViewController:(UIViewController *)vc {
|
|
50
|
-
if ([vc isKindOfClass:[
|
|
51
|
-
HBDModalViewController *modal = (HBDModalViewController *) vc;
|
|
52
|
-
return [[HBDReactBridgeManager get] primaryViewControllerWithViewController:modal.contentViewController];
|
|
53
|
-
} else if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
49
|
+
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
54
50
|
return (HBDViewController *) vc;
|
|
55
51
|
}
|
|
56
52
|
return nil;
|
|
@@ -90,13 +86,22 @@
|
|
|
90
86
|
} else if ([action isEqualToString:@"showModal"]) {
|
|
91
87
|
viewController = [self createViewControllerWithExtras:extras];
|
|
92
88
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
90
|
+
[viewController setRequestCode:requestCode];
|
|
91
|
+
[target presentViewController:viewController animated:NO completion:^{
|
|
92
|
+
resolve(@(YES));
|
|
95
93
|
}];
|
|
96
94
|
} else if ([action isEqualToString:@"hideModal"]) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
UIViewController *presenting = target.presentingViewController;
|
|
96
|
+
if (presenting) {
|
|
97
|
+
[presenting dismissViewControllerAnimated:NO completion:^{
|
|
98
|
+
resolve(@(YES));
|
|
99
|
+
}];
|
|
100
|
+
} else {
|
|
101
|
+
[target dismissViewControllerAnimated:NO completion:^{
|
|
102
|
+
resolve(@(YES));
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
100
105
|
} else if ([action isEqualToString:@"presentLayout"]) {
|
|
101
106
|
NSDictionary *layout = extras[@"layout"];
|
|
102
107
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
@@ -110,8 +115,10 @@
|
|
|
110
115
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
111
116
|
NSDictionary *layout = extras[@"layout"];
|
|
112
117
|
viewController = [[HBDReactBridgeManager get] controllerWithLayout:layout];
|
|
113
|
-
|
|
114
|
-
|
|
118
|
+
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
119
|
+
[viewController setRequestCode:requestCode];
|
|
120
|
+
[target presentViewController:viewController animated:NO completion:^{
|
|
121
|
+
resolve(@(YES));
|
|
115
122
|
}];
|
|
116
123
|
}
|
|
117
124
|
}
|
|
@@ -9,15 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
@implementation HBDViewController (Garden)
|
|
11
11
|
|
|
12
|
-
- (BOOL)forceTransparentDialogWindow {
|
|
13
|
-
id obj = objc_getAssociatedObject(self, _cmd);
|
|
14
|
-
return obj ? [obj boolValue] : NO;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
- (void)setForceTransparentDialogWindow:(BOOL)transparent {
|
|
18
|
-
objc_setAssociatedObject(self, @selector(forceTransparentDialogWindow), @(transparent), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
- (void)setLeftBarButtonItem:(NSDictionary *)item {
|
|
22
13
|
if (self.hbd_barHidden) {
|
|
23
14
|
return;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
19
19
|
@property(nonatomic, copy, readwrite) NSDictionary *options;
|
|
20
|
+
@property(nonatomic, assign) BOOL forceTransparentDialogWindow;
|
|
20
21
|
|
|
21
22
|
@end
|
|
22
23
|
|
|
@@ -99,6 +100,15 @@
|
|
|
99
100
|
|
|
100
101
|
- (void)viewDidLoad {
|
|
101
102
|
[super viewDidLoad];
|
|
103
|
+
[self setScreenBackgroundColor];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (void)setScreenBackgroundColor {
|
|
107
|
+
if (self.modalPresentationStyle == UIModalPresentationOverFullScreen) {
|
|
108
|
+
[self setModalBackgroundColor];
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
102
112
|
NSString *screenColor = self.options[@"screenBackgroundColor"];
|
|
103
113
|
if (screenColor) {
|
|
104
114
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
@@ -107,6 +117,26 @@
|
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
|
|
120
|
+
- (void)setModalBackgroundColor {
|
|
121
|
+
if (self.forceTransparentDialogWindow) {
|
|
122
|
+
self.view.backgroundColor = UIColor.clearColor;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
self.view.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.5];
|
|
127
|
+
|
|
128
|
+
NSString *screenColor = self.options[@"screenBackgroundColor"];
|
|
129
|
+
|
|
130
|
+
if (!screenColor) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
UIColor *color = [HBDUtils colorWithHexString:screenColor];
|
|
135
|
+
if (colorHasAlphaComponent(color)) {
|
|
136
|
+
self.view.backgroundColor = color;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
110
140
|
- (void)applyTabBarOptions:(NSDictionary *)options {
|
|
111
141
|
NSDictionary *tabItem = options[@"tabItem"];
|
|
112
142
|
if (tabItem) {
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
#import "UITabBar+Badge.h"
|
|
14
14
|
|
|
15
15
|
#import "HBDNavigationController.h"
|
|
16
|
-
#import "HBDModalViewController.h"
|
|
17
16
|
#import "HBDUtils.h"
|
|
18
17
|
#import "GlobalStyle.h"
|
|
19
18
|
|
|
@@ -57,20 +56,6 @@
|
|
|
57
56
|
RCTLogWarn(@"[Navigator] Can't present since the scene had present another scene already.");
|
|
58
57
|
return NO;
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
|
|
62
|
-
for (NSUInteger i = application.windows.count; i > 0; i--) {
|
|
63
|
-
UIWindow *window = application.windows[i - 1];
|
|
64
|
-
UIViewController *viewController = window.rootViewController;
|
|
65
|
-
if ([viewController isKindOfClass:[HBDModalViewController class]]) {
|
|
66
|
-
HBDModalViewController *modal = (HBDModalViewController *) viewController;
|
|
67
|
-
if (!modal.beingHidden) {
|
|
68
|
-
RCTLogWarn(@"[Navigator] Can't present a scene over a modal.");
|
|
69
|
-
return NO;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
59
|
return YES;
|
|
75
60
|
}
|
|
76
61
|
|
|
@@ -412,7 +397,7 @@
|
|
|
412
397
|
}
|
|
413
398
|
|
|
414
399
|
- (NSString *)hbd_mode {
|
|
415
|
-
if (self.
|
|
400
|
+
if (self.modalPresentationStyle == UIModalPresentationOverFullScreen) {
|
|
416
401
|
return @"modal";
|
|
417
402
|
} else if (self.presentingViewController != nil) {
|
|
418
403
|
return @"present";
|
package/lib/Navigator.js
CHANGED
package/lib/ReactRegistry.d.ts
CHANGED
|
@@ -9,14 +9,12 @@ export interface InjectedProps {
|
|
|
9
9
|
garden: Garden;
|
|
10
10
|
sceneId: string;
|
|
11
11
|
}
|
|
12
|
-
declare type ComponentType = ReturnType<ComponentProvider>;
|
|
13
12
|
export declare const NavigationContext: React.Context<any>;
|
|
14
|
-
export declare type HOC = (WrappedComponent: ComponentType) => ComponentType
|
|
13
|
+
export declare type HOC = (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>;
|
|
15
14
|
export declare class ReactRegistry {
|
|
16
15
|
static registerEnded: boolean;
|
|
17
16
|
static startRegisterComponent(hoc?: HOC): void;
|
|
18
17
|
static endRegisterComponent(): void;
|
|
19
18
|
static registerComponent(appKey: string, getComponentFunc: ComponentProvider, routeConfig?: RouteConfig): void;
|
|
20
19
|
}
|
|
21
|
-
export declare function withNavigationItem(item: NavigationItem): (WrappedComponent: ComponentType) => ComponentType
|
|
22
|
-
export {};
|
|
20
|
+
export declare function withNavigationItem(item: NavigationItem): (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>;
|
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.
|
|
4
|
+
"version": "2.11.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
package/src/Navigator.ts
CHANGED
package/src/ReactRegistry.tsx
CHANGED
|
@@ -26,17 +26,15 @@ interface Props {
|
|
|
26
26
|
sceneId: string
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function getDisplayName(WrappedComponent: ComponentType) {
|
|
29
|
+
function getDisplayName(WrappedComponent: React.ComponentType<any>) {
|
|
32
30
|
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export const NavigationContext = createContext<any>(null)
|
|
36
34
|
|
|
37
35
|
function withNavigator(moduleName: string) {
|
|
38
|
-
return function (WrappedComponent: ComponentType) {
|
|
39
|
-
const FC = React.forwardRef((props: Props, ref: React.Ref<ComponentType
|
|
36
|
+
return function (WrappedComponent: React.ComponentType<any>) {
|
|
37
|
+
const FC = React.forwardRef((props: Props, ref: React.Ref<React.ComponentType<any>>) => {
|
|
40
38
|
const { sceneId } = props
|
|
41
39
|
|
|
42
40
|
const navigator = Navigator.of(sceneId)
|
|
@@ -87,7 +85,7 @@ function withNavigator(moduleName: string) {
|
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
|
|
90
|
-
export type HOC = (WrappedComponent: ComponentType) => ComponentType
|
|
88
|
+
export type HOC = (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>
|
|
91
89
|
let wrap: HOC | undefined
|
|
92
90
|
|
|
93
91
|
export class ReactRegistry {
|
|
@@ -128,7 +126,7 @@ export class ReactRegistry {
|
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
export function withNavigationItem(item: NavigationItem) {
|
|
131
|
-
return function (WrappedComponent: ComponentType): ComponentType {
|
|
129
|
+
return function (WrappedComponent: React.ComponentType<any>): React.ComponentType<any> {
|
|
132
130
|
let navigationItem = (WrappedComponent as any).navigationItem
|
|
133
131
|
if (navigationItem) {
|
|
134
132
|
;(WrappedComponent as any).navigationItem = { ...navigationItem, ...item }
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|