hybrid-navigation 4.1.0 → 5.1.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 +116 -27
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +162 -13
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +2 -2
- 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 +18 -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 +10 -7
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +29 -9
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +31 -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 +74 -7
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +4 -0
- package/android/src/main/java/com/navigation/androidx/TabView.java +11 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/DispatchResult.java +71 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +18 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +34 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +20 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +179 -13
- 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 +283 -183
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +507 -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 +421 -92
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +227 -78
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +26 -0
- 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 +188 -26
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +67 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +42 -14
- package/dist/DeepLink.d.ts +3 -2
- package/dist/DeepLink.js +37 -14
- package/dist/NativeEvent.d.ts +17 -10
- package/dist/NativeNavigation.d.ts +24 -18
- package/dist/Navigation.d.ts +34 -19
- package/dist/Navigation.js +225 -90
- package/dist/NavigationComponentWrap.d.ts +5 -3
- package/dist/NavigationComponentWrap.js +3 -6
- package/dist/Navigator.d.ts +32 -42
- package/dist/Navigator.js +117 -91
- package/dist/Options.d.ts +15 -3
- package/dist/Route.d.ts +149 -17
- package/dist/defineRoutes.d.ts +19 -0
- package/dist/defineRoutes.js +6 -0
- package/dist/handler/DispatchCommandHandler.d.ts +25 -6
- package/dist/handler/DispatchCommandHandler.js +99 -17
- package/dist/handler/LayoutCommandHandler.d.ts +8 -7
- package/dist/handler/LayoutCommandHandler.js +24 -15
- package/dist/handler/LeaveGuardHandler.d.ts +17 -0
- package/dist/handler/LeaveGuardHandler.js +350 -0
- package/dist/handler/LifecycleEventHandler.d.ts +30 -0
- package/dist/handler/LifecycleEventHandler.js +169 -0
- package/dist/handler/PresentationCoordinator.d.ts +24 -0
- package/dist/handler/PresentationCoordinator.js +449 -0
- package/dist/handler/ResultEventHandler.d.ts +21 -9
- package/dist/handler/ResultEventHandler.js +96 -13
- package/dist/handler/TabEventHandler.d.ts +8 -0
- package/dist/handler/TabEventHandler.js +25 -0
- package/dist/hooks.d.ts +7 -2
- package/dist/hooks.js +46 -4
- package/dist/index.d.ts +24 -0
- package/dist/index.js +3 -2
- package/dist/reveal.d.ts +46 -0
- package/dist/reveal.js +431 -0
- package/dist/routeConfigRegistry.d.ts +6 -0
- package/dist/routeConfigRegistry.js +19 -0
- package/dist/routeGraph.d.ts +12 -0
- package/dist/routeGraph.js +68 -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 +106 -58
- 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 +3 -2
- package/dist/router/tabs.js +4 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.js +4 -0
- package/dist/testing.d.ts +79 -0
- package/dist/testing.js +251 -0
- package/ios/HBDGlobalStyle.h +29 -0
- package/ios/{GlobalStyle.mm → HBDGlobalStyle.mm} +43 -29
- package/ios/HybridNavigation.h +5 -1
- package/ios/Navigator/HBDDrawerNavigator.mm +24 -8
- package/ios/Navigator/HBDNavigatorRegistry.mm +1 -0
- package/ios/Navigator/HBDScreenNavigator.mm +278 -58
- package/ios/Navigator/HBDStackNavigator.mm +152 -61
- package/ios/Navigator/HBDTabNavigator.mm +60 -14
- package/ios/React/HBDNativeNavigation.mm +162 -123
- package/ios/React/HBDNavigator.h +37 -5
- package/ios/React/HBDOrientationCoordinator.h +29 -0
- package/ios/React/HBDOrientationCoordinator.mm +309 -0
- package/ios/React/HBDReactBridgeManager.h +46 -20
- package/ios/React/HBDReactBridgeManager.mm +496 -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 +31 -4
- package/ios/ViewController/HBDReactViewController.h +6 -0
- package/ios/ViewController/HBDReactViewController.mm +220 -106
- package/ios/ViewController/HBDTabBarController.h +15 -0
- package/ios/ViewController/HBDTabBarController.mm +227 -45
- package/ios/ViewController/HBDTabBarRenderer.h +28 -0
- package/ios/ViewController/HBDViewController.h +11 -3
- package/ios/ViewController/HBDViewController.mm +209 -159
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +3 -3
- package/ios/ViewController/UIViewController+HBD.h +18 -10
- package/ios/ViewController/UIViewController+HBD.mm +90 -65
- package/package.json +3 -1
- package/src/DeepLink.ts +41 -14
- package/src/NativeEvent.ts +18 -11
- package/src/NativeNavigation.ts +29 -31
- package/src/Navigation.ts +377 -120
- package/src/NavigationComponentWrap.tsx +18 -9
- package/src/Navigator.ts +219 -152
- package/src/Options.ts +12 -3
- package/src/Route.ts +228 -17
- package/src/defineRoutes.ts +46 -0
- package/src/handler/DispatchCommandHandler.ts +154 -21
- package/src/handler/LayoutCommandHandler.ts +40 -17
- package/src/handler/LeaveGuardHandler.ts +436 -0
- package/src/handler/LifecycleEventHandler.ts +219 -0
- package/src/handler/PresentationCoordinator.ts +560 -0
- package/src/handler/ResultEventHandler.ts +126 -19
- package/src/handler/TabEventHandler.ts +31 -0
- package/src/hooks.ts +75 -7
- package/src/index.ts +37 -2
- package/src/reveal.ts +565 -0
- package/src/routeConfigRegistry.ts +26 -0
- package/src/routeGraph.ts +87 -0
- package/src/router/drawer.ts +8 -5
- package/src/router/index.ts +139 -63
- package/src/router/screen.ts +3 -3
- package/src/router/stack.ts +80 -29
- package/src/router/tabs.ts +16 -7
- package/src/store.ts +6 -1
- package/src/testing.ts +395 -0
- package/testing.d.ts +1 -0
- package/testing.js +3 -0
- 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
|
@@ -1,24 +1,87 @@
|
|
|
1
1
|
#import "HBDViewController.h"
|
|
2
2
|
|
|
3
|
+
#import "HBDGlobalStyle.h"
|
|
4
|
+
#import "HBDNativeEvent.h"
|
|
5
|
+
#import "HBDOrientationCoordinator.h"
|
|
6
|
+
#import "HBDReactBridgeManager.h"
|
|
3
7
|
#import "HBDUtils.h"
|
|
4
|
-
#import "GlobalStyle.h"
|
|
5
8
|
#import "UIImage+WithBadge.h"
|
|
6
9
|
|
|
7
10
|
#import <React/RCTLog.h>
|
|
8
11
|
|
|
12
|
+
static NSString * _Nullable HBDResolvePresentingSceneId(UIViewController *vc) {
|
|
13
|
+
for (UIViewController *current = vc; current != nil; current = current.parentViewController) {
|
|
14
|
+
if (current.hbd_presentingSceneId.length > 0) {
|
|
15
|
+
return current.hbd_presentingSceneId;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return nil;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static void HBDEmitSceneStateChange(
|
|
22
|
+
NSString *sceneId,
|
|
23
|
+
HBDSceneLifecycleState prevState,
|
|
24
|
+
HBDSceneLifecycleState newState,
|
|
25
|
+
NSString * _Nullable moduleName,
|
|
26
|
+
NSString * _Nullable mode,
|
|
27
|
+
NSString * _Nullable presentingId
|
|
28
|
+
) {
|
|
29
|
+
if (sceneId.length == 0) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
NSMutableDictionary *payload = [@{
|
|
33
|
+
@"sceneId": sceneId,
|
|
34
|
+
@"state": HBDSceneLifecycleStateToString(newState),
|
|
35
|
+
@"prevState": HBDSceneLifecycleStateToString(prevState),
|
|
36
|
+
} mutableCopy];
|
|
37
|
+
if (moduleName.length > 0) {
|
|
38
|
+
payload[@"moduleName"] = moduleName;
|
|
39
|
+
}
|
|
40
|
+
if (mode.length > 0) {
|
|
41
|
+
payload[@"mode"] = mode;
|
|
42
|
+
}
|
|
43
|
+
if (presentingId.length > 0) {
|
|
44
|
+
payload[@"presentingId"] = presentingId;
|
|
45
|
+
}
|
|
46
|
+
NSDictionary *immutablePayload = [payload copy];
|
|
47
|
+
dispatch_block_t emitBlock = ^{
|
|
48
|
+
HBDNativeEvent *event = [HBDNativeEvent getInstance];
|
|
49
|
+
if (event) {
|
|
50
|
+
[event emitOnSceneStateChange:immutablePayload];
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
if ([NSThread isMainThread]) {
|
|
54
|
+
emitBlock();
|
|
55
|
+
} else {
|
|
56
|
+
dispatch_async(dispatch_get_main_queue(), emitBlock);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
9
60
|
@interface HBDViewController ()
|
|
10
61
|
|
|
11
62
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
12
63
|
@property(nonatomic, copy, readwrite) NSDictionary *options;
|
|
13
|
-
@property(nonatomic, assign) BOOL forceScreenLandscape;
|
|
14
64
|
@property(nonatomic, assign, readwrite) BOOL animatedTransition;
|
|
65
|
+
@property(nonatomic, strong, readwrite) HBDSceneLifecycleStateMachine *lifecycleStateMachine;
|
|
15
66
|
|
|
16
67
|
@end
|
|
17
68
|
|
|
18
69
|
@implementation HBDViewController
|
|
19
70
|
|
|
20
71
|
- (void)dealloc {
|
|
21
|
-
|
|
72
|
+
HBDSceneLifecycleState prevState = self.lifecycleStateMachine.state;
|
|
73
|
+
if (prevState != HBDSceneLifecycleStateDestroyed) {
|
|
74
|
+
NSString *sceneId = self.hbd_sceneId;
|
|
75
|
+
NSString *moduleName = self.moduleName;
|
|
76
|
+
NSString *mode = [self hbd_mode];
|
|
77
|
+
NSString *presentingId = HBDResolvePresentingSceneId(self);
|
|
78
|
+
if (prevState == HBDSceneLifecycleStateVisible) {
|
|
79
|
+
HBDEmitSceneStateChange(sceneId, HBDSceneLifecycleStateVisible, HBDSceneLifecycleStateInvisible, moduleName, mode, presentingId);
|
|
80
|
+
prevState = HBDSceneLifecycleStateInvisible;
|
|
81
|
+
}
|
|
82
|
+
HBDEmitSceneStateChange(sceneId, prevState, HBDSceneLifecycleStateDestroyed, moduleName, mode, presentingId);
|
|
83
|
+
[self.lifecycleStateMachine markDestroyed];
|
|
84
|
+
}
|
|
22
85
|
}
|
|
23
86
|
|
|
24
87
|
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
@@ -32,22 +95,58 @@
|
|
|
32
95
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options {
|
|
33
96
|
if (self = [super initWithNibName:nil bundle:nil]) {
|
|
34
97
|
_moduleName = moduleName;
|
|
35
|
-
_options = options;
|
|
36
|
-
_props = props;
|
|
98
|
+
_options = options ? [options copy] : @{};
|
|
99
|
+
_props = props ? [props copy] : @{};
|
|
37
100
|
_animatedTransition = YES;
|
|
101
|
+
_lifecycleStateMachine = [[HBDSceneLifecycleStateMachine alloc] init];
|
|
102
|
+
__weak HBDViewController *weakSelf = self;
|
|
103
|
+
_lifecycleStateMachine.onStateChange = ^(HBDSceneLifecycleState prevState, HBDSceneLifecycleState newState) {
|
|
104
|
+
HBDViewController *strongSelf = weakSelf;
|
|
105
|
+
if (strongSelf) {
|
|
106
|
+
[strongSelf sceneLifecycleDidChangeFromState:prevState toState:newState];
|
|
107
|
+
}
|
|
108
|
+
};
|
|
38
109
|
|
|
39
|
-
if (
|
|
40
|
-
_animatedTransition = [
|
|
110
|
+
if (_options[@"animatedTransition"]) {
|
|
111
|
+
_animatedTransition = [_options[@"animatedTransition"] boolValue];
|
|
41
112
|
}
|
|
42
113
|
|
|
43
|
-
|
|
44
|
-
|
|
114
|
+
[self applyOptions:_options];
|
|
115
|
+
[self applyTabBarOptions:_options];
|
|
116
|
+
}
|
|
117
|
+
return self;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (HBDScreenOrientation)screenOrientation {
|
|
121
|
+
return HBDScreenOrientationFromString(self.options[@"orientation"]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
- (nullable NSString *)tabKey {
|
|
125
|
+
NSDictionary *tabItem = self.options[@"tabItem"];
|
|
126
|
+
if ([tabItem isKindOfClass:[NSDictionary class]]) {
|
|
127
|
+
NSString *key = tabItem[@"key"];
|
|
128
|
+
if ([key isKindOfClass:[NSString class]] && key.length > 0) {
|
|
129
|
+
return key;
|
|
45
130
|
}
|
|
131
|
+
}
|
|
132
|
+
return nil;
|
|
133
|
+
}
|
|
46
134
|
|
|
47
|
-
|
|
48
|
-
|
|
135
|
+
- (BOOL)isNativeManagedLifecycle {
|
|
136
|
+
return YES;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (void)sceneLifecycleDidChangeFromState:(HBDSceneLifecycleState)prevState toState:(HBDSceneLifecycleState)newState {
|
|
140
|
+
if ([HBDReactBridgeManager get].isReactModuleRegisterCompleted || newState == HBDSceneLifecycleStateDestroyed) {
|
|
141
|
+
HBDEmitSceneStateChange(
|
|
142
|
+
self.hbd_sceneId,
|
|
143
|
+
prevState,
|
|
144
|
+
newState,
|
|
145
|
+
self.moduleName,
|
|
146
|
+
[self hbd_mode],
|
|
147
|
+
HBDResolvePresentingSceneId(self)
|
|
148
|
+
);
|
|
49
149
|
}
|
|
50
|
-
return self;
|
|
51
150
|
}
|
|
52
151
|
|
|
53
152
|
- (void)setAppProperties:(NSDictionary *)props {
|
|
@@ -59,7 +158,7 @@
|
|
|
59
158
|
}
|
|
60
159
|
|
|
61
160
|
- (BOOL)prefersStatusBarHidden {
|
|
62
|
-
|
|
161
|
+
return [self hbd_statusBarHidden];
|
|
63
162
|
}
|
|
64
163
|
|
|
65
164
|
- (BOOL)prefersHomeIndicatorAutoHidden {
|
|
@@ -70,103 +169,44 @@
|
|
|
70
169
|
}
|
|
71
170
|
|
|
72
171
|
- (void)viewWillAppear:(BOOL)animated {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
172
|
+
[super viewWillAppear:animated];
|
|
173
|
+
BOOL interactive = self.transitionCoordinator.interactive || self.navigationController.transitionCoordinator.interactive;
|
|
174
|
+
if (!interactive) {
|
|
175
|
+
[[HBDOrientationCoordinator shared] applyOrientationForViewController:self];
|
|
176
|
+
}
|
|
177
|
+
[self.lifecycleStateMachine viewWillAppearWithInteractiveTransition:interactive];
|
|
77
178
|
}
|
|
78
179
|
|
|
79
180
|
- (void)viewDidAppear:(BOOL)animated {
|
|
80
181
|
[super viewDidAppear:animated];
|
|
81
|
-
|
|
182
|
+
[[HBDOrientationCoordinator shared] applyOrientationForViewController:self];
|
|
183
|
+
[self.lifecycleStateMachine viewDidAppear];
|
|
82
184
|
}
|
|
83
185
|
|
|
84
|
-
- (void)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
UIInterfaceOrientation current = windowScene.interfaceOrientation;
|
|
91
|
-
BOOL isModal = [[self hbd_mode] isEqual:@"modal"];
|
|
92
|
-
|
|
93
|
-
if (!self.forceScreenLandscape && current != UIInterfaceOrientationPortrait && !isModal) {
|
|
94
|
-
[self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
|
|
95
|
-
} else if (self.forceScreenLandscape && !UIInterfaceOrientationIsLandscape(current)) {
|
|
96
|
-
UIInterfaceOrientation target = UIInterfaceOrientationLandscapeRight;
|
|
97
|
-
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
|
|
98
|
-
target = UIInterfaceOrientationLandscapeLeft;
|
|
99
|
-
}
|
|
100
|
-
[self setScreenOrientation:target usingMask:UIInterfaceOrientationMaskLandscape];
|
|
101
|
-
}
|
|
186
|
+
- (void)viewWillDisappear:(BOOL)animated {
|
|
187
|
+
[super viewWillDisappear:animated];
|
|
188
|
+
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator ?: self.navigationController.transitionCoordinator;
|
|
189
|
+
BOOL interactive = coordinator.interactive;
|
|
190
|
+
[self.lifecycleStateMachine viewWillDisappearWithInteractiveTransition:interactive];
|
|
102
191
|
}
|
|
103
192
|
|
|
104
|
-
- (void)
|
|
105
|
-
|
|
106
|
-
[self.
|
|
107
|
-
[self.navigationController.view endEditing:YES];
|
|
108
|
-
for (UIWindow *window in windowScene.windows) {
|
|
109
|
-
[window endEditing:YES];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
[GlobalStyle globalStyle].interfaceOrientation = mask;
|
|
113
|
-
if (@available(iOS 16.0, *)) {
|
|
114
|
-
// Ensure orientation capability is updated before geometry request.
|
|
115
|
-
UIViewController *controller = self;
|
|
116
|
-
while (controller != nil) {
|
|
117
|
-
[controller setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
118
|
-
controller = controller.parentViewController;
|
|
119
|
-
}
|
|
120
|
-
UIViewController *rootViewController = self.view.window.rootViewController ?: windowScene.keyWindow.rootViewController;
|
|
121
|
-
if (rootViewController != nil) {
|
|
122
|
-
[rootViewController setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (windowScene != nil) {
|
|
126
|
-
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:mask];
|
|
127
|
-
[windowScene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) {
|
|
128
|
-
#if DEBUG
|
|
129
|
-
if (error) {
|
|
130
|
-
NSLog(@"Failed to update geometry with UIInterfaceOrientationMask: %@", error);
|
|
131
|
-
}
|
|
132
|
-
#endif
|
|
133
|
-
}];
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
UIDevice *currentDevice = [UIDevice currentDevice];
|
|
137
|
-
[currentDevice setValue:@(UIInterfaceOrientationUnknown) forKey:@"orientation"];
|
|
138
|
-
[currentDevice setValue:@(orientation) forKey:@"orientation"];
|
|
139
|
-
[UIViewController attemptRotationToDeviceOrientation];
|
|
140
|
-
}
|
|
193
|
+
- (void)viewDidDisappear:(BOOL)animated {
|
|
194
|
+
[super viewDidDisappear:animated];
|
|
195
|
+
[self.lifecycleStateMachine viewDidDisappear];
|
|
141
196
|
}
|
|
142
197
|
|
|
143
|
-
- (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return window.windowScene;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
|
|
150
|
-
UIWindowScene *fallbackScene = nil;
|
|
151
|
-
for (id connectedScene in array) {
|
|
152
|
-
if ([connectedScene isKindOfClass:[UIWindowScene class]]) {
|
|
153
|
-
UIWindowScene *scene = (UIWindowScene *)connectedScene;
|
|
154
|
-
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
|
155
|
-
return scene;
|
|
156
|
-
}
|
|
157
|
-
if (scene.activationState == UISceneActivationStateForegroundInactive) {
|
|
158
|
-
fallbackScene = scene;
|
|
159
|
-
} else if (!fallbackScene) {
|
|
160
|
-
fallbackScene = scene;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return fallbackScene;
|
|
198
|
+
- (void)viewDidLayoutSubviews {
|
|
199
|
+
[super viewDidLayoutSubviews];
|
|
200
|
+
[self.lifecycleStateMachine viewDidLayoutSubviews];
|
|
165
201
|
}
|
|
166
202
|
|
|
167
203
|
- (void)viewDidLoad {
|
|
168
204
|
[super viewDidLoad];
|
|
169
205
|
[self setScreenBackgroundColor];
|
|
206
|
+
if ([self isNativeManagedLifecycle]) {
|
|
207
|
+
[self.lifecycleStateMachine markMounted];
|
|
208
|
+
[self.lifecycleStateMachine markFirstRenderComplete];
|
|
209
|
+
}
|
|
170
210
|
}
|
|
171
211
|
|
|
172
212
|
- (void)setScreenBackgroundColor {
|
|
@@ -179,12 +219,12 @@
|
|
|
179
219
|
if (screenColor) {
|
|
180
220
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
181
221
|
} else {
|
|
182
|
-
self.view.backgroundColor = [
|
|
222
|
+
self.view.backgroundColor = [self hbd_globalStyle].screenBackgroundColor;
|
|
183
223
|
}
|
|
184
224
|
}
|
|
185
225
|
|
|
186
226
|
- (void)setModalBackgroundColor {
|
|
187
|
-
self.view.backgroundColor = UIColor.clearColor;
|
|
227
|
+
self.view.backgroundColor = [self hbd_globalStyle].modalBackgroundColor ?: UIColor.clearColor;
|
|
188
228
|
|
|
189
229
|
NSString *screenColor = self.options[@"screenBackgroundColor"];
|
|
190
230
|
|
|
@@ -200,73 +240,86 @@
|
|
|
200
240
|
|
|
201
241
|
- (void)applyTabBarOptions:(NSDictionary *)options {
|
|
202
242
|
NSDictionary *tabItem = options[@"tabItem"];
|
|
203
|
-
if (tabItem) {
|
|
204
|
-
|
|
205
|
-
// title
|
|
243
|
+
if ([tabItem isKindOfClass:[NSDictionary class]]) {
|
|
244
|
+
UITabBarItem *tabBarItem = self.tabBarItem;
|
|
206
245
|
tabBarItem.title = tabItem[@"title"];
|
|
207
246
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
247
|
+
NSDictionary *badge = tabItem[@"badge"];
|
|
248
|
+
tabBarItem.badgeValue = [self badgeText:badge];
|
|
249
|
+
HBDGlobalStyle *style = [self hbd_globalStyle];
|
|
250
|
+
tabBarItem.badgeColor = style.tabBarBadgeColor;
|
|
251
|
+
|
|
252
|
+
NSDictionary *unselectedIcon = tabItem[@"unselectedIcon"];
|
|
253
|
+
NSDictionary *icon = tabItem[@"icon"];
|
|
254
|
+
UITabBar *tabBar = self.tabBarController.tabBar;
|
|
255
|
+
BOOL dot = [self showDotBadge:badge];
|
|
256
|
+
|
|
257
|
+
UITabBarItemAppearance *itemAppearance = tabBar.standardAppearance.stackedLayoutAppearance;
|
|
258
|
+
UIColor *normalIconColor = itemAppearance.normal.iconColor ?: style.tabBarItemNormalColor;
|
|
259
|
+
UIColor *selectedIconColor = itemAppearance.selected.iconColor ?: style.tabBarItemSelectedColor;
|
|
260
|
+
if (unselectedIcon) {
|
|
261
|
+
tabBarItem.image = [[HBDUtils UIImage:unselectedIcon] hbd_withIconColor:nil badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
262
|
+
tabBarItem.selectedImage = [[HBDUtils UIImage:icon] hbd_withIconColor:nil badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
263
|
+
} else {
|
|
264
|
+
tabBarItem.image = [[HBDUtils UIImage:icon] hbd_withIconColor:normalIconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
265
|
+
tabBarItem.selectedImage = [[HBDUtils UIImage:icon] hbd_withIconColor:selectedIconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
266
|
+
}
|
|
267
|
+
self.tabBarItem = tabBarItem;
|
|
227
268
|
}
|
|
228
269
|
}
|
|
229
270
|
|
|
230
271
|
- (void)updateTabBarItem:(NSDictionary *)option {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
272
|
+
if (![option isKindOfClass:[NSDictionary class]]) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
NSMutableDictionary *mutableOptions = self.options ? [self.options mutableCopy] : [NSMutableDictionary dictionary];
|
|
276
|
+
NSDictionary *existingTabItem = [mutableOptions[@"tabItem"] isKindOfClass:[NSDictionary class]] ? mutableOptions[@"tabItem"] : @{};
|
|
277
|
+
NSMutableDictionary *mutableTabItem = [existingTabItem mutableCopy];
|
|
278
|
+
|
|
279
|
+
NSString *title = option[@"title"];
|
|
280
|
+
if (title != nil) {
|
|
281
|
+
mutableTabItem[@"title"] = title;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
NSDictionary *badge = option[@"badge"];
|
|
285
|
+
if (badge != nil) {
|
|
286
|
+
mutableTabItem[@"badge"] = badge;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
NSDictionary *icon = option[@"icon"];
|
|
290
|
+
if ([icon isKindOfClass:[NSDictionary class]]) {
|
|
291
|
+
if (icon[@"selected"] != nil) {
|
|
292
|
+
mutableTabItem[@"icon"] = icon[@"selected"];
|
|
293
|
+
}
|
|
294
|
+
if (icon[@"unselected"] != nil) {
|
|
295
|
+
mutableTabItem[@"unselectedIcon"] = icon[@"unselected"];
|
|
296
|
+
} else {
|
|
297
|
+
[mutableTabItem removeObjectForKey:@"unselectedIcon"];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
mutableOptions[@"tabItem"] = [mutableTabItem copy];
|
|
302
|
+
self.options = [mutableOptions copy];
|
|
303
|
+
[self applyTabBarOptions:self.options];
|
|
251
304
|
}
|
|
252
305
|
|
|
253
306
|
- (BOOL)showDotBadge:(NSDictionary *)badge {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
307
|
+
if (badge) {
|
|
308
|
+
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
309
|
+
return hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
|
|
310
|
+
}
|
|
311
|
+
return NO;
|
|
259
312
|
}
|
|
260
313
|
|
|
261
314
|
- (NSString *)badgeText:(NSDictionary *)badge {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
315
|
+
if (badge) {
|
|
316
|
+
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
317
|
+
return hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
|
|
318
|
+
}
|
|
319
|
+
return nil;
|
|
267
320
|
}
|
|
268
321
|
|
|
269
|
-
- (void)
|
|
322
|
+
- (void)applyOptions:(NSDictionary *)options {
|
|
270
323
|
NSString *statusBarStyle = options[@"statusBarStyle"];
|
|
271
324
|
if (statusBarStyle) {
|
|
272
325
|
if ([statusBarStyle isEqualToString:@"dark-content"]) {
|
|
@@ -279,11 +332,6 @@
|
|
|
279
332
|
// Native TopBar has been removed and UINavigationBar stays hidden.
|
|
280
333
|
self.extendedLayoutIncludesOpaqueBars = YES;
|
|
281
334
|
|
|
282
|
-
NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
|
|
283
|
-
if (swipeBackEnabled) {
|
|
284
|
-
self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
|
|
285
|
-
}
|
|
286
|
-
|
|
287
335
|
NSNumber *statusBarHidden = options[@"statusBarHidden"];
|
|
288
336
|
if (statusBarHidden) {
|
|
289
337
|
self.hbd_statusBarHidden = [statusBarHidden boolValue];
|
|
@@ -295,12 +343,11 @@
|
|
|
295
343
|
}
|
|
296
344
|
}
|
|
297
345
|
|
|
298
|
-
- (void)
|
|
299
|
-
self.options = [HBDUtils mergeItem:options withTarget:self.options];
|
|
346
|
+
- (void)updateOptions:(NSDictionary *)options {
|
|
347
|
+
self.options = [HBDUtils mergeItem:options withTarget:self.options ?: @{}];
|
|
300
348
|
|
|
301
349
|
NSMutableDictionary *target = [options mutableCopy];
|
|
302
|
-
|
|
303
|
-
[self applyNavigationBarOptions:target];
|
|
350
|
+
[self applyOptions:target];
|
|
304
351
|
|
|
305
352
|
NSString *screenColor = options[@"screenBackgroundColor"];
|
|
306
353
|
if (screenColor && [self isViewLoaded]) {
|
|
@@ -315,6 +362,9 @@
|
|
|
315
362
|
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
316
363
|
}
|
|
317
364
|
|
|
365
|
+
if (options[@"orientation"]) {
|
|
366
|
+
[[HBDOrientationCoordinator shared] sceneOptionsDidUpdate:self];
|
|
367
|
+
}
|
|
318
368
|
}
|
|
319
369
|
|
|
320
370
|
@end
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
@interface UINavigationController (HBD)
|
|
4
4
|
|
|
5
|
-
- (void)
|
|
5
|
+
- (void)hbd_redirectToViewController:(UIViewController *)controller animated:(BOOL)animated;
|
|
6
6
|
|
|
7
|
-
- (void)
|
|
7
|
+
- (void)hbd_redirectToViewController:(UIViewController *)controller target:(UIViewController *)target animated:(BOOL)animated;
|
|
8
8
|
|
|
9
9
|
@end
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
@implementation UINavigationController (HBD)
|
|
6
6
|
|
|
7
|
-
- (void)
|
|
8
|
-
[self
|
|
7
|
+
- (void)hbd_redirectToViewController:(UIViewController *)controller animated:(BOOL)animated {
|
|
8
|
+
[self hbd_redirectToViewController:controller target:self.topViewController animated:animated];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
- (void)
|
|
11
|
+
- (void)hbd_redirectToViewController:(UIViewController *)controller target:(UIViewController *)target animated:(BOOL)animated {
|
|
12
12
|
NSMutableArray *children = [self.childViewControllers mutableCopy];
|
|
13
13
|
NSUInteger index = [children indexOfObject:target];
|
|
14
14
|
if (index == NSNotFound) {
|
|
@@ -2,27 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
#import <UIKit/UIKit.h>
|
|
4
4
|
|
|
5
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
+
|
|
7
|
+
@class HBDGlobalStyle;
|
|
8
|
+
|
|
5
9
|
@interface UIViewController (HBD)
|
|
6
10
|
|
|
7
11
|
@property(nonatomic, assign) UIBarStyle hbd_barStyle;
|
|
8
12
|
@property(nonatomic, assign) BOOL hbd_backInteractive;
|
|
9
|
-
@property(nonatomic, assign) BOOL
|
|
13
|
+
@property(nonatomic, assign) BOOL hbd_beforeRemoveEnabled;
|
|
10
14
|
@property(nonatomic, assign) BOOL hbd_statusBarHidden;
|
|
11
15
|
|
|
12
|
-
@property(nonatomic, copy, readonly) NSString *
|
|
13
|
-
@property(nonatomic, copy) NSString *
|
|
14
|
-
@property(nonatomic, assign) NSInteger
|
|
15
|
-
@property(nonatomic, assign) NSInteger
|
|
16
|
-
@property(nonatomic, copy) NSDictionary *
|
|
16
|
+
@property(nonatomic, copy, readonly) NSString *hbd_sceneId;
|
|
17
|
+
@property(nonatomic, copy, nullable) NSString *hbd_presentingSceneId;
|
|
18
|
+
@property(nonatomic, assign) NSInteger hbd_resultCode;
|
|
19
|
+
@property(nonatomic, assign) NSInteger hbd_requestCode;
|
|
20
|
+
@property(nonatomic, copy, nullable) NSDictionary *hbd_resultData;
|
|
17
21
|
|
|
18
|
-
- (BOOL)
|
|
22
|
+
- (BOOL)hbd_canPresentViewController;
|
|
19
23
|
|
|
20
|
-
- (void)
|
|
24
|
+
- (void)hbd_setResultCode:(NSInteger)resultCode resultData:(nullable NSDictionary *)data;
|
|
21
25
|
|
|
22
|
-
- (void)
|
|
26
|
+
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(nullable NSDictionary *)data requestCode:(NSInteger)requestCode;
|
|
23
27
|
|
|
24
|
-
- (HBDDrawerController *)
|
|
28
|
+
- (nullable HBDDrawerController *)hbd_drawerController;
|
|
25
29
|
|
|
26
30
|
- (NSString *)hbd_mode;
|
|
27
31
|
|
|
32
|
+
- (HBDGlobalStyle *)hbd_globalStyle;
|
|
33
|
+
|
|
28
34
|
@end
|
|
35
|
+
|
|
36
|
+
NS_ASSUME_NONNULL_END
|