hybrid-navigation 4.1.0 → 5.0.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 +9 -1
- package/README.md +12 -4
- package/android/build.gradle +4 -4
- package/android/proguard-rules.pro +0 -14
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +114 -23
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +115 -12
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +83 -18
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +185 -25
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +11 -0
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +563 -143
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +39 -12
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +3 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +8 -3
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +29 -9
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +28 -3
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +59 -90
- package/android/src/main/java/com/navigation/androidx/TabBar.java +21 -2
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +24 -7
- package/android/src/main/java/com/navigation/androidx/TabView.java +11 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/DispatchResult.java +59 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +18 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +15 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +3 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +113 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +13 -24
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +5 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +196 -194
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +499 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +4 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/OrientationCoordinator.java +162 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +103 -66
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +50 -89
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +156 -77
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +8 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleState.java +21 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleStateMachine.java +116 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ScreenOrientation.java +42 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +17 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +14 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +62 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +35 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +16 -13
- package/dist/DeepLink.d.ts +3 -2
- package/dist/DeepLink.js +37 -14
- package/dist/NativeEvent.d.ts +4 -12
- package/dist/NativeNavigation.d.ts +17 -19
- package/dist/Navigation.d.ts +21 -19
- package/dist/Navigation.js +83 -89
- package/dist/NavigationComponentWrap.d.ts +4 -3
- package/dist/NavigationComponentWrap.js +3 -6
- package/dist/Navigator.d.ts +31 -42
- package/dist/Navigator.js +97 -90
- package/dist/Options.d.ts +3 -1
- package/dist/Route.d.ts +85 -18
- package/dist/handler/DispatchCommandHandler.d.ts +10 -6
- package/dist/handler/DispatchCommandHandler.js +41 -17
- package/dist/handler/LayoutCommandHandler.d.ts +7 -7
- package/dist/handler/LayoutCommandHandler.js +21 -15
- package/dist/handler/LifecycleEventHandler.d.ts +26 -0
- package/dist/handler/LifecycleEventHandler.js +136 -0
- package/dist/handler/ResultEventHandler.d.ts +14 -9
- package/dist/handler/ResultEventHandler.js +88 -13
- package/dist/hooks.d.ts +5 -2
- package/dist/hooks.js +26 -4
- package/dist/index.d.ts +13 -0
- package/dist/index.js +0 -2
- package/dist/routeConfigRegistry.d.ts +6 -0
- package/dist/routeConfigRegistry.js +19 -0
- package/dist/router/drawer.d.ts +2 -2
- package/dist/router/drawer.js +6 -3
- package/dist/router/index.d.ts +8 -5
- package/dist/router/index.js +127 -43
- package/dist/router/screen.d.ts +2 -2
- package/dist/router/screen.js +1 -1
- package/dist/router/stack.d.ts +2 -2
- package/dist/router/stack.js +59 -30
- package/dist/router/tabs.d.ts +2 -2
- package/dist/router/tabs.js +4 -1
- package/dist/store.d.ts +2 -2
- package/ios/HBDGlobalStyle.h +26 -0
- package/ios/{GlobalStyle.mm → HBDGlobalStyle.mm} +30 -29
- package/ios/HybridNavigation.h +4 -1
- package/ios/Navigator/HBDDrawerNavigator.mm +24 -8
- package/ios/Navigator/HBDNavigatorRegistry.mm +1 -0
- package/ios/Navigator/HBDScreenNavigator.mm +106 -52
- package/ios/Navigator/HBDStackNavigator.mm +109 -61
- package/ios/Navigator/HBDTabNavigator.mm +32 -14
- package/ios/React/HBDNativeNavigation.mm +109 -131
- package/ios/React/HBDNavigator.h +29 -5
- package/ios/React/HBDOrientationCoordinator.h +27 -0
- package/ios/React/HBDOrientationCoordinator.mm +282 -0
- package/ios/React/HBDReactBridgeManager.h +36 -20
- package/ios/React/HBDReactBridgeManager.mm +450 -108
- package/ios/React/HBDSceneLifecycleStateMachine.h +38 -0
- package/ios/React/HBDSceneLifecycleStateMachine.mm +180 -0
- package/ios/View/HBDRootView.h +2 -0
- package/ios/View/HBDRootView.mm +148 -0
- package/ios/View/UIImage+WithBadge.h +3 -3
- package/ios/View/UIImage+WithBadge.mm +10 -15
- package/ios/ViewController/HBDDrawerController.mm +126 -5
- package/ios/ViewController/HBDNavigationController.mm +17 -4
- package/ios/ViewController/HBDReactViewController.mm +59 -121
- package/ios/ViewController/HBDTabBarController.h +4 -0
- package/ios/ViewController/HBDTabBarController.mm +59 -44
- package/ios/ViewController/HBDViewController.h +10 -3
- package/ios/ViewController/HBDViewController.mm +161 -159
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +3 -3
- package/ios/ViewController/UIViewController+HBD.h +17 -10
- package/ios/ViewController/UIViewController+HBD.mm +85 -69
- package/package.json +1 -1
- package/src/DeepLink.ts +41 -14
- package/src/NativeEvent.ts +4 -14
- package/src/NativeNavigation.ts +22 -33
- package/src/Navigation.ts +162 -121
- package/src/NavigationComponentWrap.tsx +9 -9
- package/src/Navigator.ts +191 -153
- package/src/Options.ts +3 -1
- package/src/Route.ts +134 -19
- package/src/handler/DispatchCommandHandler.ts +55 -21
- package/src/handler/LayoutCommandHandler.ts +36 -17
- package/src/handler/LifecycleEventHandler.ts +172 -0
- package/src/handler/ResultEventHandler.ts +112 -19
- package/src/hooks.ts +39 -7
- package/src/index.ts +26 -2
- package/src/routeConfigRegistry.ts +26 -0
- package/src/router/drawer.ts +8 -5
- package/src/router/index.ts +161 -50
- package/src/router/screen.ts +3 -3
- package/src/router/stack.ts +80 -29
- package/src/router/tabs.ts +15 -7
- package/src/store.ts +1 -1
- package/android/src/main/java/androidx/fragment/app/InternalFragment.java +0 -22
- package/android/src/main/java/com/navigation/androidx/SystemUI30.java +0 -87
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +0 -176
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +0 -130
- package/android/src/main/res/layout/nav_tab_bar_react.xml +0 -32
- package/android/src/main/res/layout/nav_tab_bar_react_indeterminate.xml +0 -32
- package/dist/NativeGarden.d.ts +0 -13
- package/dist/NativeGarden.js +0 -2
- package/dist/handler/VisibilityEventHandler.d.ts +0 -13
- package/dist/handler/VisibilityEventHandler.js +0 -39
- package/ios/GlobalStyle.h +0 -15
- package/ios/React/HBDNativeGarden.h +0 -10
- package/ios/React/HBDNativeGarden.mm +0 -111
- package/src/NativeGarden.ts +0 -16
- package/src/handler/VisibilityEventHandler.ts +0 -52
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
#import "HBDOrientationCoordinator.h"
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
@interface HBDGlobalStyle : NSObject
|
|
7
|
+
|
|
8
|
+
+ (void)createWithOptions:(nullable NSDictionary *)options;
|
|
9
|
+
|
|
10
|
+
+ (HBDGlobalStyle *)globalStyle;
|
|
11
|
+
|
|
12
|
+
@property(nonatomic, strong, readonly) UIColor *screenBackgroundColor;
|
|
13
|
+
@property(nonatomic, assign, readonly) UIBarStyle statusBarStyle;
|
|
14
|
+
@property(nonatomic, strong, readonly) UIColor *tabBarBackgroundColor;
|
|
15
|
+
@property(nonatomic, strong, readonly, nullable) UIImage *tabBarShadowImage;
|
|
16
|
+
@property(nonatomic, strong, readonly) UIColor *tabBarItemSelectedColor;
|
|
17
|
+
@property(nonatomic, strong, readonly) UIColor *tabBarItemNormalColor;
|
|
18
|
+
@property(nonatomic, strong, readonly) UIColor *tabBarBadgeColor;
|
|
19
|
+
@property(nonatomic, assign, readonly) HBDScreenOrientation defaultOrientation;
|
|
20
|
+
|
|
21
|
+
- (instancetype)initWithOptions:(nullable NSDictionary *)options;
|
|
22
|
+
- (void)applyToTabBar:(UITabBar *)tabBar;
|
|
23
|
+
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,63 +1,60 @@
|
|
|
1
|
-
#import "
|
|
1
|
+
#import "HBDGlobalStyle.h"
|
|
2
2
|
|
|
3
|
+
#import "HBDReactBridgeManager.h"
|
|
3
4
|
#import "HBDUtils.h"
|
|
4
5
|
|
|
5
|
-
@interface
|
|
6
|
+
@interface HBDGlobalStyle ()
|
|
6
7
|
|
|
7
8
|
@property(nonatomic, copy, readonly) NSDictionary *options;
|
|
8
9
|
@property(nonatomic, assign, readwrite) UIBarStyle statusBarStyle;
|
|
9
10
|
|
|
10
|
-
@property(nonatomic, strong) UIColor *tabBarBackgroundColor;
|
|
11
|
-
@property(nonatomic, strong) UIImage *tabBarShadowImage;
|
|
12
|
-
@property(nonatomic, strong) UIColor *tabBarItemSelectedColor;
|
|
13
|
-
@property(nonatomic, strong) UIColor *tabBarItemNormalColor;
|
|
11
|
+
@property(nonatomic, strong, readwrite) UIColor *tabBarBackgroundColor;
|
|
12
|
+
@property(nonatomic, strong, readwrite, nullable) UIImage *tabBarShadowImage;
|
|
13
|
+
@property(nonatomic, strong, readwrite) UIColor *tabBarItemSelectedColor;
|
|
14
|
+
@property(nonatomic, strong, readwrite) UIColor *tabBarItemNormalColor;
|
|
15
|
+
@property(nonatomic, strong, readwrite) UIColor *tabBarBadgeColor;
|
|
16
|
+
@property(nonatomic, assign, readwrite) HBDScreenOrientation defaultOrientation;
|
|
14
17
|
|
|
15
18
|
@end
|
|
16
19
|
|
|
17
|
-
@implementation
|
|
18
|
-
|
|
19
|
-
static GlobalStyle *globalStyle;
|
|
20
|
+
@implementation HBDGlobalStyle
|
|
20
21
|
|
|
21
22
|
+ (void)createWithOptions:(NSDictionary *)options {
|
|
22
|
-
|
|
23
|
-
globalStyle =
|
|
24
|
-
globalStyle.interfaceOrientation = interfaceOrientation;
|
|
25
|
-
[globalStyle inflateTabBar:[UITabBar appearance]];
|
|
23
|
+
HBDGlobalStyle *style = [[HBDGlobalStyle alloc] initWithOptions:options];
|
|
24
|
+
[HBDReactBridgeManager get].globalStyle = style;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
+ (
|
|
29
|
-
|
|
30
|
-
[self createWithOptions:@{}];
|
|
31
|
-
}
|
|
32
|
-
return globalStyle;
|
|
27
|
+
+ (HBDGlobalStyle *)globalStyle {
|
|
28
|
+
return [HBDReactBridgeManager get].globalStyle;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
- (instancetype)initWithOptions:(NSDictionary *)options {
|
|
36
32
|
if (self = [super init]) {
|
|
37
|
-
_options = options;
|
|
38
|
-
|
|
33
|
+
_options = options ? [options copy] : @{};
|
|
34
|
+
HBDScreenOrientation parsedOrientation = HBDScreenOrientationFromString(_options[@"orientation"]);
|
|
35
|
+
_defaultOrientation = parsedOrientation != HBDScreenOrientationUnspecified ? parsedOrientation : HBDScreenOrientationPortrait;
|
|
39
36
|
|
|
40
|
-
NSString *screenBackgroundColor =
|
|
37
|
+
NSString *screenBackgroundColor = _options[@"screenBackgroundColor"];
|
|
41
38
|
if (screenBackgroundColor) {
|
|
42
39
|
_screenBackgroundColor = [HBDUtils colorWithHexString:screenBackgroundColor];
|
|
43
40
|
} else {
|
|
44
41
|
_screenBackgroundColor = UIColor.whiteColor;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
NSString *statusBarStyle =
|
|
44
|
+
NSString *statusBarStyle = _options[@"statusBarStyle"];
|
|
48
45
|
if (statusBarStyle && [statusBarStyle isEqualToString:@"light-content"]) {
|
|
49
46
|
_statusBarStyle = UIBarStyleBlack;
|
|
50
47
|
} else {
|
|
51
48
|
_statusBarStyle = UIBarStyleDefault;
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
NSString *tabBarBackgroundColor =
|
|
51
|
+
NSString *tabBarBackgroundColor = _options[@"tabBarBackgroundColor"];
|
|
55
52
|
if (!tabBarBackgroundColor) {
|
|
56
53
|
tabBarBackgroundColor = @"#FFFFFF";
|
|
57
54
|
}
|
|
58
55
|
self.tabBarBackgroundColor = [HBDUtils colorWithHexString:tabBarBackgroundColor];
|
|
59
56
|
|
|
60
|
-
NSDictionary *tabBarShadowImage =
|
|
57
|
+
NSDictionary *tabBarShadowImage = _options[@"tabBarShadowImage"];
|
|
61
58
|
if ([tabBarShadowImage isKindOfClass:[NSDictionary class]]) {
|
|
62
59
|
UIImage *image = [UIImage new];
|
|
63
60
|
NSDictionary *imageItem = tabBarShadowImage[@"image"];
|
|
@@ -70,8 +67,8 @@ static GlobalStyle *globalStyle;
|
|
|
70
67
|
self.tabBarShadowImage = image;
|
|
71
68
|
}
|
|
72
69
|
|
|
73
|
-
NSString *tabBarItemSelectedColor =
|
|
74
|
-
NSString *tabBarItemNormalColor =
|
|
70
|
+
NSString *tabBarItemSelectedColor = _options[@"tabBarItemSelectedColor"];
|
|
71
|
+
NSString *tabBarItemNormalColor = _options[@"tabBarItemNormalColor"];
|
|
75
72
|
if (!tabBarItemSelectedColor) {
|
|
76
73
|
tabBarItemSelectedColor = @"#FF5722";
|
|
77
74
|
}
|
|
@@ -81,16 +78,19 @@ static GlobalStyle *globalStyle;
|
|
|
81
78
|
self.tabBarItemSelectedColor = [HBDUtils colorWithHexString:tabBarItemSelectedColor];
|
|
82
79
|
self.tabBarItemNormalColor = [HBDUtils colorWithHexString:tabBarItemNormalColor];
|
|
83
80
|
|
|
84
|
-
NSString *tabBarBadgeColor =
|
|
81
|
+
NSString *tabBarBadgeColor = _options[@"tabBarBadgeColor"];
|
|
85
82
|
if (!tabBarBadgeColor) {
|
|
86
83
|
tabBarBadgeColor = @"#FF3B30";
|
|
87
84
|
}
|
|
88
|
-
|
|
85
|
+
self.tabBarBadgeColor = [HBDUtils colorWithHexString:tabBarBadgeColor];
|
|
89
86
|
}
|
|
90
87
|
return self;
|
|
91
88
|
}
|
|
92
89
|
|
|
93
|
-
- (void)
|
|
90
|
+
- (void)applyToTabBar:(UITabBar *)tabBar {
|
|
91
|
+
if (!tabBar) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
94
|
UITabBarItemAppearance *tabBarItem = [UITabBarItemAppearance new];
|
|
95
95
|
tabBarItem.normal.titleTextAttributes = @{
|
|
96
96
|
NSForegroundColorAttributeName: self.tabBarItemNormalColor,
|
|
@@ -115,6 +115,7 @@ static GlobalStyle *globalStyle;
|
|
|
115
115
|
//
|
|
116
116
|
} else {
|
|
117
117
|
tabBar.standardAppearance.backgroundImage = [HBDUtils imageWithColor:self.tabBarBackgroundColor];
|
|
118
|
+
tabBar.scrollEdgeAppearance.backgroundImage = [HBDUtils imageWithColor:self.tabBarBackgroundColor];
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
|
package/ios/HybridNavigation.h
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
#define HybridNavigation_h
|
|
3
3
|
|
|
4
4
|
#import "HBDReactBridgeManager.h"
|
|
5
|
+
#import "HBDSceneLifecycleStateMachine.h"
|
|
6
|
+
#import "HBDOrientationCoordinator.h"
|
|
5
7
|
|
|
6
8
|
#import "HBDViewController.h"
|
|
7
9
|
#import "HBDNavigationController.h"
|
|
8
10
|
#import "HBDTabBarController.h"
|
|
9
11
|
#import "HBDDrawerController.h"
|
|
10
12
|
#import "UIViewController+HBD.h"
|
|
13
|
+
#import "UINavigationController+HBD.h"
|
|
11
14
|
|
|
12
15
|
#import "HBDNavigator.h"
|
|
13
16
|
#import "HBDScreenNavigator.h"
|
|
@@ -16,6 +19,6 @@
|
|
|
16
19
|
#import "HBDDrawerNavigator.h"
|
|
17
20
|
|
|
18
21
|
#import "HBDUtils.h"
|
|
19
|
-
#import "
|
|
22
|
+
#import "HBDGlobalStyle.h"
|
|
20
23
|
|
|
21
24
|
#endif /* HybridNavigation_h */
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
- (NSArray<NSString *> *)supportActions {
|
|
12
|
-
return @[@"toggleMenu", @"openMenu", @"closeMenu"];
|
|
12
|
+
return @[@"toggleMenu", @"openMenu", @"closeMenu", @"setMenuInteractive"];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
- (UIViewController *)viewControllerWithLayout:(NSDictionary *)layout {
|
|
@@ -59,12 +59,19 @@
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
HBDDrawerController *drawer = (HBDDrawerController *) vc;
|
|
62
|
+
NSMutableArray *children = [[NSMutableArray alloc] initWithCapacity:2];
|
|
62
63
|
NSDictionary *content = [[HBDReactBridgeManager get] routeGraphWithViewController:drawer.contentController];
|
|
64
|
+
if (content) {
|
|
65
|
+
[children addObject:content];
|
|
66
|
+
}
|
|
63
67
|
NSDictionary *menu = [[HBDReactBridgeManager get] routeGraphWithViewController:drawer.menuController];
|
|
68
|
+
if (menu) {
|
|
69
|
+
[children addObject:menu];
|
|
70
|
+
}
|
|
64
71
|
return @{
|
|
65
72
|
@"layout": @"drawer",
|
|
66
|
-
@"sceneId": drawer.
|
|
67
|
-
@"children":
|
|
73
|
+
@"sceneId": drawer.hbd_sceneId,
|
|
74
|
+
@"children": children,
|
|
68
75
|
@"mode": [drawer hbd_mode],
|
|
69
76
|
};
|
|
70
77
|
}
|
|
@@ -82,29 +89,38 @@
|
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
|
|
85
|
-
- (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras
|
|
86
|
-
HBDDrawerController *drawer = [vc
|
|
92
|
+
- (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion {
|
|
93
|
+
HBDDrawerController *drawer = [vc hbd_drawerController];
|
|
87
94
|
if (!drawer) {
|
|
88
|
-
|
|
95
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Target scene is not inside a drawer."));
|
|
89
96
|
return;
|
|
90
97
|
}
|
|
91
98
|
|
|
92
|
-
callback(@[NSNull.null, @YES]);
|
|
93
|
-
|
|
94
99
|
if ([action isEqualToString:@"toggleMenu"]) {
|
|
95
100
|
[drawer toggleMenu];
|
|
101
|
+
completion(HBDDispatchResultOk());
|
|
96
102
|
return;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
if ([action isEqualToString:@"openMenu"]) {
|
|
100
106
|
[drawer openMenu];
|
|
107
|
+
completion(HBDDispatchResultOk());
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
if ([action isEqualToString:@"closeMenu"]) {
|
|
105
112
|
[drawer closeMenu];
|
|
113
|
+
completion(HBDDispatchResultOk());
|
|
106
114
|
return;
|
|
107
115
|
}
|
|
116
|
+
|
|
117
|
+
if ([action isEqualToString:@"setMenuInteractive"]) {
|
|
118
|
+
drawer.menuInteractive = [extras[@"enabled"] boolValue];
|
|
119
|
+
completion(HBDDispatchResultOk());
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, [NSString stringWithFormat:@"Unsupported drawer action: %@", action]));
|
|
108
124
|
}
|
|
109
125
|
|
|
110
126
|
- (void)invalidate {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- (instancetype)init {
|
|
25
25
|
if (self = [super init]) {
|
|
26
26
|
_layouts = [NSMutableArray new];
|
|
27
|
+
_navigators = [NSMutableArray new];
|
|
27
28
|
_actionNavigatorPairs = [NSMutableDictionary new];
|
|
28
29
|
_layoutNavigatorPairs = [NSMutableDictionary new];
|
|
29
30
|
_classLayoutPairs = [NSMutableDictionary new];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#import "HBDScreenNavigator.h"
|
|
2
2
|
|
|
3
|
-
#import "HBDReactBridgeManager.h"
|
|
4
3
|
#import "HBDNavigationController.h"
|
|
4
|
+
#import "HBDOrientationCoordinator.h"
|
|
5
|
+
#import "HBDReactBridgeManager.h"
|
|
5
6
|
#import "HBDViewController.h"
|
|
6
7
|
#import "UIViewController+HBD.h"
|
|
7
8
|
|
|
@@ -34,10 +35,10 @@
|
|
|
34
35
|
return nil;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
HBDViewController *screen = (HBDViewController *)
|
|
38
|
+
HBDViewController *screen = (HBDViewController *)vc;
|
|
38
39
|
return @{
|
|
39
40
|
@"layout": @"screen",
|
|
40
|
-
@"sceneId": screen.
|
|
41
|
+
@"sceneId": screen.hbd_sceneId,
|
|
41
42
|
@"moduleName": RCTNullIfNil(screen.moduleName),
|
|
42
43
|
@"mode": [screen hbd_mode],
|
|
43
44
|
};
|
|
@@ -45,133 +46,186 @@
|
|
|
45
46
|
|
|
46
47
|
- (HBDViewController *)primaryViewControllerWithViewController:(UIViewController *)vc {
|
|
47
48
|
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
48
|
-
return (HBDViewController *)
|
|
49
|
+
return (HBDViewController *)vc;
|
|
49
50
|
}
|
|
50
51
|
return nil;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
- (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras
|
|
54
|
+
- (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion {
|
|
54
55
|
if ([action isEqualToString:@"present"]) {
|
|
55
|
-
[self handlePresentWithViewController:vc extras:extras
|
|
56
|
+
[self handlePresentWithViewController:vc extras:extras completion:completion];
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
if ([action isEqualToString:@"dismiss"]) {
|
|
60
|
-
[self handleDismissWithViewController:vc
|
|
61
|
+
[self handleDismissWithViewController:vc completion:completion];
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
if ([action isEqualToString:@"showModal"]) {
|
|
65
|
-
[self handleShowModalWithViewController:vc extras:extras
|
|
66
|
+
[self handleShowModalWithViewController:vc extras:extras completion:completion];
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
if ([action isEqualToString:@"hideModal"]) {
|
|
70
|
-
[self handleDismissWithViewController:vc
|
|
71
|
+
[self handleDismissWithViewController:vc completion:completion];
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
if ([action isEqualToString:@"presentLayout"]) {
|
|
75
|
-
[self handlePresentLayoutWithViewController:vc extras:extras
|
|
76
|
+
[self handlePresentLayoutWithViewController:vc extras:extras completion:completion];
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
if ([action isEqualToString:@"showModalLayout"]) {
|
|
80
|
-
[self handleShowModalLayoutWithViewController:vc extras:extras
|
|
81
|
+
[self handleShowModalLayoutWithViewController:vc extras:extras completion:completion];
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, [NSString stringWithFormat:@"Unsupported screen action: %@", action]));
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
- (
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
- (BOOL)isInsideModalViewController:(UIViewController *)vc {
|
|
89
|
+
UIViewController *current = vc;
|
|
90
|
+
while (current != nil) {
|
|
91
|
+
if (current.modalPresentationStyle == UIModalPresentationOverFullScreen) {
|
|
92
|
+
return YES;
|
|
93
|
+
}
|
|
94
|
+
current = current.parentViewController;
|
|
95
|
+
}
|
|
96
|
+
return NO;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (void)handlePresentWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion {
|
|
100
|
+
if ([self isInsideModalViewController:presenting]) {
|
|
101
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Cannot present a scene on top of a modal."));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (![presenting hbd_canPresentViewController]) {
|
|
105
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeAlreadyPresenting, @"Target scene is already presenting another scene."));
|
|
88
106
|
return;
|
|
89
107
|
}
|
|
90
108
|
|
|
91
109
|
UIViewController *vc = [self viewControllerWithExtras:extras];
|
|
110
|
+
if (!vc) {
|
|
111
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Unable to create presented screen."));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
92
114
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
93
115
|
HBDNavigationController *nav = [[HBDNavigationController alloc] initWithRootViewController:vc];
|
|
94
116
|
nav.modalPresentationStyle = UIModalPresentationCurrentContext;
|
|
95
|
-
[nav
|
|
96
|
-
[vc
|
|
97
|
-
[vc
|
|
117
|
+
[nav setHbd_requestCode:requestCode];
|
|
118
|
+
[vc setHbd_requestCode:requestCode];
|
|
119
|
+
[vc setHbd_presentingSceneId:presenting.hbd_sceneId];
|
|
98
120
|
|
|
99
121
|
[presenting presentViewController:nav animated:YES completion:^{
|
|
100
|
-
|
|
122
|
+
completion(HBDDispatchResultOk());
|
|
101
123
|
}];
|
|
102
124
|
}
|
|
103
125
|
|
|
104
126
|
- (UIViewController *)modalHostViewControllerForViewController:(UIViewController *)vc {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
UIViewController *host = vc;
|
|
128
|
+
while (host.parentViewController != nil) {
|
|
129
|
+
host = host.parentViewController;
|
|
130
|
+
}
|
|
131
|
+
return host;
|
|
110
132
|
}
|
|
111
133
|
|
|
112
|
-
- (void)handleDismissWithViewController:(UIViewController *)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
134
|
+
- (void)handleDismissWithViewController:(UIViewController *)vc completion:(HBDDispatchCompletion)completion {
|
|
135
|
+
UIViewController *modalHost = [self modalHostViewControllerForViewController:vc];
|
|
136
|
+
BOOL isModal = modalHost.modalPresentationStyle == UIModalPresentationOverFullScreen;
|
|
137
|
+
BOOL animated = !isModal;
|
|
138
|
+
if (!isModal && [vc isKindOfClass:[HBDViewController class]]) {
|
|
139
|
+
HBDViewController *hbdvc = (HBDViewController *)vc;
|
|
140
|
+
animated = hbdvc.animatedTransition;
|
|
141
|
+
}
|
|
120
142
|
|
|
121
|
-
|
|
143
|
+
UIViewController *presenting = modalHost.presentingViewController;
|
|
144
|
+
if (!presenting && !modalHost.presentedViewController) {
|
|
145
|
+
RCTLogInfo(@"[Navigation] Nothing to dismiss for sceneId: %@", vc.hbd_sceneId);
|
|
146
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Nothing to dismiss."));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
122
149
|
|
|
123
150
|
[modalHost dismissViewControllerAnimated:animated completion:^{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
151
|
+
if (presenting != nil) {
|
|
152
|
+
HBDViewController *hbdvc = [[HBDReactBridgeManager get] primaryViewControllerWithViewController:presenting];
|
|
153
|
+
if (hbdvc != nil) {
|
|
154
|
+
[[HBDOrientationCoordinator shared] applyOrientationForViewController:hbdvc];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
completion(HBDDispatchResultOk());
|
|
131
158
|
}];
|
|
132
159
|
}
|
|
133
160
|
|
|
134
|
-
- (void)handleShowModalWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras
|
|
135
|
-
if (![presenting
|
|
136
|
-
|
|
161
|
+
- (void)handleShowModalWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion {
|
|
162
|
+
if (![presenting hbd_canPresentViewController]) {
|
|
163
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeAlreadyPresenting, @"Target scene is already presenting another scene."));
|
|
137
164
|
return;
|
|
138
165
|
}
|
|
139
166
|
|
|
140
167
|
UIViewController *vc = [self viewControllerWithExtras:extras];
|
|
168
|
+
if (!vc) {
|
|
169
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Unable to create modal screen."));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
141
172
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
142
173
|
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
143
174
|
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
144
|
-
[vc
|
|
175
|
+
[vc setHbd_requestCode:requestCode];
|
|
176
|
+
[vc setHbd_presentingSceneId:presenting.hbd_sceneId];
|
|
145
177
|
|
|
146
178
|
[presenting presentViewController:vc animated:NO completion:^{
|
|
147
|
-
|
|
179
|
+
completion(HBDDispatchResultOk());
|
|
148
180
|
}];
|
|
149
181
|
}
|
|
150
182
|
|
|
151
|
-
- (void)handlePresentLayoutWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras
|
|
183
|
+
- (void)handlePresentLayoutWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion {
|
|
184
|
+
if ([self isInsideModalViewController:presenting]) {
|
|
185
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Cannot present a scene on top of a modal."));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (![presenting hbd_canPresentViewController]) {
|
|
189
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeAlreadyPresenting, @"Target scene is already presenting another scene."));
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
152
193
|
NSDictionary *layout = extras[@"layout"];
|
|
153
194
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
154
195
|
UIViewController *vc = [[HBDReactBridgeManager get] viewControllerWithLayout:layout];
|
|
155
|
-
|
|
156
|
-
|
|
196
|
+
if (!vc) {
|
|
197
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Unable to create presented layout."));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
[vc setHbd_requestCode:requestCode];
|
|
201
|
+
[vc setHbd_presentingSceneId:presenting.hbd_sceneId];
|
|
157
202
|
vc.modalPresentationStyle = UIModalPresentationCurrentContext;
|
|
158
203
|
|
|
159
204
|
[presenting presentViewController:vc animated:YES completion:^{
|
|
160
|
-
|
|
205
|
+
completion(HBDDispatchResultOk());
|
|
161
206
|
}];
|
|
162
207
|
}
|
|
163
208
|
|
|
164
|
-
- (void)handleShowModalLayoutWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras
|
|
209
|
+
- (void)handleShowModalLayoutWithViewController:(UIViewController *)presenting extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion {
|
|
210
|
+
if (![presenting hbd_canPresentViewController]) {
|
|
211
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeAlreadyPresenting, @"Target scene is already presenting another scene."));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
165
215
|
NSInteger requestCode = [extras[@"requestCode"] integerValue];
|
|
166
216
|
NSDictionary *layout = extras[@"layout"];
|
|
167
217
|
UIViewController *vc = [[HBDReactBridgeManager get] viewControllerWithLayout:layout];
|
|
218
|
+
if (!vc) {
|
|
219
|
+
completion(HBDDispatchResultFail(HBDDispatchCodeInvalidAction, @"Unable to create modal layout."));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
168
222
|
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
169
223
|
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
170
|
-
[vc
|
|
171
|
-
[vc
|
|
224
|
+
[vc setHbd_requestCode:requestCode];
|
|
225
|
+
[vc setHbd_presentingSceneId:presenting.hbd_sceneId];
|
|
172
226
|
|
|
173
227
|
[presenting presentViewController:vc animated:NO completion:^{
|
|
174
|
-
|
|
228
|
+
completion(HBDDispatchResultOk());
|
|
175
229
|
}];
|
|
176
230
|
}
|
|
177
231
|
|