hybrid-navigation 3.1.5 → 4.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/README.md +4 -4
- package/android/build.gradle +1 -2
- package/android/src/main/java/androidx/fragment/app/InternalFragment.java +22 -0
- package/android/src/main/java/com/navigation/androidx/AppUtils.java +54 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +211 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +685 -0
- package/android/src/main/java/com/navigation/androidx/BarStyle.java +7 -0
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +89 -0
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +57 -0
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +392 -0
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +318 -0
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +86 -0
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +23 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +195 -0
- package/android/src/main/java/com/navigation/androidx/PresentationStyle.java +5 -0
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +111 -0
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +287 -0
- package/android/src/main/java/com/navigation/androidx/StackLayoutInflater.java +34 -0
- package/android/src/main/java/com/navigation/androidx/Style.java +141 -0
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +240 -0
- package/android/src/main/java/com/navigation/androidx/SystemUI30.java +87 -0
- package/android/src/main/java/com/navigation/androidx/TabBar.java +353 -0
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +313 -0
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +102 -0
- package/android/src/main/java/com/navigation/androidx/TabBarProvider.java +30 -0
- package/android/src/main/java/com/navigation/androidx/TabView.java +226 -0
- package/android/src/main/java/com/navigation/androidx/TransitionAnimation.java +31 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +6 -243
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +8 -141
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +4 -68
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +12 -61
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +0 -47
- package/android/src/main/java/com/reactnative/hybridnavigation/Parameters.java +3 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +2 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +1 -88
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +0 -5
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +0 -18
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +1 -10
- package/android/src/main/res/anim/{nav_push_translucent_enter.xml → nav_delay.xml} +1 -1
- package/android/src/main/res/anim/{nav_pop_translucent_enter.xml → nav_dismiss_enter.xml} +1 -1
- package/android/src/main/res/anim/nav_dismiss_exit.xml +6 -0
- package/android/src/main/res/anim/nav_fade_in.xml +5 -0
- package/android/src/main/res/anim/nav_fade_out.xml +5 -0
- package/android/src/main/res/anim/nav_pop_enter.xml +6 -0
- package/android/src/main/res/anim/nav_pop_exit.xml +6 -0
- package/android/src/main/res/anim/nav_present_enter.xml +6 -0
- package/android/src/main/res/anim/{nav_pop_translucent_exit.xml → nav_present_exit.xml} +1 -1
- package/android/src/main/res/anim/nav_push_enter.xml +6 -0
- package/android/src/main/res/anim/{nav_push_translucent_exit.xml → nav_push_exit.xml} +2 -1
- package/android/src/main/res/drawable/nav_dot_badge_background.xml +5 -0
- package/android/src/main/res/drawable/nav_text_badge_background.xml +5 -0
- package/android/src/main/res/drawable-v21/nav_toolbar_button_item_background.xml +24 -0
- package/android/src/main/res/layout/nav_fragment_drawer.xml +23 -0
- package/android/src/main/res/layout/nav_fragment_navigation.xml +7 -0
- package/android/src/main/res/layout/nav_fragment_tabbar.xml +13 -0
- package/android/src/main/res/layout/nav_tab_bar_container.xml +15 -0
- package/android/src/main/res/layout/nav_tab_bar_item.xml +49 -0
- package/android/src/main/res/values/dimens.xml +11 -0
- package/android/src/main/res/values/strings.xml +1 -0
- package/dist/{NativeEvent.d.ts → src/NativeEvent.d.ts} +0 -5
- package/dist/{NativeGarden.d.ts → src/NativeGarden.d.ts} +0 -5
- package/dist/{Navigation.d.ts → src/Navigation.d.ts} +1 -11
- package/dist/{Navigation.js → src/Navigation.js} +1 -31
- package/dist/{Navigator.js → src/Navigator.js} +0 -4
- package/dist/src/Options.d.ts +61 -0
- package/dist/src/Options.js +2 -0
- package/ios/GlobalStyle.h +1 -9
- package/ios/GlobalStyle.mm +48 -310
- package/ios/HBDUtils.h +0 -14
- package/ios/HBDUtils.mm +1 -116
- package/ios/HybridNavigation.h +0 -3
- package/ios/Navigator/HBDScreenNavigator.mm +12 -4
- package/ios/Navigator/HBDStackNavigator.mm +36 -39
- package/ios/React/HBDNativeGarden.mm +0 -40
- package/ios/React/HBDNativeNavigation.mm +21 -16
- package/ios/View/HBDRootView.h +0 -2
- package/ios/View/HBDRootView.mm +0 -21
- package/ios/ViewController/HBDDrawerController.mm +3 -11
- package/ios/ViewController/HBDFadeAnimation.mm +10 -26
- package/ios/ViewController/HBDNavigationController.h +0 -6
- package/ios/ViewController/HBDNavigationController.mm +42 -661
- package/ios/ViewController/HBDReactViewController.mm +7 -101
- package/ios/ViewController/HBDTabBarController.mm +10 -6
- package/ios/ViewController/HBDViewController.mm +58 -182
- package/ios/ViewController/UINavigationController+HBD.mm +0 -3
- package/ios/ViewController/UIViewController+HBD.h +0 -9
- package/ios/ViewController/UIViewController+HBD.mm +1 -131
- package/package.json +1 -1
- package/src/NativeEvent.ts +0 -6
- package/src/NativeGarden.ts +0 -11
- package/src/Navigation.ts +2 -68
- package/src/Navigator.ts +0 -5
- package/src/Options.ts +2 -76
- package/dist/Options.d.ts +0 -129
- package/dist/Options.js +0 -6
- package/dist/handler/BarButtonEventHandler.d.ts +0 -10
- package/dist/handler/BarButtonEventHandler.js +0 -38
- package/ios/View/HBDBackBarButtonItem.h +0 -9
- package/ios/View/HBDBackBarButtonItem.mm +0 -13
- package/ios/View/HBDBarButtonItem.h +0 -24
- package/ios/View/HBDBarButtonItem.mm +0 -69
- package/ios/View/HBDNavigationBar.h +0 -15
- package/ios/View/HBDNavigationBar.mm +0 -207
- package/ios/View/HBDTitleView.h +0 -7
- package/ios/View/HBDTitleView.mm +0 -66
- package/ios/ViewController/HBDPopAnimation.h +0 -9
- package/ios/ViewController/HBDPopAnimation.mm +0 -27
- package/ios/ViewController/HBDPushAnimation.h +0 -9
- package/ios/ViewController/HBDPushAnimation.mm +0 -28
- package/ios/ViewController/HBDViewController+Garden.h +0 -17
- package/ios/ViewController/HBDViewController+Garden.mm +0 -183
- package/src/handler/BarButtonEventHandler.ts +0 -50
- /package/dist/{DeepLink.d.ts → src/DeepLink.d.ts} +0 -0
- /package/dist/{DeepLink.js → src/DeepLink.js} +0 -0
- /package/dist/{NativeEvent.js → src/NativeEvent.js} +0 -0
- /package/dist/{NativeGarden.js → src/NativeGarden.js} +0 -0
- /package/dist/{NativeNavigation.d.ts → src/NativeNavigation.d.ts} +0 -0
- /package/dist/{NativeNavigation.js → src/NativeNavigation.js} +0 -0
- /package/dist/{NavigationComponentWrap.d.ts → src/NavigationComponentWrap.d.ts} +0 -0
- /package/dist/{NavigationComponentWrap.js → src/NavigationComponentWrap.js} +0 -0
- /package/dist/{Navigator.d.ts → src/Navigator.d.ts} +0 -0
- /package/dist/{Route.d.ts → src/Route.d.ts} +0 -0
- /package/dist/{Route.js → src/Route.js} +0 -0
- /package/dist/{handler → src/handler}/DispatchCommandHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/DispatchCommandHandler.js +0 -0
- /package/dist/{handler → src/handler}/LayoutCommandHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/LayoutCommandHandler.js +0 -0
- /package/dist/{handler → src/handler}/ResultEventHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/ResultEventHandler.js +0 -0
- /package/dist/{handler → src/handler}/VisibilityEventHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/VisibilityEventHandler.js +0 -0
- /package/dist/{hooks.d.ts → src/hooks.d.ts} +0 -0
- /package/dist/{hooks.js → src/hooks.js} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{router → src/router}/drawer.d.ts +0 -0
- /package/dist/{router → src/router}/drawer.js +0 -0
- /package/dist/{router → src/router}/index.d.ts +0 -0
- /package/dist/{router → src/router}/index.js +0 -0
- /package/dist/{router → src/router}/screen.d.ts +0 -0
- /package/dist/{router → src/router}/screen.js +0 -0
- /package/dist/{router → src/router}/stack.d.ts +0 -0
- /package/dist/{router → src/router}/stack.js +0 -0
- /package/dist/{router → src/router}/tabs.d.ts +0 -0
- /package/dist/{router → src/router}/tabs.js +0 -0
- /package/dist/{store.d.ts → src/store.d.ts} +0 -0
- /package/dist/{store.js → src/store.js} +0 -0
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
#import "HBDReactBridgeManager.h"
|
|
4
4
|
#import "HBDRootView.h"
|
|
5
|
-
#import "HBDTitleView.h"
|
|
6
5
|
#import "HBDUtils.h"
|
|
7
6
|
#import "HBDNativeEvent.h"
|
|
8
7
|
#import "GlobalStyle.h"
|
|
9
8
|
|
|
10
9
|
#import <React/RCTConvert.h>
|
|
11
|
-
#import <React/RCTSurfaceHostingProxyRootView.h>
|
|
12
10
|
|
|
13
11
|
@interface HBDReactViewController ()
|
|
14
12
|
|
|
@@ -53,9 +51,6 @@
|
|
|
53
51
|
RCTFabricSurface *surface = [rctHost createSurfaceWithModuleName:self.moduleName initialProperties:[self propsWithSceneId]];
|
|
54
52
|
HBDRootView *rootView = [[HBDRootView alloc] initWithSurface:(id)surface];
|
|
55
53
|
self.rootView = rootView;
|
|
56
|
-
|
|
57
|
-
BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
|
|
58
|
-
rootView.passThroughTouches = passThroughTouches;
|
|
59
54
|
rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
60
55
|
self.view = [[UIView alloc] init];
|
|
61
56
|
self.view.backgroundColor = [GlobalStyle globalStyle].screenBackgroundColor;
|
|
@@ -68,106 +63,21 @@
|
|
|
68
63
|
- (void)viewDidLoad {
|
|
69
64
|
[super viewDidLoad];
|
|
70
65
|
[self syncRootViewBackgroundColor];
|
|
71
|
-
[self
|
|
72
|
-
|
|
73
|
-
NSDictionary *titleItem = self.options[@"titleItem"];
|
|
74
|
-
if (titleItem && self.navigationController) {
|
|
75
|
-
if (self.hbd_barHidden) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
NSString *moduleName = titleItem[@"moduleName"];
|
|
79
|
-
if (moduleName) {
|
|
80
|
-
NSString *fitting = titleItem[@"layoutFitting"];
|
|
81
|
-
CGSize size;
|
|
82
|
-
if ([fitting isEqualToString:@"expanded"]) {
|
|
83
|
-
size = UILayoutFittingExpandedSize;
|
|
84
|
-
} else {
|
|
85
|
-
size = UILayoutFittingCompressedSize;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
RCTHost *host = [HBDReactBridgeManager get].rctHost;
|
|
89
|
-
RCTFabricSurface *surface = [host createSurfaceWithModuleName:moduleName initialProperties:[self propsWithSceneId]];
|
|
90
|
-
RCTSurfaceHostingProxyRootView *titleRootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:(id)surface];
|
|
91
|
-
HBDTitleView *titleView = [[HBDTitleView alloc] initWithRootView:titleRootView layoutFittingSize:size navigationBarBounds:self.navigationController.navigationBar.bounds];
|
|
92
|
-
self.navigationItem.titleView = titleView;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
- (void)viewSafeAreaInsetsDidChange {
|
|
98
|
-
[super viewSafeAreaInsetsDidChange];
|
|
99
|
-
if (self.shouldAdjustSafeAreaTopToStatusBar) {
|
|
100
|
-
CGFloat statusBarHeight = [self hbd_statusBarHeight];
|
|
101
|
-
CGFloat currentEffectiveTop = self.view.safeAreaInsets.top;
|
|
102
|
-
if (fabs(currentEffectiveTop - statusBarHeight) > 0.5) {
|
|
103
|
-
CGFloat systemTop = currentEffectiveTop - self.additionalSafeAreaInsets.top;
|
|
104
|
-
UIEdgeInsets o = self.additionalSafeAreaInsets;
|
|
105
|
-
self.additionalSafeAreaInsets = UIEdgeInsetsMake(statusBarHeight - systemTop, o.left, o.bottom, o.right);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
[self updateReactViewConstraints];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
- (CGFloat)hbd_statusBarHeight {
|
|
112
|
-
UIWindow *window = self.view.window ?: self.navigationController.view.window;
|
|
113
|
-
UIWindowScene *scene = window.windowScene;
|
|
114
|
-
if (!scene) {
|
|
115
|
-
NSArray *connectedScenes = [[UIApplication sharedApplication].connectedScenes allObjects];
|
|
116
|
-
for (id connectedScene in connectedScenes) {
|
|
117
|
-
if ([connectedScene isKindOfClass:[UIWindowScene class]]) {
|
|
118
|
-
UIWindowScene *windowScene = (UIWindowScene *)connectedScene;
|
|
119
|
-
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
|
|
120
|
-
scene = windowScene;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return scene ? scene.statusBarManager.statusBarFrame.size.height : 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/// 局部隐藏 topBar 或局部透明 topBar(非全局隐藏)时,需将 SafeArea 顶部修正为状态栏高度
|
|
130
|
-
- (BOOL)shouldAdjustSafeAreaTopToStatusBar {
|
|
131
|
-
if ([GlobalStyle globalStyle].topBarHidden) {
|
|
132
|
-
return NO;
|
|
133
|
-
}
|
|
134
|
-
if (![self.parentViewController isKindOfClass:UINavigationController.class]) {
|
|
135
|
-
return NO;
|
|
136
|
-
}
|
|
137
|
-
return self.hbd_barHidden || self.hbd_barAlpha < 1.0 || colorHasAlphaComponent(self.hbd_barTintColor);
|
|
66
|
+
[self updateReactViewFrame];
|
|
138
67
|
}
|
|
139
68
|
|
|
140
69
|
- (void)viewDidLayoutSubviews {
|
|
141
70
|
[super viewDidLayoutSubviews];
|
|
142
|
-
|
|
71
|
+
[self updateReactViewFrame];
|
|
143
72
|
}
|
|
144
73
|
|
|
145
|
-
- (void)
|
|
74
|
+
- (void)updateReactViewFrame {
|
|
146
75
|
if (self.isViewLoaded && self.rootView) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
topInset,
|
|
152
|
-
self.view.frame.size.width,
|
|
153
|
-
self.view.frame.size.height - topInset - bottomInset
|
|
154
|
-
)];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
- (BOOL)shouldFitWindowInsetsTop {
|
|
159
|
-
if (![self.parentViewController isKindOfClass:UINavigationController.class]) {
|
|
160
|
-
return YES;
|
|
76
|
+
CGRect targetFrame = self.view.bounds;
|
|
77
|
+
if (!CGRectEqualToRect(self.rootView.frame, targetFrame)) {
|
|
78
|
+
[self.rootView setFrame:targetFrame];
|
|
79
|
+
}
|
|
161
80
|
}
|
|
162
|
-
BOOL isTranslucent = self.hbd_barHidden || self.hbd_barAlpha < 1.0 || colorHasAlphaComponent(self.hbd_barTintColor);
|
|
163
|
-
return isTranslucent || self.extendedLayoutIncludesOpaqueBars;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
- (BOOL)shouldFitWindowInsetsBottom {
|
|
167
|
-
if (self.navigationController && self.tabBarController) {
|
|
168
|
-
return self != [self.navigationController.viewControllers firstObject];
|
|
169
|
-
}
|
|
170
|
-
return YES;
|
|
171
81
|
}
|
|
172
82
|
|
|
173
83
|
- (NSDictionary *)propsWithSceneId {
|
|
@@ -190,10 +100,6 @@
|
|
|
190
100
|
|
|
191
101
|
- (void)viewWillAppear:(BOOL)animated {
|
|
192
102
|
[super viewWillAppear:animated];
|
|
193
|
-
#pragma clang diagnostic push
|
|
194
|
-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
195
|
-
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
196
|
-
#pragma clang diagnostic pop
|
|
197
103
|
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
198
104
|
if (coordinator && !coordinator.interactive) {
|
|
199
105
|
if (!self.viewAppeared) {
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
return self.selectedViewController;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
- (UIViewController *)childViewControllerForStatusBarStyle {
|
|
23
|
+
return self.selectedViewController;
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
- (UIViewController *)childViewControllerForHomeIndicatorAutoHidden {
|
|
23
27
|
return self.selectedViewController;
|
|
24
28
|
}
|
|
@@ -46,7 +50,7 @@
|
|
|
46
50
|
} else if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
47
51
|
return (HBDViewController *)vc;
|
|
48
52
|
}
|
|
49
|
-
|
|
53
|
+
|
|
50
54
|
return nil;
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -74,10 +78,10 @@
|
|
|
74
78
|
}
|
|
75
79
|
tabBar.shadowImage = image;
|
|
76
80
|
}
|
|
77
|
-
|
|
81
|
+
|
|
78
82
|
NSString *tabBarItemSelectedColor = options[@"tabBarItemSelectedColor"];
|
|
79
83
|
NSString *tabBarItemNormalColor = options[@"tabBarItemNormalColor"];
|
|
80
|
-
|
|
84
|
+
|
|
81
85
|
if (tabBarItemSelectedColor) {
|
|
82
86
|
if (!tabBarItemNormalColor) {
|
|
83
87
|
tabBarItemNormalColor = @"#666666";
|
|
@@ -96,7 +100,7 @@
|
|
|
96
100
|
[UITabBar appearance].standardAppearance.stackedLayoutAppearance = tabBarItem;
|
|
97
101
|
[UITabBar appearance].scrollEdgeAppearance.stackedLayoutAppearance = tabBarItem;
|
|
98
102
|
}
|
|
99
|
-
|
|
103
|
+
|
|
100
104
|
for (UIViewController *tab in self.childViewControllers) {
|
|
101
105
|
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
102
106
|
[hbdvc updateTabBarItem:hbdvc.options];
|
|
@@ -126,11 +130,11 @@
|
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
|
|
129
|
-
|
|
133
|
+
|
|
130
134
|
if (toVC.viewLoaded) {
|
|
131
135
|
return nil;
|
|
132
136
|
}
|
|
133
|
-
|
|
137
|
+
|
|
134
138
|
return [[HBDFadeAnimation alloc] init];
|
|
135
139
|
}
|
|
136
140
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#import "HBDViewController.h"
|
|
2
2
|
|
|
3
|
-
#import "HBDViewController+Garden.h"
|
|
4
3
|
#import "HBDUtils.h"
|
|
5
4
|
#import "GlobalStyle.h"
|
|
6
|
-
#import "HBDBackBarButtonItem.h"
|
|
7
5
|
#import "UIImage+WithBadge.h"
|
|
8
6
|
|
|
9
7
|
#import <React/RCTLog.h>
|
|
@@ -12,7 +10,6 @@
|
|
|
12
10
|
|
|
13
11
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
14
12
|
@property(nonatomic, copy, readwrite) NSDictionary *options;
|
|
15
|
-
@property(nonatomic, assign) BOOL forceTransparentDialogWindow;
|
|
16
13
|
@property(nonatomic, assign) BOOL forceScreenLandscape;
|
|
17
14
|
@property(nonatomic, assign, readwrite) BOOL animatedTransition;
|
|
18
15
|
|
|
@@ -21,7 +18,7 @@
|
|
|
21
18
|
@implementation HBDViewController
|
|
22
19
|
|
|
23
20
|
- (void)dealloc {
|
|
24
|
-
//
|
|
21
|
+
//
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
@@ -38,20 +35,15 @@
|
|
|
38
35
|
_options = options;
|
|
39
36
|
_props = props;
|
|
40
37
|
_animatedTransition = YES;
|
|
41
|
-
|
|
38
|
+
|
|
42
39
|
if (options[@"animatedTransition"]) {
|
|
43
40
|
_animatedTransition = [options[@"animatedTransition"] boolValue];
|
|
44
41
|
}
|
|
45
|
-
|
|
42
|
+
|
|
46
43
|
if (options[@"forceScreenLandscape"]) {
|
|
47
44
|
_forceScreenLandscape = [options[@"forceScreenLandscape"] boolValue];
|
|
48
45
|
}
|
|
49
|
-
|
|
50
|
-
self.forceTransparentDialogWindow = [options[@"forceTransparentDialogWindow"] boolValue];
|
|
51
|
-
if (self.forceTransparentDialogWindow) {
|
|
52
|
-
_animatedTransition = NO;
|
|
53
|
-
}
|
|
54
|
-
|
|
46
|
+
|
|
55
47
|
[self applyNavigationBarOptions:options];
|
|
56
48
|
[self applyTabBarOptions:options];
|
|
57
49
|
}
|
|
@@ -91,37 +83,55 @@
|
|
|
91
83
|
|
|
92
84
|
- (void)adjustScreenOrientation {
|
|
93
85
|
UIWindowScene *windowScene = [self getWindowScene];
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
[self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
|
|
86
|
+
if (windowScene == nil) {
|
|
87
|
+
return;
|
|
97
88
|
}
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
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
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
- (void)setScreenOrientation:(UIInterfaceOrientation) orientation usingMask:(UIInterfaceOrientationMask) mask {
|
|
105
|
+
UIWindowScene *windowScene = [self getWindowScene];
|
|
106
|
+
[self.view endEditing:YES];
|
|
107
|
+
[self.navigationController.view endEditing:YES];
|
|
108
|
+
for (UIWindow *window in windowScene.windows) {
|
|
109
|
+
[window endEditing:YES];
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
[GlobalStyle globalStyle].interfaceOrientation = mask;
|
|
106
113
|
if (@available(iOS 16.0, *)) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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];
|
|
120
131
|
[currentDevice setValue:@(UIInterfaceOrientationUnknown) forKey:@"orientation"];
|
|
121
132
|
[currentDevice setValue:@(orientation) forKey:@"orientation"];
|
|
133
|
+
[UIViewController attemptRotationToDeviceOrientation];
|
|
122
134
|
}
|
|
123
|
-
|
|
124
|
-
[UIViewController attemptRotationToDeviceOrientation];
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
- (UIWindowScene *)getWindowScene {
|
|
@@ -152,7 +162,7 @@
|
|
|
152
162
|
[self setModalBackgroundColor];
|
|
153
163
|
return;
|
|
154
164
|
}
|
|
155
|
-
|
|
165
|
+
|
|
156
166
|
NSString *screenColor = self.options[@"screenBackgroundColor"];
|
|
157
167
|
if (screenColor) {
|
|
158
168
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
@@ -162,15 +172,10 @@
|
|
|
162
172
|
}
|
|
163
173
|
|
|
164
174
|
- (void)setModalBackgroundColor {
|
|
165
|
-
if (self.forceTransparentDialogWindow) {
|
|
166
|
-
self.view.backgroundColor = UIColor.clearColor;
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
175
|
self.view.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.5];
|
|
171
|
-
|
|
176
|
+
|
|
172
177
|
NSString *screenColor = self.options[@"screenBackgroundColor"];
|
|
173
|
-
|
|
178
|
+
|
|
174
179
|
if (!screenColor) {
|
|
175
180
|
return;
|
|
176
181
|
}
|
|
@@ -184,7 +189,7 @@
|
|
|
184
189
|
- (void)applyTabBarOptions:(NSDictionary *)options {
|
|
185
190
|
NSDictionary *tabItem = options[@"tabItem"];
|
|
186
191
|
if (tabItem) {
|
|
187
|
-
UITabBarItem *tabBarItem = self.
|
|
192
|
+
UITabBarItem *tabBarItem = self.tabBarItem;
|
|
188
193
|
// title
|
|
189
194
|
tabBarItem.title = tabItem[@"title"];
|
|
190
195
|
|
|
@@ -192,12 +197,12 @@
|
|
|
192
197
|
NSDictionary *badge = tabItem[@"badge"];
|
|
193
198
|
tabBarItem.badgeValue = [self badgeText:badge];
|
|
194
199
|
tabBarItem.badgeColor = [UITabBarItem appearance].badgeColor;
|
|
195
|
-
|
|
200
|
+
|
|
196
201
|
NSDictionary *unselectedIcon = tabItem[@"unselectedIcon"];
|
|
197
202
|
NSDictionary *icon = tabItem[@"icon"];
|
|
198
203
|
UITabBar *appearance = self.tabBarController.tabBar ?: [UITabBar appearance];
|
|
199
204
|
BOOL dot = [self showDotBadge:badge];
|
|
200
|
-
|
|
205
|
+
|
|
201
206
|
UITabBarItemAppearance *itemAppearance = appearance.standardAppearance.stackedLayoutAppearance;
|
|
202
207
|
if (unselectedIcon) {
|
|
203
208
|
tabBarItem.image = [[HBDUtils UIImage:unselectedIcon] withIconColor:itemAppearance.normal.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
@@ -206,9 +211,7 @@
|
|
|
206
211
|
tabBarItem.image = [[HBDUtils UIImage:icon] withIconColor:itemAppearance.normal.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
207
212
|
tabBarItem.selectedImage = [[HBDUtils UIImage:icon] withIconColor:itemAppearance.selected.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
|
|
208
213
|
}
|
|
209
|
-
|
|
210
|
-
self.tabBarItem = tabBarItem;
|
|
211
|
-
}
|
|
214
|
+
self.tabBarItem = tabBarItem;
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
217
|
|
|
@@ -224,14 +227,14 @@
|
|
|
224
227
|
if (badge != nil) {
|
|
225
228
|
self.options[@"tabItem"][@"badge"] = badge;
|
|
226
229
|
}
|
|
227
|
-
|
|
230
|
+
|
|
228
231
|
// icon
|
|
229
232
|
NSDictionary *icon = option[@"icon"];
|
|
230
233
|
if (icon != nil) {
|
|
231
234
|
self.options[@"tabItem"][@"icon"] = icon[@"selected"];
|
|
232
235
|
self.options[@"tabItem"][@"unselectedIcon"] = icon[@"unselected"];
|
|
233
236
|
}
|
|
234
|
-
|
|
237
|
+
|
|
235
238
|
[self applyTabBarOptions:self.options];
|
|
236
239
|
}
|
|
237
240
|
|
|
@@ -252,78 +255,23 @@
|
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
- (void)applyNavigationBarOptions:(NSDictionary *)options {
|
|
255
|
-
NSString *
|
|
256
|
-
if (
|
|
257
|
-
if ([
|
|
258
|
+
NSString *statusBarStyle = options[@"statusBarStyle"];
|
|
259
|
+
if (statusBarStyle) {
|
|
260
|
+
if ([statusBarStyle isEqualToString:@"dark-content"]) {
|
|
258
261
|
self.hbd_barStyle = UIBarStyleDefault;
|
|
259
262
|
} else {
|
|
260
263
|
self.hbd_barStyle = UIBarStyleBlack;
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
266
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
self.hbd_tintColor = [HBDUtils colorWithHexString:topBarTintColor];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
NSMutableDictionary *titleAttributes = [@{} mutableCopy];
|
|
270
|
-
NSString *titleTextColor = options[@"titleTextColor"];
|
|
271
|
-
NSNumber *titleTextSize = options[@"titleTextSize"];
|
|
272
|
-
if (titleTextColor) {
|
|
273
|
-
titleAttributes[NSForegroundColorAttributeName] = [HBDUtils colorWithHexString:titleTextColor];
|
|
274
|
-
}
|
|
275
|
-
if (titleTextSize) {
|
|
276
|
-
titleAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:[titleTextSize floatValue]];
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (titleAttributes.count > 0) {
|
|
280
|
-
if (self.hbd_titleTextAttributes) {
|
|
281
|
-
NSMutableDictionary *attributes = [self.hbd_titleTextAttributes mutableCopy];
|
|
282
|
-
[attributes addEntriesFromDictionary:titleAttributes];
|
|
283
|
-
self.hbd_titleTextAttributes = attributes;
|
|
284
|
-
} else {
|
|
285
|
-
self.hbd_titleTextAttributes = titleAttributes;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
NSString *topBarColor = options[@"topBarColor"];
|
|
290
|
-
if (topBarColor) {
|
|
291
|
-
self.hbd_barTintColor = [HBDUtils colorWithHexString:topBarColor];
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
NSNumber *topBarAlpha = options[@"topBarAlpha"];
|
|
295
|
-
if (topBarAlpha) {
|
|
296
|
-
self.hbd_barAlpha = [topBarAlpha floatValue];
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// 全局 topBarHidden 优先,一旦设置则局部开启无效
|
|
300
|
-
if ([GlobalStyle globalStyle].topBarHidden) {
|
|
301
|
-
self.hbd_barHidden = YES;
|
|
302
|
-
} else if (options[@"topBarHidden"] != nil) {
|
|
303
|
-
self.hbd_barHidden = [options[@"topBarHidden"] boolValue];
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if ([GlobalStyle globalStyle].isBackTitleHidden) {
|
|
307
|
-
UIBarButtonItem *buttonItem = [[HBDBackBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:NULL];
|
|
308
|
-
self.navigationItem.backBarButtonItem = buttonItem;
|
|
309
|
-
self.navigationItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
|
|
310
|
-
}
|
|
267
|
+
// Native TopBar has been removed and UINavigationBar stays hidden.
|
|
268
|
+
self.extendedLayoutIncludesOpaqueBars = YES;
|
|
311
269
|
|
|
312
270
|
NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
|
|
313
271
|
if (swipeBackEnabled) {
|
|
314
272
|
self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
|
|
315
273
|
}
|
|
316
274
|
|
|
317
|
-
NSNumber *extendedLayoutIncludesTopBar = options[@"extendedLayoutIncludesTopBar"];
|
|
318
|
-
if (extendedLayoutIncludesTopBar) {
|
|
319
|
-
self.extendedLayoutIncludesOpaqueBars = [extendedLayoutIncludesTopBar boolValue];
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
NSNumber *hideShadow = options[@"topBarShadowHidden"];
|
|
323
|
-
if (hideShadow) {
|
|
324
|
-
self.hbd_barShadowHidden = [hideShadow boolValue];
|
|
325
|
-
}
|
|
326
|
-
|
|
327
275
|
NSNumber *statusBarHidden = options[@"statusBarHidden"];
|
|
328
276
|
if (statusBarHidden) {
|
|
329
277
|
self.hbd_statusBarHidden = [statusBarHidden boolValue];
|
|
@@ -333,71 +281,13 @@
|
|
|
333
281
|
if (backInteractive) {
|
|
334
282
|
self.hbd_backInteractive = [backInteractive boolValue];
|
|
335
283
|
}
|
|
336
|
-
|
|
337
|
-
NSNumber *backButtonHidden = options[@"backButtonHidden"];
|
|
338
|
-
if (backButtonHidden) {
|
|
339
|
-
if ([backButtonHidden boolValue]) {
|
|
340
|
-
[self.navigationItem setHidesBackButton:YES];
|
|
341
|
-
} else {
|
|
342
|
-
[self.navigationItem setHidesBackButton:NO];
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
NSDictionary *titleItem = options[@"titleItem"];
|
|
347
|
-
if (titleItem) {
|
|
348
|
-
NSString *moduleName = titleItem[@"moduleName"];
|
|
349
|
-
if (!moduleName) {
|
|
350
|
-
self.navigationItem.title = titleItem[@"title"];
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
id rightBarButtonItem = options[@"rightBarButtonItem"];
|
|
355
|
-
if (rightBarButtonItem) {
|
|
356
|
-
[self setRightBarButtonItem:RCTNilIfNull(rightBarButtonItem)];
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
id leftBarButtonItem = options[@"leftBarButtonItem"];
|
|
360
|
-
if (leftBarButtonItem) {
|
|
361
|
-
[self setLeftBarButtonItem:RCTNilIfNull(leftBarButtonItem)];
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
NSArray *rightBarButtonItems = options[@"rightBarButtonItems"];
|
|
365
|
-
if (rightBarButtonItems) {
|
|
366
|
-
[self setRightBarButtonItems:rightBarButtonItems];
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
NSArray *leftBarButtonItems = options[@"leftBarButtonItems"];
|
|
370
|
-
if (leftBarButtonItems) {
|
|
371
|
-
[self setLeftBarButtonItems:leftBarButtonItems];
|
|
372
|
-
}
|
|
373
284
|
}
|
|
374
285
|
|
|
375
286
|
- (void)updateNavigationBarOptions:(NSDictionary *)options {
|
|
376
|
-
|
|
377
|
-
self.options = [HBDUtils mergeItem:options withTarget:previous];
|
|
287
|
+
self.options = [HBDUtils mergeItem:options withTarget:self.options];
|
|
378
288
|
|
|
379
289
|
NSMutableDictionary *target = [options mutableCopy];
|
|
380
290
|
|
|
381
|
-
if (options[@"titleItem"]) {
|
|
382
|
-
target[@"titleItem"] = self.options[@"titleItem"];
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (options[@"leftBarButtonItem"]) {
|
|
386
|
-
target[@"leftBarButtonItem"] = self.options[@"leftBarButtonItem"];
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if (options[@"rightBarButtonItem"]) {
|
|
390
|
-
target[@"rightBarButtonItem"] = self.options[@"rightBarButtonItem"];
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (options[@"leftBarButtonItems"]) {
|
|
394
|
-
target[@"leftBarButtonItems"] = self.options[@"leftBarButtonItems"];
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (options[@"rightBarButtonItems"]) {
|
|
398
|
-
target[@"rightBarButtonItems"] = self.options[@"rightBarButtonItems"];
|
|
399
|
-
}
|
|
400
|
-
|
|
401
291
|
[self applyNavigationBarOptions:target];
|
|
402
292
|
|
|
403
293
|
NSString *screenColor = options[@"screenBackgroundColor"];
|
|
@@ -405,8 +295,7 @@
|
|
|
405
295
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
406
296
|
}
|
|
407
297
|
|
|
408
|
-
|
|
409
|
-
if (statusBarHidden) {
|
|
298
|
+
if (options[@"statusBarHidden"] || options[@"statusBarStyle"]) {
|
|
410
299
|
[self setNeedsStatusBarAppearanceUpdate];
|
|
411
300
|
}
|
|
412
301
|
|
|
@@ -414,19 +303,6 @@
|
|
|
414
303
|
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
415
304
|
}
|
|
416
305
|
|
|
417
|
-
if ([self shouldUpdateNavigationBar:options compareTo:previous]) {
|
|
418
|
-
[self hbd_setNeedsUpdateNavigationBar];
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
- (BOOL)shouldUpdateNavigationBar:(NSDictionary *)options compareTo:(NSDictionary *)previous {
|
|
423
|
-
NSArray *keys = @[@"topBarStyle", @"topBarColor", @"topBarAlpha", @"tintColor", @"topBarShadowHidden"];
|
|
424
|
-
for (NSString *opt in options.allKeys) {
|
|
425
|
-
if ([keys containsObject:opt] && [NSString stringWithFormat:@"%@", previous[opt]] != [NSString stringWithFormat:@"%@", options[opt]]) {
|
|
426
|
-
return YES;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return NO;
|
|
430
306
|
}
|
|
431
307
|
|
|
432
308
|
@end
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
NSUInteger count = self.childViewControllers.count;
|
|
25
25
|
[children removeObjectsInRange:NSMakeRange(index, count - index)];
|
|
26
26
|
[children addObject:controller];
|
|
27
|
-
if (children.count > 1) {
|
|
28
|
-
controller.hidesBottomBarWhenPushed = self.hidesBottomBarWhenPushed;
|
|
29
|
-
}
|
|
30
27
|
[self setViewControllers:children animated:animated];
|
|
31
28
|
}
|
|
32
29
|
|
|
@@ -5,19 +5,10 @@
|
|
|
5
5
|
@interface UIViewController (HBD)
|
|
6
6
|
|
|
7
7
|
@property(nonatomic, assign) UIBarStyle hbd_barStyle;
|
|
8
|
-
@property(nonatomic, strong) UIColor *hbd_barTintColor;
|
|
9
|
-
@property(nonatomic, strong) UIColor *hbd_tintColor;
|
|
10
|
-
@property(nonatomic, strong) NSDictionary *hbd_titleTextAttributes;
|
|
11
|
-
@property(nonatomic, assign) float hbd_barAlpha;
|
|
12
|
-
@property(nonatomic, assign) BOOL hbd_barHidden;
|
|
13
|
-
@property(nonatomic, assign) BOOL hbd_barShadowHidden;
|
|
14
8
|
@property(nonatomic, assign) BOOL hbd_backInteractive;
|
|
15
9
|
@property(nonatomic, assign) BOOL hbd_swipeBackEnabled;
|
|
16
|
-
@property(nonatomic, assign, readonly) float hbd_barShadowAlpha;
|
|
17
10
|
@property(nonatomic, assign) BOOL hbd_statusBarHidden;
|
|
18
11
|
|
|
19
|
-
- (void)hbd_setNeedsUpdateNavigationBar;
|
|
20
|
-
|
|
21
12
|
@property(nonatomic, copy, readonly) NSString *sceneId;
|
|
22
13
|
@property(nonatomic, copy) NSString *presentingSceneId;
|
|
23
14
|
@property(nonatomic, assign) NSInteger resultCode;
|