hybrid-navigation 2.10.2 → 2.11.2
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 -19
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +1 -8
- 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/package.json +1 -1
- package/ios/HybridNavigation/ViewController/HBDModalViewController.h +0 -121
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +0 -514
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.3'
|
|
37
37
|
}
|
|
@@ -5,12 +5,9 @@ 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
|
-
import android.graphics.drawable.ColorDrawable;
|
|
11
9
|
import android.os.Bundle;
|
|
12
10
|
import android.view.View;
|
|
13
|
-
import android.view.Window;
|
|
14
11
|
|
|
15
12
|
import androidx.annotation.CallSuper;
|
|
16
13
|
import androidx.annotation.NonNull;
|
|
@@ -23,6 +20,7 @@ import com.navigation.androidx.AwesomeFragment;
|
|
|
23
20
|
import com.navigation.androidx.AwesomeToolbar;
|
|
24
21
|
import com.navigation.androidx.BarStyle;
|
|
25
22
|
import com.navigation.androidx.FragmentHelper;
|
|
23
|
+
import com.navigation.androidx.PresentationStyle;
|
|
26
24
|
import com.navigation.androidx.Style;
|
|
27
25
|
import com.navigation.androidx.SystemUI;
|
|
28
26
|
import com.navigation.androidx.TabBarItem;
|
|
@@ -90,6 +88,20 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
90
88
|
protected void onCustomStyle(@NonNull Style style) {
|
|
91
89
|
super.onCustomStyle(style);
|
|
92
90
|
garden = new Garden(this, style);
|
|
91
|
+
if (getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
92
|
+
setBackgroundForModal(style);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private void setBackgroundForModal(@NonNull Style style) {
|
|
97
|
+
if (forceTransparentDialogWindow()) {
|
|
98
|
+
style.setScreenBackgroundColor(Color.TRANSPARENT);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
int color = mStyle.getScreenBackgroundColor();
|
|
102
|
+
if (Color.alpha(color) == 255) {
|
|
103
|
+
style.setScreenBackgroundColor(Color.parseColor("#77000000"));
|
|
104
|
+
}
|
|
93
105
|
}
|
|
94
106
|
|
|
95
107
|
@Override
|
|
@@ -97,30 +109,27 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
97
109
|
super.onViewCreated(view, savedInstanceState);
|
|
98
110
|
garden.setupToolbar();
|
|
99
111
|
}
|
|
100
|
-
|
|
112
|
+
|
|
101
113
|
@NonNull
|
|
102
114
|
@Override
|
|
103
|
-
|
|
104
|
-
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
|
105
|
-
Window window = dialog.getWindow();
|
|
106
|
-
|
|
115
|
+
protected BarStyle preferredStatusBarStyle() {
|
|
107
116
|
if (forceTransparentDialogWindow()) {
|
|
108
|
-
|
|
109
|
-
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
117
|
+
return SystemUI.activityNavigationBarStyle(requireActivity());
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
|
|
120
|
+
if (getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
121
|
+
return BarStyle.LightContent;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return super.preferredStatusBarStyle();
|
|
113
125
|
}
|
|
114
126
|
|
|
115
|
-
@NonNull
|
|
116
127
|
@Override
|
|
117
|
-
protected
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
return BarStyle.DarkContent;
|
|
121
|
-
}
|
|
128
|
+
protected boolean preferredNavigationBarHidden() {
|
|
129
|
+
if (getPresentationStyle() == PresentationStyle.OverFullScreen) {
|
|
130
|
+
return SystemUI.isNavigationBarHidden(requireActivity().getWindow());
|
|
122
131
|
}
|
|
123
|
-
return super.
|
|
132
|
+
return super.preferredNavigationBarHidden();
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
public Garden getGarden() {
|
|
@@ -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
|
}
|
|
@@ -332,12 +332,5 @@ public class ReactFragment extends HybridFragment implements ReactRootViewHolder
|
|
|
332
332
|
}
|
|
333
333
|
getActivity().supportStartPostponedEnterTransition();
|
|
334
334
|
}
|
|
335
|
-
|
|
336
|
-
@Override
|
|
337
|
-
protected int preferredNavigationBarColor() {
|
|
338
|
-
if (mStyle.getNavigationBarColor() == Style.INVALID_COLOR) {
|
|
339
|
-
return mStyle.getScreenBackgroundColor();
|
|
340
|
-
}
|
|
341
|
-
return mStyle.getNavigationBarColor();
|
|
342
|
-
}
|
|
335
|
+
|
|
343
336
|
}
|
|
@@ -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/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.2",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDModalViewController.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
// fork from https://github.com/Tencent/QMUI_iOS/blob/master/QMUIKit/QMUIComponents/QMUIModalPresentationViewController.h
|
|
5
|
-
// Created by Listen on 2018/6/4.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "HBDViewController.h"
|
|
10
|
-
|
|
11
|
-
typedef NS_ENUM(NSUInteger, HBDModalAnimationStyle) {
|
|
12
|
-
HBDModalAnimationStyleFade, // 渐现渐隐,默认
|
|
13
|
-
HBDModalAnimationStylePopup, // 从中心点弹出
|
|
14
|
-
HBDModalAnimationStyleSlide // 从下往上升起
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
@class HBDModalViewController;
|
|
18
|
-
|
|
19
|
-
@interface HBDModalViewController : UIViewController
|
|
20
|
-
|
|
21
|
-
@property(nonatomic, assign, readonly, getter=isBeingHidden) BOOL beingHidden;
|
|
22
|
-
@property(nonatomic, weak, readonly) UIWindow *previousKeyWindow;
|
|
23
|
-
|
|
24
|
-
@property(nonatomic, strong) UIViewController *contentViewController;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 等同 contentViewController.view
|
|
28
|
-
*/
|
|
29
|
-
@property(nonatomic, strong, readonly) UIView *contentView;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 黑色遮罩
|
|
33
|
-
*/
|
|
34
|
-
@property(nonatomic, strong) UIView *dimmingView;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 设置`contentView`布局时与外容器的间距,默认为(20, 20, 20, 20)
|
|
38
|
-
* @warning 当设置了`layoutBlock`属性时,此属性不生效
|
|
39
|
-
*/
|
|
40
|
-
@property(nonatomic, assign) UIEdgeInsets contentViewMargins;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 限制`contentView`布局时的最大宽度,默认为iPhone 6竖屏下的屏幕宽度减去`contentViewMargins`在水平方向的值,也即浮层在iPhone 6 Plus或iPad上的宽度以iPhone 6上的宽度为准。
|
|
44
|
-
* @warning 当设置了`layoutBlock`属性时,此属性不生效re
|
|
45
|
-
*/
|
|
46
|
-
@property(nonatomic, assign) CGFloat maximumContentViewWidth;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 测量 contentView 的大小
|
|
50
|
-
* @arg limitSize contentView size 范围
|
|
51
|
-
*/
|
|
52
|
-
@property(nonatomic, assign) CGSize (^measureBlock)(HBDModalViewController *modalViewController, CGSize limitSize);
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 管理自定义的浮层布局,将会在浮层显示前、控件的容器大小发生变化时(例如横竖屏、来电状态栏)被调用
|
|
56
|
-
* @arg modalViewController
|
|
57
|
-
* @arg contentViewDefaultFrame 不使用自定义布局的情况下的默认布局,会受`contentViewMargins`、`maximumContentViewWidth`、`contentView sizeThatFits:`的影响
|
|
58
|
-
*
|
|
59
|
-
* @see contentViewMargins
|
|
60
|
-
* @see maximumContentViewWidth
|
|
61
|
-
*/
|
|
62
|
-
@property(nonatomic, copy) void (^layoutBlock)(HBDModalViewController *modalViewController, CGRect contentViewDefaultFrame);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 设置要使用的显示/隐藏动画的类型,默认为`HBDModalAnimationStyleFade`。
|
|
66
|
-
* @warning 当使用了`showingAnimation`和`hidingAnimation`时,该属性无效
|
|
67
|
-
*/
|
|
68
|
-
@property(nonatomic, assign) HBDModalAnimationStyle animationStyle;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 管理自定义的显示动画,需要管理的对象包括`contentView`和`dimmingView`,在`showingAnimation`被调用前,`contentView`已被添加到界面上。若使用了`layoutBlock`,则会先调用`layoutBlock`,再调用`showingAnimation`。在动画结束后,必须调用参数里的`completion` block。
|
|
72
|
-
* @arg modalViewController
|
|
73
|
-
* @arg contentViewFrame 动画执行完后`contentView`的最终frame,若使用了`layoutBlock`,则也即`layoutBlock`计算完后的frame
|
|
74
|
-
* @arg completion 动画结束后给到modalController的回调,modalController会在这个回调里做一些状态设置,务必调用。
|
|
75
|
-
*/
|
|
76
|
-
@property(nonatomic, copy) void (^showingAnimation)(HBDModalViewController *modalViewController, CGRect contentViewFrame, void(^completion)(BOOL finished));
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 管理自定义的隐藏动画,需要管理的对象包括`contentView`和`dimmingView`,在动画结束后,必须调用参数里的`completion` block。
|
|
80
|
-
* @arg modalViewController
|
|
81
|
-
* @arg completion 动画结束后给到modalController的回调,modalController会在这个回调里做一些清理工作,务必调用
|
|
82
|
-
*/
|
|
83
|
-
@property(nonatomic, copy) void (^hidingAnimation)(HBDModalViewController *modalViewController, void(^completion)(BOOL finished));
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* modal 将要销毁时的回掉
|
|
87
|
-
*/
|
|
88
|
-
@property(nonatomic, copy) void (^willDismissBlock)(HBDModalViewController *modalViewController);
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 请求重新计算浮层的布局
|
|
92
|
-
*/
|
|
93
|
-
- (void)updateLayout;
|
|
94
|
-
|
|
95
|
-
@end
|
|
96
|
-
|
|
97
|
-
/// 专用于 HBDModalViewController 的 UIWindow,这样才能在`[[UIApplication sharedApplication] windows]`里方便地区分出来
|
|
98
|
-
@interface HBDModalWindow : UIWindow
|
|
99
|
-
|
|
100
|
-
@end
|
|
101
|
-
|
|
102
|
-
@interface UIViewController (HBDModalViewController)
|
|
103
|
-
|
|
104
|
-
@property(nonatomic, weak, readonly) HBDModalViewController *hbd_modalViewController;
|
|
105
|
-
|
|
106
|
-
@property(nonatomic, strong, readonly) UIViewController *hbd_targetViewController;
|
|
107
|
-
|
|
108
|
-
@property(nonatomic, weak, readonly) UIViewController *hbd_popupViewController;
|
|
109
|
-
|
|
110
|
-
/// 把参数 vc 作为 contentViewController 包裹在 HBDModalViewController 中进行显示。
|
|
111
|
-
/// vc 可以通过 hbd_modalViewController 访问到包裹它的 HBDModalViewController。
|
|
112
|
-
/// vc 可以通过 hbd_targetViewController 访问到此方法的调用者。
|
|
113
|
-
/// 此方法的调用者可以通过 hbd_popupViewController 访问到 vc,也就是 HBDModalViewController 的 contentViewController。
|
|
114
|
-
- (void)hbd_showViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
115
|
-
|
|
116
|
-
- (void)hbd_showViewController:(UIViewController *)vc requestCode:(NSInteger)requestCode animated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
117
|
-
|
|
118
|
-
- (void)hbd_hideViewControllerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
119
|
-
|
|
120
|
-
@end
|
|
121
|
-
|
|
@@ -1,514 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDModalViewController.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
// fork from https://github.com/Tencent/QMUI_iOS/blob/master/QMUIKit/QMUIComponents/QMUIModalPresentationViewController.m
|
|
5
|
-
// Created by Listen on 2018/6/4.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <React/RCTLog.h>
|
|
10
|
-
#import <objc/runtime.h>
|
|
11
|
-
#import "HBDModalViewController.h"
|
|
12
|
-
#import "HBDRootView.h"
|
|
13
|
-
#import "HBDUtils.h"
|
|
14
|
-
#import "HBDViewController+Garden.h"
|
|
15
|
-
|
|
16
|
-
@interface UIViewController ()
|
|
17
|
-
|
|
18
|
-
@property(nonatomic, weak, readwrite) HBDModalViewController *hbd_modalViewController;
|
|
19
|
-
@property(nonatomic, strong, readwrite) UIViewController *hbd_targetViewController;
|
|
20
|
-
@property(nonatomic, weak, readwrite) UIViewController *hbd_popupViewController;
|
|
21
|
-
|
|
22
|
-
@end
|
|
23
|
-
|
|
24
|
-
@interface HBDModalViewController ()
|
|
25
|
-
|
|
26
|
-
@property(nonatomic, assign, readwrite, getter=isBeingHidden) BOOL beingHidden;
|
|
27
|
-
|
|
28
|
-
@property(nonatomic, strong, readwrite) UIView *contentView;
|
|
29
|
-
|
|
30
|
-
@property(nonatomic, strong) HBDModalWindow *modalWindow;
|
|
31
|
-
@property(nonatomic, weak, readwrite) UIWindow *previousKeyWindow;
|
|
32
|
-
@property(nonatomic, strong) UITapGestureRecognizer *dimmingViewTapGestureRecognizer;
|
|
33
|
-
|
|
34
|
-
@end
|
|
35
|
-
|
|
36
|
-
@implementation HBDModalViewController
|
|
37
|
-
|
|
38
|
-
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
39
|
-
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
|
|
40
|
-
[self didInitialized];
|
|
41
|
-
}
|
|
42
|
-
return self;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
|
|
46
|
-
if (self = [super initWithCoder:aDecoder]) {
|
|
47
|
-
[self didInitialized];
|
|
48
|
-
}
|
|
49
|
-
return self;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
- (void)didInitialized {
|
|
53
|
-
self.animationStyle = HBDModalAnimationStyleFade;
|
|
54
|
-
self.contentViewMargins = UIEdgeInsetsZero;
|
|
55
|
-
self.maximumContentViewWidth = [UIScreen mainScreen].bounds.size.width;
|
|
56
|
-
[self initDefaultDimmingViewWithoutAddToView];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
- (void)dealloc {
|
|
60
|
-
self.modalWindow = nil;
|
|
61
|
-
RCTLogInfo(@"[Navigator] %s", __FUNCTION__);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
- (UIViewController *)childViewControllerForStatusBarStyle {
|
|
65
|
-
return self.contentViewController;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
- (UIViewController *)childViewControllerForStatusBarHidden {
|
|
69
|
-
return self.contentViewController;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
- (UIViewController *)childViewControllerForHomeIndicatorAutoHidden {
|
|
73
|
-
return self.contentViewController;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
- (void)viewDidLoad {
|
|
77
|
-
[super viewDidLoad];
|
|
78
|
-
self.view.backgroundColor = UIColor.clearColor;
|
|
79
|
-
if (self.dimmingView && !self.dimmingView.superview) {
|
|
80
|
-
[self.view addSubview:self.dimmingView];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
- (void)viewWillLayoutSubviews {
|
|
85
|
-
[super viewWillLayoutSubviews];
|
|
86
|
-
self.dimmingView.frame = self.view.bounds;
|
|
87
|
-
if ([HBDUtils isInCall]) {
|
|
88
|
-
self.dimmingView.frame = CGRectMake(CGRectGetMinX(self.view.bounds), CGRectGetMinY(self.view.bounds) + 20, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) - 20);
|
|
89
|
-
}
|
|
90
|
-
CGRect contentViewFrame = [self contentViewFrameForShowing];
|
|
91
|
-
if (self.layoutBlock) {
|
|
92
|
-
self.layoutBlock(self, contentViewFrame);
|
|
93
|
-
} else {
|
|
94
|
-
self.contentView.frame = contentViewFrame;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
- (CGRect)contentViewFrameForShowing {
|
|
99
|
-
if ([self.contentView isKindOfClass:[HBDRootView class]]) {
|
|
100
|
-
return self.view.bounds;
|
|
101
|
-
}
|
|
102
|
-
CGSize contentViewContainerSize = CGSizeMake(CGRectGetWidth(self.view.bounds) - self.contentViewMargins.left - self.contentViewMargins.right, CGRectGetHeight(self.view.bounds) - self.contentViewMargins.top - self.contentViewMargins.bottom);
|
|
103
|
-
CGSize contentViewLimitSize = CGSizeMake(fmin(self.maximumContentViewWidth, contentViewContainerSize.width), contentViewContainerSize.height);
|
|
104
|
-
CGSize contentViewSize = CGSizeZero;
|
|
105
|
-
if (self.measureBlock) {
|
|
106
|
-
contentViewSize = self.measureBlock(self, contentViewLimitSize);
|
|
107
|
-
} else {
|
|
108
|
-
contentViewSize = [self.contentView sizeThatFits:contentViewLimitSize];
|
|
109
|
-
}
|
|
110
|
-
contentViewSize.width = fmin(contentViewLimitSize.width, contentViewSize.width);
|
|
111
|
-
contentViewSize.height = fmin(contentViewLimitSize.height, contentViewSize.height);
|
|
112
|
-
CGRect contentViewFrame = CGRectMake((contentViewContainerSize.width - contentViewSize.width) / 2 + self.contentViewMargins.left, (contentViewContainerSize.height - contentViewSize.height) / 2 + self.contentViewMargins.top, contentViewSize.width, contentViewSize.height);
|
|
113
|
-
contentViewFrame = CGRectApplyAffineTransform(contentViewFrame, self.contentView.transform);
|
|
114
|
-
return contentViewFrame;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
- (void)viewDidAppear:(BOOL)animated {
|
|
118
|
-
[super viewDidAppear:animated];
|
|
119
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
- (void)viewDidDisappear:(BOOL)animated {
|
|
123
|
-
[super viewDidDisappear:animated];
|
|
124
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
- (void)statusBarFrameWillChange:(NSNotification *)notification {
|
|
128
|
-
[UIView animateWithDuration:0.35 animations:^{
|
|
129
|
-
CGFloat dy = [HBDUtils isInCall] ? -20 : 20;
|
|
130
|
-
self.dimmingView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) + dy);
|
|
131
|
-
}];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
- (void)updateLayout {
|
|
135
|
-
if ([self isViewLoaded]) {
|
|
136
|
-
[self.view setNeedsLayout];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
|
|
141
|
-
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
|
142
|
-
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
143
|
-
if (!UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) {
|
|
144
|
-
self.view.frame = CGRectMake(0, 0, size.width, size.height);
|
|
145
|
-
}
|
|
146
|
-
[self updateLayout];
|
|
147
|
-
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
148
|
-
|
|
149
|
-
}];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
#pragma mark - Dimming View
|
|
153
|
-
|
|
154
|
-
- (void)setDimmingView:(UIView *)dimmingView {
|
|
155
|
-
if (![self isViewLoaded]) {
|
|
156
|
-
_dimmingView = dimmingView;
|
|
157
|
-
} else {
|
|
158
|
-
[self.view insertSubview:dimmingView belowSubview:_dimmingView];
|
|
159
|
-
[_dimmingView removeFromSuperview];
|
|
160
|
-
_dimmingView = dimmingView;
|
|
161
|
-
[self.view setNeedsLayout];
|
|
162
|
-
}
|
|
163
|
-
[self addTapGestureRecognizerToDimmingViewIfNeeded];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
- (void)initDefaultDimmingViewWithoutAddToView {
|
|
167
|
-
if (!self.dimmingView) {
|
|
168
|
-
_dimmingView = [[UIView alloc] init];
|
|
169
|
-
self.dimmingView.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.6];
|
|
170
|
-
[self addTapGestureRecognizerToDimmingViewIfNeeded];
|
|
171
|
-
if ([self isViewLoaded]) {
|
|
172
|
-
[self.view addSubview:self.dimmingView];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// 要考虑用户可能创建了自己的dimmingView,则tap手势也要重新添加上去
|
|
178
|
-
- (void)addTapGestureRecognizerToDimmingViewIfNeeded {
|
|
179
|
-
if (!self.dimmingView) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (self.dimmingViewTapGestureRecognizer.view == self.dimmingView) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (!self.dimmingViewTapGestureRecognizer) {
|
|
188
|
-
self.dimmingViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDimmingViewTapGestureRecognizer:)];
|
|
189
|
-
}
|
|
190
|
-
[self.dimmingView addGestureRecognizer:self.dimmingViewTapGestureRecognizer];
|
|
191
|
-
self.dimmingView.userInteractionEnabled = YES;// UIImageView默认userInteractionEnabled为NO,为了兼容UIImageView,这里必须主动设置为YES
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
- (void)handleDimmingViewTapGestureRecognizer:(UITapGestureRecognizer *)tapGestureRecognizer {
|
|
195
|
-
[self.contentViewController hbd_hideViewControllerAnimated:YES completion:nil];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
#pragma mark - ContentView
|
|
199
|
-
|
|
200
|
-
- (void)setContentViewController:(UIViewController *)contentViewController {
|
|
201
|
-
_contentViewController = contentViewController;
|
|
202
|
-
if (contentViewController) {
|
|
203
|
-
_contentViewController.hbd_modalViewController = self;
|
|
204
|
-
[self addChildViewController:contentViewController];
|
|
205
|
-
[contentViewController didMoveToParentViewController:self];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
- (void)setContentView:(UIView *)contentView {
|
|
210
|
-
_contentView = contentView;
|
|
211
|
-
if ([contentView isKindOfClass:[HBDRootView class]]) {
|
|
212
|
-
HBDRootView *rootView = (HBDRootView *) contentView;
|
|
213
|
-
rootView.backgroundColor = UIColor.clearColor;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
#pragma mark - Showing and Hiding
|
|
218
|
-
|
|
219
|
-
- (void)showingAnimationWithCompletion:(void (^)(BOOL))completion {
|
|
220
|
-
if (self.animationStyle == HBDModalAnimationStyleFade) {
|
|
221
|
-
self.dimmingView.alpha = 0.0;
|
|
222
|
-
self.contentView.alpha = 0.0;
|
|
223
|
-
[UIView animateWithDuration:.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
224
|
-
self.dimmingView.alpha = 1.0;
|
|
225
|
-
self.contentView.alpha = 1.0;
|
|
226
|
-
} completion:^(BOOL finished) {
|
|
227
|
-
if (completion) {
|
|
228
|
-
completion(finished);
|
|
229
|
-
}
|
|
230
|
-
}];
|
|
231
|
-
|
|
232
|
-
} else if (self.animationStyle == HBDModalAnimationStylePopup) {
|
|
233
|
-
self.dimmingView.alpha = 0.0;
|
|
234
|
-
self.contentView.transform = CGAffineTransformMakeScale(0, 0);
|
|
235
|
-
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
236
|
-
self.dimmingView.alpha = 1.0;
|
|
237
|
-
self.contentView.transform = CGAffineTransformMakeScale(1, 1);
|
|
238
|
-
} completion:^(BOOL finished) {
|
|
239
|
-
self.contentView.transform = CGAffineTransformIdentity;
|
|
240
|
-
if (completion) {
|
|
241
|
-
completion(finished);
|
|
242
|
-
}
|
|
243
|
-
}];
|
|
244
|
-
|
|
245
|
-
} else if (self.animationStyle == HBDModalAnimationStyleSlide) {
|
|
246
|
-
self.dimmingView.alpha = 0.0;
|
|
247
|
-
self.contentView.transform = CGAffineTransformMakeTranslation(0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(self.contentView.frame));
|
|
248
|
-
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
249
|
-
self.dimmingView.alpha = 1.0;
|
|
250
|
-
self.contentView.transform = CGAffineTransformIdentity;
|
|
251
|
-
} completion:^(BOOL finished) {
|
|
252
|
-
if (completion) {
|
|
253
|
-
completion(finished);
|
|
254
|
-
}
|
|
255
|
-
}];
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
- (void)hidingAnimationWithCompletion:(void (^)(BOOL))completion {
|
|
260
|
-
if (self.animationStyle == HBDModalAnimationStyleFade) {
|
|
261
|
-
[UIView animateWithDuration:.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
262
|
-
self.dimmingView.alpha = 0.0;
|
|
263
|
-
self.contentView.alpha = 0.0;
|
|
264
|
-
} completion:^(BOOL finished) {
|
|
265
|
-
if (completion) {
|
|
266
|
-
completion(finished);
|
|
267
|
-
}
|
|
268
|
-
}];
|
|
269
|
-
} else if (self.animationStyle == HBDModalAnimationStylePopup) {
|
|
270
|
-
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
271
|
-
self.dimmingView.alpha = 0.0;
|
|
272
|
-
self.contentView.transform = CGAffineTransformMakeScale(0.0, 0.0);
|
|
273
|
-
} completion:^(BOOL finished) {
|
|
274
|
-
if (completion) {
|
|
275
|
-
self.contentView.transform = CGAffineTransformIdentity;
|
|
276
|
-
completion(finished);
|
|
277
|
-
}
|
|
278
|
-
}];
|
|
279
|
-
} else if (self.animationStyle == HBDModalAnimationStyleSlide) {
|
|
280
|
-
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
281
|
-
self.dimmingView.alpha = 0.0;
|
|
282
|
-
self.contentView.transform = CGAffineTransformMakeTranslation(0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(self.contentView.frame));
|
|
283
|
-
} completion:^(BOOL finished) {
|
|
284
|
-
if (completion) {
|
|
285
|
-
self.contentView.transform = CGAffineTransformIdentity;
|
|
286
|
-
completion(finished);
|
|
287
|
-
}
|
|
288
|
-
}];
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
- (void)showWithAnimated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
293
|
-
self.contentView = self.contentViewController.view;
|
|
294
|
-
self.previousKeyWindow = self.contentViewController.hbd_targetViewController.view.window;
|
|
295
|
-
|
|
296
|
-
if (!self.modalWindow) {
|
|
297
|
-
self.modalWindow = [[HBDModalWindow alloc] init];
|
|
298
|
-
self.modalWindow.windowLevel = UIWindowLevelAlert - 4.0;;
|
|
299
|
-
self.modalWindow.backgroundColor = UIColor.clearColor;// 避免横竖屏旋转时出现黑色
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
self.modalWindow.rootViewController = self;
|
|
303
|
-
[self.modalWindow makeKeyAndVisible];
|
|
304
|
-
|
|
305
|
-
void (^didShownCompletion)(BOOL finished) = ^(BOOL finished) {
|
|
306
|
-
if (completion) {
|
|
307
|
-
completion(finished);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
if (animated) {
|
|
312
|
-
[self.view addSubview:self.contentView];
|
|
313
|
-
[self.view layoutIfNeeded];
|
|
314
|
-
CGRect contentViewFrame = [self contentViewFrameForShowing];
|
|
315
|
-
if (self.showingAnimation) {
|
|
316
|
-
// 使用自定义的动画
|
|
317
|
-
if (self.layoutBlock) {
|
|
318
|
-
self.layoutBlock(self, contentViewFrame);
|
|
319
|
-
contentViewFrame = self.contentView.frame;
|
|
320
|
-
}
|
|
321
|
-
self.showingAnimation(self, contentViewFrame, didShownCompletion);
|
|
322
|
-
} else {
|
|
323
|
-
self.contentView.frame = contentViewFrame;
|
|
324
|
-
[self.contentView setNeedsLayout];
|
|
325
|
-
[self.contentView layoutIfNeeded];
|
|
326
|
-
[self showingAnimationWithCompletion:didShownCompletion];
|
|
327
|
-
}
|
|
328
|
-
} else {
|
|
329
|
-
CGRect contentViewFrame = [self contentViewFrameForShowing];
|
|
330
|
-
self.contentView.frame = contentViewFrame;
|
|
331
|
-
[self.view addSubview:self.contentView];
|
|
332
|
-
self.dimmingView.alpha = 1;
|
|
333
|
-
didShownCompletion(YES);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
- (void)hideWithAnimated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
338
|
-
self.beingHidden = YES;
|
|
339
|
-
[self.view endEditing:YES];
|
|
340
|
-
|
|
341
|
-
if (RCTKeyWindow() == self.modalWindow) {
|
|
342
|
-
if (self.previousKeyWindow) {
|
|
343
|
-
[self.previousKeyWindow makeKeyWindow];
|
|
344
|
-
} else {
|
|
345
|
-
[[UIApplication sharedApplication].delegate.window makeKeyWindow];
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (self.contentViewController) {
|
|
350
|
-
[self.contentViewController beginAppearanceTransition:NO animated:animated];
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
void (^didHiddenCompletion)(BOOL finished) = ^(BOOL finished) {
|
|
354
|
-
|
|
355
|
-
if (self.contentViewController) {
|
|
356
|
-
[self.contentViewController endAppearanceTransition];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
self.modalWindow.hidden = YES;
|
|
360
|
-
self.modalWindow.rootViewController = nil;
|
|
361
|
-
self.previousKeyWindow = nil;
|
|
362
|
-
|
|
363
|
-
if (self.willDismissBlock) {
|
|
364
|
-
self.willDismissBlock(self);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (completion) {
|
|
368
|
-
completion(YES);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (self.contentViewController) {
|
|
372
|
-
self.contentViewController.hbd_targetViewController.hbd_popupViewController = nil;
|
|
373
|
-
self.contentViewController.hbd_targetViewController = nil;
|
|
374
|
-
self.contentViewController.hbd_modalViewController = nil;
|
|
375
|
-
self.contentViewController = nil;
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
if (animated) {
|
|
380
|
-
if (self.hidingAnimation) {
|
|
381
|
-
self.hidingAnimation(self, didHiddenCompletion);
|
|
382
|
-
} else {
|
|
383
|
-
[self hidingAnimationWithCompletion:didHiddenCompletion];
|
|
384
|
-
}
|
|
385
|
-
} else {
|
|
386
|
-
didHiddenCompletion(YES);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
@end
|
|
391
|
-
|
|
392
|
-
@interface HBDModalViewController (Manager)
|
|
393
|
-
- (void)showWithAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
394
|
-
|
|
395
|
-
- (void)hideWithAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
396
|
-
@end
|
|
397
|
-
|
|
398
|
-
@implementation HBDModalWindow
|
|
399
|
-
|
|
400
|
-
@end
|
|
401
|
-
|
|
402
|
-
@implementation UIViewController (HBDModalViewController)
|
|
403
|
-
|
|
404
|
-
- (HBDModalViewController *)hbd_modalViewController {
|
|
405
|
-
return objc_getAssociatedObject(self, _cmd);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
- (void)setHbd_modalViewController:(HBDModalViewController *)modalViewController {
|
|
409
|
-
objc_setAssociatedObject(self, @selector(hbd_modalViewController), modalViewController, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
- (UIViewController *)hbd_targetViewController {
|
|
413
|
-
return objc_getAssociatedObject(self, _cmd);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
- (void)setHbd_targetViewController:(UIViewController *)targetViewController {
|
|
417
|
-
objc_setAssociatedObject(self, @selector(hbd_targetViewController), targetViewController, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
- (UIViewController *)hbd_popupViewController {
|
|
421
|
-
return objc_getAssociatedObject(self, _cmd);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
- (void)setHbd_popupViewController:(UIViewController *)puppetViewController {
|
|
425
|
-
objc_setAssociatedObject(self, @selector(hbd_popupViewController), puppetViewController, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
- (void)hbd_showViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
429
|
-
[self hbd_showViewController:vc requestCode:0 animated:animated completion:completion];
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
- (void)hbd_showViewController:(UIViewController *)vc requestCode:(NSInteger)requestCode animated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
433
|
-
if (![self canShowModal]) {
|
|
434
|
-
[self didReceiveResultCode:0 resultData:nil requestCode:requestCode];
|
|
435
|
-
|
|
436
|
-
if (completion) {
|
|
437
|
-
completion(NO);
|
|
438
|
-
}
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
self.hbd_popupViewController = vc;
|
|
443
|
-
[self beginAppearanceTransition:NO animated:YES];
|
|
444
|
-
[self endAppearanceTransition];
|
|
445
|
-
|
|
446
|
-
vc.hbd_barStyle = self.hbd_barStyle;
|
|
447
|
-
vc.hbd_targetViewController = self;
|
|
448
|
-
vc.requestCode = requestCode;
|
|
449
|
-
|
|
450
|
-
HBDModalViewController *modalViewController = [[HBDModalViewController alloc] init];
|
|
451
|
-
modalViewController.contentViewController = vc;
|
|
452
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
453
|
-
HBDViewController *hbdvc = (HBDViewController *)vc;
|
|
454
|
-
NSString *screenColor = hbdvc.options[@"screenBackgroundColor"];
|
|
455
|
-
if (screenColor) {
|
|
456
|
-
UIColor *color = [HBDUtils colorWithHexString:screenColor];
|
|
457
|
-
if (colorHasAlphaComponent(color)) {
|
|
458
|
-
modalViewController.dimmingView.backgroundColor = color;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
if (hbdvc.forceTransparentDialogWindow) {
|
|
462
|
-
modalViewController.dimmingView.backgroundColor = UIColor.clearColor;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
[modalViewController showWithAnimated:animated completion:completion];
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
- (BOOL)canShowModal {
|
|
469
|
-
UIViewController *presented = self.presentedViewController;
|
|
470
|
-
if (presented && !presented.isBeingDismissed) {
|
|
471
|
-
RCTLogWarn(@"[Navigator] Can't show modal since the scene had present another scene already.");
|
|
472
|
-
return NO;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
|
|
476
|
-
for (NSUInteger i = application.windows.count; i > 0; i--) {
|
|
477
|
-
UIWindow *window = application.windows[i - 1];
|
|
478
|
-
UIViewController *viewController = window.rootViewController;
|
|
479
|
-
if ([viewController isKindOfClass:[HBDModalViewController class]]) {
|
|
480
|
-
HBDModalViewController *modal = (HBDModalViewController *) viewController;
|
|
481
|
-
if (!modal.beingHidden && window != self.view.window) {
|
|
482
|
-
RCTLogWarn(@"[Navigator] Can't show modal since the scene had show another modal already.");
|
|
483
|
-
return NO;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
return YES;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
- (void)hbd_hideViewControllerAnimated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
492
|
-
if (!self.hbd_modalViewController) {
|
|
493
|
-
UIViewController *parent = self.parentViewController;
|
|
494
|
-
parent.resultData = self.resultData;
|
|
495
|
-
parent.resultCode = self.resultCode;
|
|
496
|
-
[parent hbd_hideViewControllerAnimated:animated completion:completion];
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
[self.hbd_modalViewController hideWithAnimated:animated completion:^(BOOL finished) {
|
|
501
|
-
UIViewController *target = self.hbd_targetViewController;
|
|
502
|
-
[target beginAppearanceTransition:YES animated:YES];
|
|
503
|
-
[target endAppearanceTransition];
|
|
504
|
-
[target didReceiveResultCode:self.resultCode resultData:self.resultData requestCode:self.requestCode];
|
|
505
|
-
|
|
506
|
-
if (completion) {
|
|
507
|
-
completion(finished);
|
|
508
|
-
}
|
|
509
|
-
}];
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
@end
|
|
513
|
-
|
|
514
|
-
|