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
|
@@ -1,24 +1,58 @@
|
|
|
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 void HBDEmitSceneStateChange(NSString *sceneId, HBDSceneLifecycleState prevState, HBDSceneLifecycleState newState) {
|
|
13
|
+
if (sceneId.length == 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
NSDictionary *payload = @{
|
|
17
|
+
@"sceneId": sceneId,
|
|
18
|
+
@"state": HBDSceneLifecycleStateToString(newState),
|
|
19
|
+
@"prevState": HBDSceneLifecycleStateToString(prevState),
|
|
20
|
+
};
|
|
21
|
+
dispatch_block_t emitBlock = ^{
|
|
22
|
+
HBDNativeEvent *event = [HBDNativeEvent getInstance];
|
|
23
|
+
if (event) {
|
|
24
|
+
[event emitOnSceneStateChange:payload];
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
if ([NSThread isMainThread]) {
|
|
28
|
+
emitBlock();
|
|
29
|
+
} else {
|
|
30
|
+
dispatch_async(dispatch_get_main_queue(), emitBlock);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
9
34
|
@interface HBDViewController ()
|
|
10
35
|
|
|
11
36
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
12
37
|
@property(nonatomic, copy, readwrite) NSDictionary *options;
|
|
13
|
-
@property(nonatomic, assign) BOOL forceScreenLandscape;
|
|
14
38
|
@property(nonatomic, assign, readwrite) BOOL animatedTransition;
|
|
39
|
+
@property(nonatomic, strong, readwrite) HBDSceneLifecycleStateMachine *lifecycleStateMachine;
|
|
15
40
|
|
|
16
41
|
@end
|
|
17
42
|
|
|
18
43
|
@implementation HBDViewController
|
|
19
44
|
|
|
20
45
|
- (void)dealloc {
|
|
21
|
-
|
|
46
|
+
HBDSceneLifecycleState prevState = self.lifecycleStateMachine.state;
|
|
47
|
+
if (prevState != HBDSceneLifecycleStateDestroyed) {
|
|
48
|
+
NSString *sceneId = self.hbd_sceneId;
|
|
49
|
+
if (prevState == HBDSceneLifecycleStateVisible) {
|
|
50
|
+
HBDEmitSceneStateChange(sceneId, HBDSceneLifecycleStateVisible, HBDSceneLifecycleStateInvisible);
|
|
51
|
+
prevState = HBDSceneLifecycleStateInvisible;
|
|
52
|
+
}
|
|
53
|
+
HBDEmitSceneStateChange(sceneId, prevState, HBDSceneLifecycleStateDestroyed);
|
|
54
|
+
[self.lifecycleStateMachine markDestroyed];
|
|
55
|
+
}
|
|
22
56
|
}
|
|
23
57
|
|
|
24
58
|
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
@@ -32,24 +66,42 @@
|
|
|
32
66
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options {
|
|
33
67
|
if (self = [super initWithNibName:nil bundle:nil]) {
|
|
34
68
|
_moduleName = moduleName;
|
|
35
|
-
_options = options;
|
|
36
|
-
_props = props;
|
|
69
|
+
_options = options ? [options copy] : @{};
|
|
70
|
+
_props = props ? [props copy] : @{};
|
|
37
71
|
_animatedTransition = YES;
|
|
72
|
+
_lifecycleStateMachine = [[HBDSceneLifecycleStateMachine alloc] init];
|
|
73
|
+
__weak HBDViewController *weakSelf = self;
|
|
74
|
+
_lifecycleStateMachine.onStateChange = ^(HBDSceneLifecycleState prevState, HBDSceneLifecycleState newState) {
|
|
75
|
+
HBDViewController *strongSelf = weakSelf;
|
|
76
|
+
if (strongSelf) {
|
|
77
|
+
[strongSelf sceneLifecycleDidChangeFromState:prevState toState:newState];
|
|
78
|
+
}
|
|
79
|
+
};
|
|
38
80
|
|
|
39
|
-
if (
|
|
40
|
-
_animatedTransition = [
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (options[@"forceScreenLandscape"]) {
|
|
44
|
-
_forceScreenLandscape = [options[@"forceScreenLandscape"] boolValue];
|
|
81
|
+
if (_options[@"animatedTransition"]) {
|
|
82
|
+
_animatedTransition = [_options[@"animatedTransition"] boolValue];
|
|
45
83
|
}
|
|
46
84
|
|
|
47
|
-
[self
|
|
48
|
-
[self applyTabBarOptions:
|
|
85
|
+
[self applyOptions:_options];
|
|
86
|
+
[self applyTabBarOptions:_options];
|
|
49
87
|
}
|
|
50
88
|
return self;
|
|
51
89
|
}
|
|
52
90
|
|
|
91
|
+
- (HBDScreenOrientation)screenOrientation {
|
|
92
|
+
return HBDScreenOrientationFromString(self.options[@"orientation"]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
- (BOOL)isNativeManagedLifecycle {
|
|
96
|
+
return YES;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (void)sceneLifecycleDidChangeFromState:(HBDSceneLifecycleState)prevState toState:(HBDSceneLifecycleState)newState {
|
|
100
|
+
if ([HBDReactBridgeManager get].isReactModuleRegisterCompleted || newState == HBDSceneLifecycleStateDestroyed) {
|
|
101
|
+
HBDEmitSceneStateChange(self.hbd_sceneId, prevState, newState);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
53
105
|
- (void)setAppProperties:(NSDictionary *)props {
|
|
54
106
|
self.props = props;
|
|
55
107
|
}
|
|
@@ -59,7 +111,7 @@
|
|
|
59
111
|
}
|
|
60
112
|
|
|
61
113
|
- (BOOL)prefersStatusBarHidden {
|
|
62
|
-
|
|
114
|
+
return [self hbd_statusBarHidden];
|
|
63
115
|
}
|
|
64
116
|
|
|
65
117
|
- (BOOL)prefersHomeIndicatorAutoHidden {
|
|
@@ -70,103 +122,43 @@
|
|
|
70
122
|
}
|
|
71
123
|
|
|
72
124
|
- (void)viewWillAppear:(BOOL)animated {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
125
|
+
[super viewWillAppear:animated];
|
|
126
|
+
BOOL interactive = self.transitionCoordinator.interactive || self.navigationController.transitionCoordinator.interactive;
|
|
127
|
+
if (!interactive) {
|
|
128
|
+
[[HBDOrientationCoordinator shared] applyOrientationForViewController:self];
|
|
129
|
+
}
|
|
130
|
+
[self.lifecycleStateMachine viewWillAppearWithInteractiveTransition:interactive];
|
|
77
131
|
}
|
|
78
132
|
|
|
79
133
|
- (void)viewDidAppear:(BOOL)animated {
|
|
80
134
|
[super viewDidAppear:animated];
|
|
81
|
-
|
|
135
|
+
[[HBDOrientationCoordinator shared] applyOrientationForViewController:self];
|
|
136
|
+
[self.lifecycleStateMachine viewDidAppear];
|
|
82
137
|
}
|
|
83
138
|
|
|
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
|
-
}
|
|
139
|
+
- (void)viewWillDisappear:(BOOL)animated {
|
|
140
|
+
[super viewWillDisappear:animated];
|
|
141
|
+
BOOL interactive = self.transitionCoordinator.interactive || self.navigationController.transitionCoordinator.interactive;
|
|
142
|
+
[self.lifecycleStateMachine viewWillDisappearWithInteractiveTransition:interactive];
|
|
102
143
|
}
|
|
103
144
|
|
|
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
|
-
}
|
|
145
|
+
- (void)viewDidDisappear:(BOOL)animated {
|
|
146
|
+
[super viewDidDisappear:animated];
|
|
147
|
+
[self.lifecycleStateMachine viewDidDisappear];
|
|
141
148
|
}
|
|
142
149
|
|
|
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;
|
|
150
|
+
- (void)viewDidLayoutSubviews {
|
|
151
|
+
[super viewDidLayoutSubviews];
|
|
152
|
+
[self.lifecycleStateMachine viewDidLayoutSubviews];
|
|
165
153
|
}
|
|
166
154
|
|
|
167
155
|
- (void)viewDidLoad {
|
|
168
156
|
[super viewDidLoad];
|
|
169
157
|
[self setScreenBackgroundColor];
|
|
158
|
+
if ([self isNativeManagedLifecycle]) {
|
|
159
|
+
[self.lifecycleStateMachine markMounted];
|
|
160
|
+
[self.lifecycleStateMachine markFirstRenderComplete];
|
|
161
|
+
}
|
|
170
162
|
}
|
|
171
163
|
|
|
172
164
|
- (void)setScreenBackgroundColor {
|
|
@@ -179,7 +171,7 @@
|
|
|
179
171
|
if (screenColor) {
|
|
180
172
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
181
173
|
} else {
|
|
182
|
-
self.view.backgroundColor = [
|
|
174
|
+
self.view.backgroundColor = [self hbd_globalStyle].screenBackgroundColor;
|
|
183
175
|
}
|
|
184
176
|
}
|
|
185
177
|
|
|
@@ -200,73 +192,86 @@
|
|
|
200
192
|
|
|
201
193
|
- (void)applyTabBarOptions:(NSDictionary *)options {
|
|
202
194
|
NSDictionary *tabItem = options[@"tabItem"];
|
|
203
|
-
if (tabItem) {
|
|
204
|
-
|
|
205
|
-
// title
|
|
195
|
+
if ([tabItem isKindOfClass:[NSDictionary class]]) {
|
|
196
|
+
UITabBarItem *tabBarItem = self.tabBarItem;
|
|
206
197
|
tabBarItem.title = tabItem[@"title"];
|
|
207
198
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
199
|
+
NSDictionary *badge = tabItem[@"badge"];
|
|
200
|
+
tabBarItem.badgeValue = [self badgeText:badge];
|
|
201
|
+
HBDGlobalStyle *style = [self hbd_globalStyle];
|
|
202
|
+
tabBarItem.badgeColor = style.tabBarBadgeColor;
|
|
203
|
+
|
|
204
|
+
NSDictionary *unselectedIcon = tabItem[@"unselectedIcon"];
|
|
205
|
+
NSDictionary *icon = tabItem[@"icon"];
|
|
206
|
+
UITabBar *tabBar = self.tabBarController.tabBar;
|
|
207
|
+
BOOL dot = [self showDotBadge:badge];
|
|
208
|
+
|
|
209
|
+
UITabBarItemAppearance *itemAppearance = tabBar.standardAppearance.stackedLayoutAppearance;
|
|
210
|
+
UIColor *normalIconColor = itemAppearance.normal.iconColor ?: style.tabBarItemNormalColor;
|
|
211
|
+
UIColor *selectedIconColor = itemAppearance.selected.iconColor ?: style.tabBarItemSelectedColor;
|
|
212
|
+
if (unselectedIcon) {
|
|
213
|
+
tabBarItem.image = [[HBDUtils UIImage:unselectedIcon] hbd_withIconColor:nil badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
214
|
+
tabBarItem.selectedImage = [[HBDUtils UIImage:icon] hbd_withIconColor:nil badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
215
|
+
} else {
|
|
216
|
+
tabBarItem.image = [[HBDUtils UIImage:icon] hbd_withIconColor:normalIconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
217
|
+
tabBarItem.selectedImage = [[HBDUtils UIImage:icon] hbd_withIconColor:selectedIconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
218
|
+
}
|
|
219
|
+
self.tabBarItem = tabBarItem;
|
|
227
220
|
}
|
|
228
221
|
}
|
|
229
222
|
|
|
230
223
|
- (void)updateTabBarItem:(NSDictionary *)option {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
224
|
+
if (![option isKindOfClass:[NSDictionary class]]) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
NSMutableDictionary *mutableOptions = self.options ? [self.options mutableCopy] : [NSMutableDictionary dictionary];
|
|
228
|
+
NSDictionary *existingTabItem = [mutableOptions[@"tabItem"] isKindOfClass:[NSDictionary class]] ? mutableOptions[@"tabItem"] : @{};
|
|
229
|
+
NSMutableDictionary *mutableTabItem = [existingTabItem mutableCopy];
|
|
230
|
+
|
|
231
|
+
NSString *title = option[@"title"];
|
|
232
|
+
if (title != nil) {
|
|
233
|
+
mutableTabItem[@"title"] = title;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
NSDictionary *badge = option[@"badge"];
|
|
237
|
+
if (badge != nil) {
|
|
238
|
+
mutableTabItem[@"badge"] = badge;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
NSDictionary *icon = option[@"icon"];
|
|
242
|
+
if ([icon isKindOfClass:[NSDictionary class]]) {
|
|
243
|
+
if (icon[@"selected"] != nil) {
|
|
244
|
+
mutableTabItem[@"icon"] = icon[@"selected"];
|
|
245
|
+
}
|
|
246
|
+
if (icon[@"unselected"] != nil) {
|
|
247
|
+
mutableTabItem[@"unselectedIcon"] = icon[@"unselected"];
|
|
248
|
+
} else {
|
|
249
|
+
[mutableTabItem removeObjectForKey:@"unselectedIcon"];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
mutableOptions[@"tabItem"] = [mutableTabItem copy];
|
|
254
|
+
self.options = [mutableOptions copy];
|
|
255
|
+
[self applyTabBarOptions:self.options];
|
|
251
256
|
}
|
|
252
257
|
|
|
253
258
|
- (BOOL)showDotBadge:(NSDictionary *)badge {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
if (badge) {
|
|
260
|
+
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
261
|
+
return hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
|
|
262
|
+
}
|
|
263
|
+
return NO;
|
|
259
264
|
}
|
|
260
265
|
|
|
261
266
|
- (NSString *)badgeText:(NSDictionary *)badge {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
+
if (badge) {
|
|
268
|
+
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
269
|
+
return hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
|
|
270
|
+
}
|
|
271
|
+
return nil;
|
|
267
272
|
}
|
|
268
273
|
|
|
269
|
-
- (void)
|
|
274
|
+
- (void)applyOptions:(NSDictionary *)options {
|
|
270
275
|
NSString *statusBarStyle = options[@"statusBarStyle"];
|
|
271
276
|
if (statusBarStyle) {
|
|
272
277
|
if ([statusBarStyle isEqualToString:@"dark-content"]) {
|
|
@@ -279,11 +284,6 @@
|
|
|
279
284
|
// Native TopBar has been removed and UINavigationBar stays hidden.
|
|
280
285
|
self.extendedLayoutIncludesOpaqueBars = YES;
|
|
281
286
|
|
|
282
|
-
NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
|
|
283
|
-
if (swipeBackEnabled) {
|
|
284
|
-
self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
|
|
285
|
-
}
|
|
286
|
-
|
|
287
287
|
NSNumber *statusBarHidden = options[@"statusBarHidden"];
|
|
288
288
|
if (statusBarHidden) {
|
|
289
289
|
self.hbd_statusBarHidden = [statusBarHidden boolValue];
|
|
@@ -295,12 +295,11 @@
|
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
- (void)
|
|
299
|
-
self.options = [HBDUtils mergeItem:options withTarget:self.options];
|
|
298
|
+
- (void)updateOptions:(NSDictionary *)options {
|
|
299
|
+
self.options = [HBDUtils mergeItem:options withTarget:self.options ?: @{}];
|
|
300
300
|
|
|
301
301
|
NSMutableDictionary *target = [options mutableCopy];
|
|
302
|
-
|
|
303
|
-
[self applyNavigationBarOptions:target];
|
|
302
|
+
[self applyOptions:target];
|
|
304
303
|
|
|
305
304
|
NSString *screenColor = options[@"screenBackgroundColor"];
|
|
306
305
|
if (screenColor && [self isViewLoaded]) {
|
|
@@ -315,6 +314,9 @@
|
|
|
315
314
|
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
316
315
|
}
|
|
317
316
|
|
|
317
|
+
if (options[@"orientation"]) {
|
|
318
|
+
[[HBDOrientationCoordinator shared] sceneOptionsDidUpdate:self];
|
|
319
|
+
}
|
|
318
320
|
}
|
|
319
321
|
|
|
320
322
|
@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,34 @@
|
|
|
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 hbd_swipeBackEnabled;
|
|
10
13
|
@property(nonatomic, assign) BOOL hbd_statusBarHidden;
|
|
11
14
|
|
|
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 *
|
|
15
|
+
@property(nonatomic, copy, readonly) NSString *hbd_sceneId;
|
|
16
|
+
@property(nonatomic, copy, nullable) NSString *hbd_presentingSceneId;
|
|
17
|
+
@property(nonatomic, assign) NSInteger hbd_resultCode;
|
|
18
|
+
@property(nonatomic, assign) NSInteger hbd_requestCode;
|
|
19
|
+
@property(nonatomic, copy, nullable) NSDictionary *hbd_resultData;
|
|
17
20
|
|
|
18
|
-
- (BOOL)
|
|
21
|
+
- (BOOL)hbd_canPresentViewController;
|
|
19
22
|
|
|
20
|
-
- (void)
|
|
23
|
+
- (void)hbd_setResultCode:(NSInteger)resultCode resultData:(nullable NSDictionary *)data;
|
|
21
24
|
|
|
22
|
-
- (void)
|
|
25
|
+
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(nullable NSDictionary *)data requestCode:(NSInteger)requestCode;
|
|
23
26
|
|
|
24
|
-
- (HBDDrawerController *)
|
|
27
|
+
- (nullable HBDDrawerController *)hbd_drawerController;
|
|
25
28
|
|
|
26
29
|
- (NSString *)hbd_mode;
|
|
27
30
|
|
|
31
|
+
- (HBDGlobalStyle *)hbd_globalStyle;
|
|
32
|
+
|
|
28
33
|
@end
|
|
34
|
+
|
|
35
|
+
NS_ASSUME_NONNULL_END
|