hybrid-navigation 4.0.8 → 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 +5 -4
- package/android/proguard-rules.pro +3 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +114 -23
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +116 -13
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +83 -18
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +192 -28
- 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 +47 -15
- 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 -87
- 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/ReactSurfaceCleanup.java +3 -1
- 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 -27
- 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 +37 -19
- package/ios/React/HBDReactBridgeManager.mm +490 -96
- 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 +127 -6
- 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 -147
- 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,91 +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
|
-
[self setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
116
|
-
[self.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
117
|
-
[self.tabBarController setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
118
|
-
|
|
119
|
-
if (windowScene != nil) {
|
|
120
|
-
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:mask];
|
|
121
|
-
[windowScene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) {
|
|
122
|
-
#if DEBUG
|
|
123
|
-
if (error) {
|
|
124
|
-
NSLog(@"Failed to update geometry with UIInterfaceOrientationMask: %@", error);
|
|
125
|
-
}
|
|
126
|
-
#endif
|
|
127
|
-
}];
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
UIDevice *currentDevice = [UIDevice currentDevice];
|
|
131
|
-
[currentDevice setValue:@(UIInterfaceOrientationUnknown) forKey:@"orientation"];
|
|
132
|
-
[currentDevice setValue:@(orientation) forKey:@"orientation"];
|
|
133
|
-
[UIViewController attemptRotationToDeviceOrientation];
|
|
134
|
-
}
|
|
145
|
+
- (void)viewDidDisappear:(BOOL)animated {
|
|
146
|
+
[super viewDidDisappear:animated];
|
|
147
|
+
[self.lifecycleStateMachine viewDidDisappear];
|
|
135
148
|
}
|
|
136
149
|
|
|
137
|
-
- (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return window.windowScene;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
|
|
144
|
-
for (id connectedScene in array) {
|
|
145
|
-
if ([connectedScene isKindOfClass:[UIWindowScene class]]) {
|
|
146
|
-
UIWindowScene *scene = (UIWindowScene *)connectedScene;
|
|
147
|
-
if (scene.activationState == UISceneActivationStateForegroundActive) {
|
|
148
|
-
return scene;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return nil;
|
|
150
|
+
- (void)viewDidLayoutSubviews {
|
|
151
|
+
[super viewDidLayoutSubviews];
|
|
152
|
+
[self.lifecycleStateMachine viewDidLayoutSubviews];
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
- (void)viewDidLoad {
|
|
156
156
|
[super viewDidLoad];
|
|
157
157
|
[self setScreenBackgroundColor];
|
|
158
|
+
if ([self isNativeManagedLifecycle]) {
|
|
159
|
+
[self.lifecycleStateMachine markMounted];
|
|
160
|
+
[self.lifecycleStateMachine markFirstRenderComplete];
|
|
161
|
+
}
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
- (void)setScreenBackgroundColor {
|
|
@@ -167,7 +171,7 @@
|
|
|
167
171
|
if (screenColor) {
|
|
168
172
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
169
173
|
} else {
|
|
170
|
-
self.view.backgroundColor = [
|
|
174
|
+
self.view.backgroundColor = [self hbd_globalStyle].screenBackgroundColor;
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
177
|
|
|
@@ -188,73 +192,86 @@
|
|
|
188
192
|
|
|
189
193
|
- (void)applyTabBarOptions:(NSDictionary *)options {
|
|
190
194
|
NSDictionary *tabItem = options[@"tabItem"];
|
|
191
|
-
if (tabItem) {
|
|
192
|
-
|
|
193
|
-
// title
|
|
195
|
+
if ([tabItem isKindOfClass:[NSDictionary class]]) {
|
|
196
|
+
UITabBarItem *tabBarItem = self.tabBarItem;
|
|
194
197
|
tabBarItem.title = tabItem[@"title"];
|
|
195
198
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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;
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
- (void)updateTabBarItem:(NSDictionary *)option {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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];
|
|
239
256
|
}
|
|
240
257
|
|
|
241
258
|
- (BOOL)showDotBadge:(NSDictionary *)badge {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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;
|
|
247
264
|
}
|
|
248
265
|
|
|
249
266
|
- (NSString *)badgeText:(NSDictionary *)badge {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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;
|
|
255
272
|
}
|
|
256
273
|
|
|
257
|
-
- (void)
|
|
274
|
+
- (void)applyOptions:(NSDictionary *)options {
|
|
258
275
|
NSString *statusBarStyle = options[@"statusBarStyle"];
|
|
259
276
|
if (statusBarStyle) {
|
|
260
277
|
if ([statusBarStyle isEqualToString:@"dark-content"]) {
|
|
@@ -267,11 +284,6 @@
|
|
|
267
284
|
// Native TopBar has been removed and UINavigationBar stays hidden.
|
|
268
285
|
self.extendedLayoutIncludesOpaqueBars = YES;
|
|
269
286
|
|
|
270
|
-
NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
|
|
271
|
-
if (swipeBackEnabled) {
|
|
272
|
-
self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
|
|
273
|
-
}
|
|
274
|
-
|
|
275
287
|
NSNumber *statusBarHidden = options[@"statusBarHidden"];
|
|
276
288
|
if (statusBarHidden) {
|
|
277
289
|
self.hbd_statusBarHidden = [statusBarHidden boolValue];
|
|
@@ -283,12 +295,11 @@
|
|
|
283
295
|
}
|
|
284
296
|
}
|
|
285
297
|
|
|
286
|
-
- (void)
|
|
287
|
-
self.options = [HBDUtils mergeItem:options withTarget:self.options];
|
|
298
|
+
- (void)updateOptions:(NSDictionary *)options {
|
|
299
|
+
self.options = [HBDUtils mergeItem:options withTarget:self.options ?: @{}];
|
|
288
300
|
|
|
289
301
|
NSMutableDictionary *target = [options mutableCopy];
|
|
290
|
-
|
|
291
|
-
[self applyNavigationBarOptions:target];
|
|
302
|
+
[self applyOptions:target];
|
|
292
303
|
|
|
293
304
|
NSString *screenColor = options[@"screenBackgroundColor"];
|
|
294
305
|
if (screenColor && [self isViewLoaded]) {
|
|
@@ -303,6 +314,9 @@
|
|
|
303
314
|
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
304
315
|
}
|
|
305
316
|
|
|
317
|
+
if (options[@"orientation"]) {
|
|
318
|
+
[[HBDOrientationCoordinator shared] sceneOptionsDidUpdate:self];
|
|
319
|
+
}
|
|
306
320
|
}
|
|
307
321
|
|
|
308
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
|