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
|
@@ -1,64 +1,17 @@
|
|
|
1
1
|
#import "HBDNavigationController.h"
|
|
2
2
|
|
|
3
3
|
#import "HBDViewController.h"
|
|
4
|
-
#import "HBDNavigationBar.h"
|
|
5
|
-
#import "HBDUtils.h"
|
|
6
|
-
#import "HBDPushAnimation.h"
|
|
7
|
-
#import "HBDPopAnimation.h"
|
|
8
|
-
#import "HBDFadeAnimation.h"
|
|
9
|
-
#import "GlobalStyle.h"
|
|
10
4
|
|
|
11
5
|
#import <React/RCTLog.h>
|
|
6
|
+
#import <React/RCTUtils.h>
|
|
12
7
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@interface HBDNavigationControllerDelegate : UIScreenEdgePanGestureRecognizer <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
16
|
-
|
|
17
|
-
@property(nonatomic, weak) id <UINavigationControllerDelegate> proxyDelegate;
|
|
18
|
-
@property(nonatomic, weak, readonly) HBDNavigationController *nav;
|
|
19
|
-
@property(nonatomic, strong) UIPercentDrivenInteractiveTransition *interactiveTransition;
|
|
20
|
-
@property(nonatomic, assign) UIEdgeInsets hbd_savedAdditionalSafeAreaInsetsForTo;
|
|
21
|
-
@property(nonatomic, assign) BOOL hbd_didCompensateSafeAreaForTo;
|
|
22
|
-
@property(nonatomic, assign) UIEdgeInsets hbd_savedAdditionalSafeAreaInsetsForFrom;
|
|
23
|
-
@property(nonatomic, assign) BOOL hbd_didCompensateSafeAreaForFrom;
|
|
24
|
-
|
|
25
|
-
- (instancetype)initWithNavigationController:(HBDNavigationController *)navigationController;
|
|
26
|
-
- (void)hbd_compensateSafeAreaForViewController:(UIViewController *)vc expectedTopInset:(CGFloat)expectedTopInset isToVC:(BOOL)isToVC;
|
|
27
|
-
- (void)hbd_restoreCompensatedSafeAreaForFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *)viewController;
|
|
28
|
-
- (BOOL)shouldAnimateTabBarFrom:(UIViewController *)from to:(UIViewController *)to;
|
|
29
|
-
- (void)prepareTabBarForTransitionFrom:(UIViewController *)from to:(UIViewController *)to;
|
|
30
|
-
- (void)animateTabBarForTransitionFrom:(UIViewController *)from to:(UIViewController *)to;
|
|
31
|
-
- (void)completeTabBarTransitionFrom:(UIViewController *)from
|
|
32
|
-
to:(UIViewController *)to
|
|
33
|
-
cancelled:(BOOL)cancelled;
|
|
34
|
-
- (BOOL)shouldUseFadeAnimationFrom:(UIViewController *)from to:(UIViewController *)to;
|
|
35
|
-
- (BOOL)shouldHandleInteractiveTransitionWithNavigationController:(HBDNavigationController *)nav;
|
|
8
|
+
@interface HBDNavigationController () <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
36
9
|
|
|
37
|
-
@end
|
|
38
|
-
|
|
39
|
-
@interface HBDNavigationController ()
|
|
40
|
-
|
|
41
|
-
@property(nonatomic, readonly) HBDNavigationBar *navigationBar;
|
|
42
|
-
@property(nonatomic, strong) UIView *fromFakeBar;
|
|
43
|
-
@property(nonatomic, strong) UIView *toFakeBar;
|
|
44
|
-
@property(nonatomic, strong) UIImageView *fromFakeShadow;
|
|
45
|
-
@property(nonatomic, strong) UIImageView *toFakeShadow;
|
|
46
10
|
@property(nonatomic, weak) UIViewController *poppingViewController;
|
|
47
|
-
@property(nonatomic, strong)
|
|
48
|
-
|
|
49
|
-
- (void)updateNavigationBarStyleForViewController:(UIViewController *)vc;
|
|
50
|
-
|
|
51
|
-
- (void)updateNavigationBarTintColorForViewController:(UIViewController *)vc;
|
|
52
|
-
|
|
53
|
-
- (void)updateNavigationBarAlphaForViewController:(UIViewController *)vc;
|
|
54
|
-
|
|
55
|
-
- (void)updateNavigationBarBackgroundForViewController:(UIViewController *)vc;
|
|
56
|
-
|
|
57
|
-
- (void)showFakeBarFrom:(UIViewController *)from to:(UIViewController *)to;
|
|
58
|
-
|
|
59
|
-
- (void)clearFake;
|
|
11
|
+
@property(nonatomic, strong) UIScreenEdgePanGestureRecognizer *navigationPopGestureRecognizer;
|
|
60
12
|
|
|
61
13
|
- (UIGestureRecognizer *)superInteractivePopGestureRecognizer;
|
|
14
|
+
- (void)handleNavigationTransition:(UIScreenEdgePanGestureRecognizer *)pan;
|
|
62
15
|
|
|
63
16
|
@end
|
|
64
17
|
|
|
@@ -68,468 +21,21 @@
|
|
|
68
21
|
|
|
69
22
|
@end
|
|
70
23
|
|
|
71
|
-
@implementation HBDNavigationControllerDelegate
|
|
72
|
-
|
|
73
|
-
- (instancetype)initWithNavigationController:(HBDNavigationController *)nav {
|
|
74
|
-
if (self = [super init]) {
|
|
75
|
-
_nav = nav;
|
|
76
|
-
self.edges = UIRectEdgeLeft;
|
|
77
|
-
self.delegate = self;
|
|
78
|
-
[self addTarget:self action:@selector(handleNavigationTransition:)];
|
|
79
|
-
[nav.view addGestureRecognizer:self];
|
|
80
|
-
[nav superInteractivePopGestureRecognizer].enabled = NO;
|
|
81
|
-
}
|
|
82
|
-
return self;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
|
86
|
-
HBDNavigationController *nav = self.nav;
|
|
87
|
-
|
|
88
|
-
if (nav.transitionCoordinator) {
|
|
89
|
-
return NO;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (nav.viewControllers.count > 1) {
|
|
93
|
-
UIViewController *topVC = nav.topViewController;
|
|
94
|
-
return topVC.hbd_swipeBackEnabled && topVC.hbd_backInteractive;
|
|
95
|
-
}
|
|
96
|
-
return NO;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
100
|
-
if (gestureRecognizer == self.nav.interactivePopGestureRecognizer) {
|
|
101
|
-
return YES;
|
|
102
|
-
}
|
|
103
|
-
return NO;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
- (void)handleNavigationTransition:(UIScreenEdgePanGestureRecognizer *)pan {
|
|
107
|
-
HBDNavigationController *nav = self.nav;
|
|
108
|
-
|
|
109
|
-
id <UIViewControllerTransitionCoordinator> coordinator = nav.transitionCoordinator;
|
|
110
|
-
BOOL shouldHandleInteractiveTransition =
|
|
111
|
-
[self shouldBetterTransitionWithViewController:nav.topViewController] ||
|
|
112
|
-
[self shouldHandleInteractiveTransitionWithNavigationController:nav];
|
|
113
|
-
|
|
114
|
-
if (![self.proxyDelegate respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)]) {
|
|
115
|
-
if (self.interactiveTransition || (!coordinator && shouldHandleInteractiveTransition)) {
|
|
116
|
-
CGFloat process = [pan translationInView:nav.view].x / nav.view.bounds.size.width;
|
|
117
|
-
process = MIN(1.0, (MAX(0.0, process)));
|
|
118
|
-
if (pan.state == UIGestureRecognizerStateBegan) {
|
|
119
|
-
self.interactiveTransition = [UIPercentDrivenInteractiveTransition new];
|
|
120
|
-
//触发pop转场动画
|
|
121
|
-
[nav popViewControllerAnimated:YES];
|
|
122
|
-
} else if (pan.state == UIGestureRecognizerStateChanged) {
|
|
123
|
-
UIPercentDrivenInteractiveTransition *transition = self.interactiveTransition;
|
|
124
|
-
[transition updateInteractiveTransition:process];
|
|
125
|
-
} else if (pan.state == UIGestureRecognizerStateEnded
|
|
126
|
-
|| pan.state == UIGestureRecognizerStateCancelled) {
|
|
127
|
-
if (process > 0.33) {
|
|
128
|
-
[self.interactiveTransition finishInteractiveTransition];
|
|
129
|
-
} else {
|
|
130
|
-
[self.interactiveTransition cancelInteractiveTransition];
|
|
131
|
-
}
|
|
132
|
-
self.interactiveTransition = nil;
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
id <HBDNavigationTransitionProtocol> target = (id <HBDNavigationTransitionProtocol>) [nav superInteractivePopGestureRecognizer].delegate;
|
|
136
|
-
if ([target respondsToSelector:@selector(handleNavigationTransition:)]) {
|
|
137
|
-
[target handleNavigationTransition:pan];
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
144
|
-
|
|
145
|
-
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:willShowViewController:animated:)]) {
|
|
146
|
-
[self.proxyDelegate navigationController:navigationController willShowViewController:viewController animated:animated];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
HBDNavigationController *nav = self.nav;
|
|
150
|
-
id <UIViewControllerTransitionCoordinator> coordinator = nav.transitionCoordinator;
|
|
151
|
-
if (coordinator) {
|
|
152
|
-
[self showViewController:viewController withCoordinator:coordinator];
|
|
153
|
-
} else {
|
|
154
|
-
if (!animated && nav.childViewControllers.count > 1) {
|
|
155
|
-
UIViewController *lastButOne = nav.childViewControllers[nav.childViewControllers.count - 2];
|
|
156
|
-
if ([self shouldShowFakeBarFrom:lastButOne to:viewController viewController:viewController]) {
|
|
157
|
-
[nav showFakeBarFrom:lastButOne to:viewController];
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
[nav updateNavigationBarForViewController:viewController];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
166
|
-
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:didShowViewController:animated:)]) {
|
|
167
|
-
[self.proxyDelegate navigationController:navigationController didShowViewController:viewController animated:animated];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
UIViewController *poppingVC = self.nav.poppingViewController;
|
|
171
|
-
if (poppingVC && [poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
172
|
-
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
self.nav.poppingViewController = nil;
|
|
176
|
-
|
|
177
|
-
if (!animated) {
|
|
178
|
-
[self.nav updateNavigationBarForViewController:viewController];
|
|
179
|
-
[self.nav clearFake];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
|
|
184
|
-
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationControllerSupportedInterfaceOrientations:)]) {
|
|
185
|
-
return [self.proxyDelegate navigationControllerSupportedInterfaceOrientations:navigationController];
|
|
186
|
-
}
|
|
187
|
-
return [GlobalStyle globalStyle].interfaceOrientation;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController {
|
|
191
|
-
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationControllerPreferredInterfaceOrientationForPresentation:)]) {
|
|
192
|
-
return [self.proxyDelegate navigationControllerPreferredInterfaceOrientationForPresentation:navigationController];
|
|
193
|
-
}
|
|
194
|
-
UIInterfaceOrientationMask mask = [GlobalStyle globalStyle].interfaceOrientation;
|
|
195
|
-
if (mask & UIInterfaceOrientationMaskLandscapeRight) {
|
|
196
|
-
return UIInterfaceOrientationLandscapeRight;
|
|
197
|
-
}
|
|
198
|
-
if (mask & UIInterfaceOrientationMaskLandscapeLeft) {
|
|
199
|
-
return UIInterfaceOrientationLandscapeLeft;
|
|
200
|
-
}
|
|
201
|
-
return UIInterfaceOrientationPortrait;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
|
|
205
|
-
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>)animationController {
|
|
206
|
-
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)]) {
|
|
207
|
-
return [self.proxyDelegate navigationController:navigationController interactionControllerForAnimationController:animationController];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if ([animationController isKindOfClass:[HBDPopAnimation class]] ||
|
|
211
|
-
[animationController isKindOfClass:[HBDFadeAnimation class]]) {
|
|
212
|
-
return self.interactiveTransition;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return nil;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
|
|
219
|
-
animationControllerForOperation:(UINavigationControllerOperation)operation
|
|
220
|
-
fromViewController:(UIViewController *)fromVC
|
|
221
|
-
toViewController:(UIViewController *)toVC {
|
|
222
|
-
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:animationControllerForOperation:fromViewController:toViewController:)]) {
|
|
223
|
-
return [self.proxyDelegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC];
|
|
224
|
-
} else {
|
|
225
|
-
// 检查是否需要使用淡入淡出动画(横屏页面)
|
|
226
|
-
// 只要 from 或 to 页面有一个是横屏,就采用 fade 动画
|
|
227
|
-
BOOL shouldUseFadeAnimation = NO;
|
|
228
|
-
|
|
229
|
-
// 检查 fromVC 是否是横屏
|
|
230
|
-
if ([fromVC isKindOfClass:[HBDViewController class]]) {
|
|
231
|
-
HBDViewController *hbdFromVC = (HBDViewController *)fromVC;
|
|
232
|
-
if (hbdFromVC.forceScreenLandscape) {
|
|
233
|
-
shouldUseFadeAnimation = YES;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// 检查 toVC 是否是横屏
|
|
238
|
-
if (!shouldUseFadeAnimation && [toVC isKindOfClass:[HBDViewController class]]) {
|
|
239
|
-
HBDViewController *hbdToVC = (HBDViewController *)toVC;
|
|
240
|
-
if (hbdToVC.forceScreenLandscape) {
|
|
241
|
-
shouldUseFadeAnimation = YES;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (shouldUseFadeAnimation) {
|
|
246
|
-
return [HBDFadeAnimation new];
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (operation == UINavigationControllerOperationPush) {
|
|
250
|
-
if ([self shouldBetterTransitionWithViewController:toVC]) {
|
|
251
|
-
return [HBDPushAnimation new];
|
|
252
|
-
}
|
|
253
|
-
} else if (operation == UINavigationControllerOperationPop) {
|
|
254
|
-
if ([self shouldBetterTransitionWithViewController:fromVC]) {
|
|
255
|
-
return [HBDPopAnimation new];
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return nil;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
- (BOOL)shouldBetterTransitionWithViewController:(UIViewController *)vc {
|
|
264
|
-
BOOL shouldBetter = NO;
|
|
265
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
266
|
-
HBDViewController *hbd = (HBDViewController *) vc;
|
|
267
|
-
shouldBetter = [hbd.options[@"passThroughTouches"] boolValue];
|
|
268
|
-
}
|
|
269
|
-
return shouldBetter;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
- (BOOL)shouldUseFadeAnimationFrom:(UIViewController *)from to:(UIViewController *)to {
|
|
273
|
-
if ([from isKindOfClass:[HBDViewController class]]) {
|
|
274
|
-
HBDViewController *hbdFromVC = (HBDViewController *)from;
|
|
275
|
-
if (hbdFromVC.forceScreenLandscape) {
|
|
276
|
-
return YES;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if ([to isKindOfClass:[HBDViewController class]]) {
|
|
281
|
-
HBDViewController *hbdToVC = (HBDViewController *)to;
|
|
282
|
-
if (hbdToVC.forceScreenLandscape) {
|
|
283
|
-
return YES;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return NO;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
- (BOOL)shouldHandleInteractiveTransitionWithNavigationController:(HBDNavigationController *)nav {
|
|
291
|
-
if (nav.viewControllers.count < 2) {
|
|
292
|
-
return NO;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
UIViewController *from = nav.topViewController;
|
|
296
|
-
UIViewController *to = nav.viewControllers[nav.viewControllers.count - 2];
|
|
297
|
-
return [self shouldUseFadeAnimationFrom:from to:to];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
- (void)hbd_compensateSafeAreaForViewController:(UIViewController *)vc expectedTopInset:(CGFloat)expectedTopInset isToVC:(BOOL)isToVC {
|
|
301
|
-
if (vc.isViewLoaded) {
|
|
302
|
-
[vc.view layoutIfNeeded];
|
|
303
|
-
}
|
|
304
|
-
CGFloat systemTop = vc.isViewLoaded ? vc.view.safeAreaInsets.top : 0;
|
|
305
|
-
CGFloat compensate = expectedTopInset > systemTop ? (expectedTopInset - systemTop) : 0;
|
|
306
|
-
if (isToVC) {
|
|
307
|
-
self.hbd_savedAdditionalSafeAreaInsetsForTo = vc.additionalSafeAreaInsets;
|
|
308
|
-
self.hbd_didCompensateSafeAreaForTo = (compensate > 0);
|
|
309
|
-
} else {
|
|
310
|
-
self.hbd_savedAdditionalSafeAreaInsetsForFrom = vc.additionalSafeAreaInsets;
|
|
311
|
-
self.hbd_didCompensateSafeAreaForFrom = (compensate > 0);
|
|
312
|
-
}
|
|
313
|
-
if (compensate > 0) {
|
|
314
|
-
UIEdgeInsets o = vc.additionalSafeAreaInsets;
|
|
315
|
-
vc.additionalSafeAreaInsets = UIEdgeInsetsMake(o.top + compensate, o.left, o.bottom, o.right);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
- (void)hbd_restoreCompensatedSafeAreaForFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *)viewController {
|
|
320
|
-
if (self.hbd_didCompensateSafeAreaForTo && to == viewController) {
|
|
321
|
-
viewController.additionalSafeAreaInsets = self.hbd_savedAdditionalSafeAreaInsetsForTo;
|
|
322
|
-
self.hbd_didCompensateSafeAreaForTo = NO;
|
|
323
|
-
}
|
|
324
|
-
if (self.hbd_didCompensateSafeAreaForFrom) {
|
|
325
|
-
from.additionalSafeAreaInsets = self.hbd_savedAdditionalSafeAreaInsetsForFrom;
|
|
326
|
-
self.hbd_didCompensateSafeAreaForFrom = NO;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
- (void)showViewController:(UIViewController *_Nonnull)viewController withCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
|
|
331
|
-
UIViewController *from = [coordinator viewControllerForKey:UITransitionContextFromViewControllerKey];
|
|
332
|
-
UIViewController *to = [coordinator viewControllerForKey:UITransitionContextToViewControllerKey];
|
|
333
|
-
|
|
334
|
-
// Fix a system bug https://github.com/listenzz/HBDNavigationBar/issues/35
|
|
335
|
-
[self resetButtonLabelInNavBar:self.nav.navigationBar];
|
|
336
|
-
|
|
337
|
-
if (self.nav.poppingViewController) {
|
|
338
|
-
// Inspired by QMUI
|
|
339
|
-
UILabel *backButtonLabel = self.nav.navigationBar.backButtonLabel;
|
|
340
|
-
if (backButtonLabel) {
|
|
341
|
-
backButtonLabel.hbd_specifiedTextColor = backButtonLabel.textColor;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
345
|
-
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
346
|
-
backButtonLabel.hbd_specifiedTextColor = nil;
|
|
347
|
-
}];
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
[self.nav updateNavigationBarStyleForViewController:viewController];
|
|
351
|
-
|
|
352
|
-
BOOL shouldAnimateTabBar = [self shouldAnimateTabBarFrom:from to:to];
|
|
353
|
-
if (shouldAnimateTabBar) {
|
|
354
|
-
[self prepareTabBarForTransitionFrom:from to:to];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
358
|
-
BOOL shouldFake = [self shouldShowFakeBarFrom:from to:to viewController:viewController];
|
|
359
|
-
if (shouldFake) {
|
|
360
|
-
[self.nav updateNavigationBarTintColorForViewController:viewController];
|
|
361
|
-
[self.nav showFakeBarFrom:from to:to];
|
|
362
|
-
|
|
363
|
-
// 转场涉及旋转时不应用 safe area 补偿,避免布局错乱
|
|
364
|
-
BOOL noRotation = CGAffineTransformIsIdentity(context.targetTransform);
|
|
365
|
-
if (noRotation) {
|
|
366
|
-
CGFloat expectedTopInset = CGRectGetMaxY(self.nav.navigationBar.frame);
|
|
367
|
-
[self hbd_compensateSafeAreaForViewController:to expectedTopInset:expectedTopInset isToVC:YES];
|
|
368
|
-
[self hbd_compensateSafeAreaForViewController:from expectedTopInset:expectedTopInset isToVC:NO];
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
[self.nav updateNavigationBarForViewController:viewController];
|
|
372
|
-
if (to == viewController) {
|
|
373
|
-
self.nav.navigationBar.scrollEdgeAppearance.backgroundColor = viewController.hbd_barTintColor;
|
|
374
|
-
self.nav.navigationBar.standardAppearance.backgroundColor = viewController.hbd_barTintColor;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (shouldAnimateTabBar) {
|
|
379
|
-
[self animateTabBarForTransitionFrom:from to:to];
|
|
380
|
-
}
|
|
381
|
-
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
382
|
-
self.nav.poppingViewController = nil;
|
|
383
|
-
[self hbd_restoreCompensatedSafeAreaForFrom:from to:to viewController:viewController];
|
|
384
|
-
|
|
385
|
-
// Restore navigation bar state first, before clearing appearance.
|
|
386
|
-
if (context.isCancelled) {
|
|
387
|
-
if (to == viewController) {
|
|
388
|
-
[self.nav updateNavigationBarForViewController:from];
|
|
389
|
-
}
|
|
390
|
-
} else {
|
|
391
|
-
[self.nav updateNavigationBarForViewController:viewController];
|
|
392
|
-
UIViewController *poppingVC = self.nav.poppingViewController;
|
|
393
|
-
if (poppingVC && [poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
394
|
-
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
self.nav.navigationBar.scrollEdgeAppearance.backgroundColor = UIColor.clearColor;
|
|
399
|
-
self.nav.navigationBar.standardAppearance.backgroundColor = UIColor.clearColor;
|
|
400
|
-
|
|
401
|
-
if (shouldAnimateTabBar) {
|
|
402
|
-
[self completeTabBarTransitionFrom:from to:to cancelled:context.isCancelled];
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (to == viewController) {
|
|
406
|
-
[self.nav clearFake];
|
|
407
|
-
}
|
|
408
|
-
}];
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
- (BOOL)shouldAnimateTabBarFrom:(UIViewController *)from to:(UIViewController *)to {
|
|
412
|
-
UITabBarController *tabBarController = self.nav.tabBarController;
|
|
413
|
-
if (!tabBarController) {
|
|
414
|
-
return NO;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return from.hidesBottomBarWhenPushed != to.hidesBottomBarWhenPushed;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
- (void)prepareTabBarForTransitionFrom:(UIViewController *)from to:(UIViewController *)to {
|
|
421
|
-
UITabBar *tabBar = self.nav.tabBarController.tabBar;
|
|
422
|
-
[tabBar.layer removeAllAnimations];
|
|
423
|
-
tabBar.hidden = NO;
|
|
424
|
-
|
|
425
|
-
if (from.hidesBottomBarWhenPushed && !to.hidesBottomBarWhenPushed) {
|
|
426
|
-
// iOS 26 首次交互返回时,系统会过早让 TabBar 现身;先把初始 alpha 固定住,交给 coordinator 渐变。
|
|
427
|
-
tabBar.alpha = 0.0;
|
|
428
|
-
} else if (!from.hidesBottomBarWhenPushed && to.hidesBottomBarWhenPushed) {
|
|
429
|
-
tabBar.alpha = 1.0;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
- (void)animateTabBarForTransitionFrom:(UIViewController *)from to:(UIViewController *)to {
|
|
434
|
-
UITabBar *tabBar = self.nav.tabBarController.tabBar;
|
|
435
|
-
if (from.hidesBottomBarWhenPushed && !to.hidesBottomBarWhenPushed) {
|
|
436
|
-
tabBar.alpha = 1.0;
|
|
437
|
-
} else if (!from.hidesBottomBarWhenPushed && to.hidesBottomBarWhenPushed) {
|
|
438
|
-
tabBar.alpha = 0.0;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
- (void)completeTabBarTransitionFrom:(UIViewController *)from
|
|
443
|
-
to:(UIViewController *)to
|
|
444
|
-
cancelled:(BOOL)cancelled {
|
|
445
|
-
UITabBar *tabBar = self.nav.tabBarController.tabBar;
|
|
446
|
-
[tabBar.layer removeAllAnimations];
|
|
447
|
-
|
|
448
|
-
UIViewController *visibleViewController = cancelled ? from : to;
|
|
449
|
-
if (visibleViewController.hidesBottomBarWhenPushed) {
|
|
450
|
-
tabBar.alpha = 1.0;
|
|
451
|
-
tabBar.hidden = YES;
|
|
452
|
-
} else {
|
|
453
|
-
tabBar.hidden = NO;
|
|
454
|
-
tabBar.alpha = 1.0;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
- (void)resetButtonLabelInNavBar:(UINavigationBar *)navBar {
|
|
459
|
-
for (UIView *view in navBar.subviews) {
|
|
460
|
-
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
461
|
-
if ([viewName isEqualToString:@"UINavigationBarContentView"]) {
|
|
462
|
-
[self resetButtonLabelInView:view];
|
|
463
|
-
break;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
- (void)resetButtonLabelInView:(UIView *)view {
|
|
469
|
-
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
470
|
-
if ([viewName isEqualToString:@"UIButtonLabel"]) {
|
|
471
|
-
view.alpha = 1.0;
|
|
472
|
-
} else if (view.subviews.count > 0) {
|
|
473
|
-
for (UIView *sub in view.subviews) {
|
|
474
|
-
[self resetButtonLabelInView:sub];
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
// Fake bar: hide real bar (alpha=0) and add fromFakeBar/toFakeBar on each VC's view for smooth bar color change.
|
|
480
|
-
- (BOOL)shouldShowFakeBarFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *_Nonnull)viewController {
|
|
481
|
-
if ([GlobalStyle globalStyle].topBarHidden) {
|
|
482
|
-
return NO;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
if ([GlobalStyle globalStyle].alwaysSplitNavigationBarTransition && to == viewController) {
|
|
486
|
-
return YES;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (to != viewController) {
|
|
490
|
-
return NO;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
if (![from.hbd_barTintColor.description isEqual:to.hbd_barTintColor.description]) {
|
|
494
|
-
RCTLogInfo(@"from:%@, to:%@",
|
|
495
|
-
from.hbd_barTintColor.description,
|
|
496
|
-
to.hbd_barTintColor.description);
|
|
497
|
-
return YES;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
return from.hbd_barAlpha < 1.0 || to.hbd_barAlpha < 1.0;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
@end
|
|
504
|
-
|
|
505
24
|
@implementation HBDNavigationController
|
|
506
25
|
|
|
507
|
-
@dynamic navigationBar;
|
|
508
|
-
|
|
509
26
|
- (void)dealloc {
|
|
510
27
|
RCTLogInfo(@"[Navigation] %s", __FUNCTION__);
|
|
511
28
|
}
|
|
512
29
|
|
|
513
30
|
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
|
|
514
|
-
if (self = [super initWithNavigationBarClass:
|
|
515
|
-
if ([rootViewController isKindOfClass:[HBDViewController class]]) {
|
|
516
|
-
HBDViewController *root = (HBDViewController *) rootViewController;
|
|
517
|
-
self.tabBarItem = root.tabBarItem;
|
|
518
|
-
root.tabBarItem = nil;
|
|
519
|
-
NSDictionary *tabItem = root.options[@"tabItem"];
|
|
520
|
-
if (tabItem && tabItem[@"hideTabBarWhenPush"]) {
|
|
521
|
-
self.hidesBottomBarWhenPushed = [tabItem[@"hideTabBarWhenPush"] boolValue];
|
|
522
|
-
} else {
|
|
523
|
-
self.hidesBottomBarWhenPushed = YES;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
31
|
+
if (self = [super initWithNavigationBarClass:nil toolbarClass:nil]) {
|
|
526
32
|
self.viewControllers = @[rootViewController];
|
|
527
33
|
}
|
|
528
34
|
return self;
|
|
529
35
|
}
|
|
530
36
|
|
|
531
37
|
- (UIGestureRecognizer *)interactivePopGestureRecognizer {
|
|
532
|
-
return self.
|
|
38
|
+
return self.navigationPopGestureRecognizer;
|
|
533
39
|
}
|
|
534
40
|
|
|
535
41
|
- (UIGestureRecognizer *)superInteractivePopGestureRecognizer {
|
|
@@ -551,69 +57,59 @@
|
|
|
551
57
|
- (void)viewDidLoad {
|
|
552
58
|
[super viewDidLoad];
|
|
553
59
|
self.definesPresentationContext = NO;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
[
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
self
|
|
563
|
-
self.navigationBar.standardAppearance = [scrollEdgeAppearance copy];
|
|
564
|
-
|
|
565
|
-
self.navigationDelegate = [[HBDNavigationControllerDelegate alloc] initWithNavigationController:self];
|
|
566
|
-
self.navigationDelegate.proxyDelegate = self.delegate;
|
|
567
|
-
self.delegate = self.navigationDelegate;
|
|
60
|
+
|
|
61
|
+
self.navigationPopGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleNavigationTransition:)];
|
|
62
|
+
self.navigationPopGestureRecognizer.edges = UIRectEdgeLeft;
|
|
63
|
+
self.navigationPopGestureRecognizer.delegate = self;
|
|
64
|
+
[self.view addGestureRecognizer:self.navigationPopGestureRecognizer];
|
|
65
|
+
[self superInteractivePopGestureRecognizer].enabled = NO;
|
|
66
|
+
|
|
67
|
+
self.delegate = self;
|
|
68
|
+
[self setNavigationBarHidden:YES animated:NO];
|
|
568
69
|
}
|
|
569
70
|
|
|
570
71
|
- (void)setDelegate:(id <UINavigationControllerDelegate>)delegate {
|
|
571
|
-
if (
|
|
72
|
+
if (delegate == self || !self.navigationPopGestureRecognizer) {
|
|
572
73
|
[super setDelegate:delegate];
|
|
573
|
-
} else {
|
|
574
|
-
self.navigationDelegate.proxyDelegate = delegate;
|
|
575
74
|
}
|
|
576
75
|
}
|
|
577
76
|
|
|
578
|
-
- (
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (!coordinator) {
|
|
582
|
-
[self updateNavigationBarForViewController:self.topViewController];
|
|
77
|
+
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
|
78
|
+
if (self.transitionCoordinator) {
|
|
79
|
+
return NO;
|
|
583
80
|
}
|
|
584
|
-
}
|
|
585
81
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
return;
|
|
82
|
+
if (self.viewControllers.count > 1) {
|
|
83
|
+
UIViewController *topVC = self.topViewController;
|
|
84
|
+
if ([topVC isKindOfClass:[HBDViewController class]] && ((HBDViewController *)topVC).forceScreenLandscape) {
|
|
85
|
+
return NO;
|
|
86
|
+
}
|
|
87
|
+
return topVC.hbd_swipeBackEnabled && topVC.hbd_backInteractive;
|
|
592
88
|
}
|
|
89
|
+
return NO;
|
|
90
|
+
}
|
|
593
91
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
BOOL statusBarHidden = RCTKeyWindow().windowScene.statusBarManager.statusBarHidden;
|
|
598
|
-
|
|
599
|
-
// 状态栏隐藏时系统可能把 top 算成 0,补 20pt 避免内容贴顶
|
|
600
|
-
if (statusBarHidden && safeAreaInsets.top == 0) {
|
|
601
|
-
self.additionalSafeAreaInsets = UIEdgeInsetsMake(20, additionalInsets.left, additionalInsets.bottom, additionalInsets.right);
|
|
92
|
+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
93
|
+
if (gestureRecognizer == self.interactivePopGestureRecognizer) {
|
|
94
|
+
return YES;
|
|
602
95
|
}
|
|
96
|
+
return NO;
|
|
97
|
+
}
|
|
603
98
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
99
|
+
- (void)handleNavigationTransition:(UIScreenEdgePanGestureRecognizer *)pan {
|
|
100
|
+
id <HBDNavigationTransitionProtocol> target = (id <HBDNavigationTransitionProtocol>) [self superInteractivePopGestureRecognizer].delegate;
|
|
101
|
+
if ([target respondsToSelector:@selector(handleNavigationTransition:)]) {
|
|
102
|
+
[target handleNavigationTransition:pan];
|
|
607
103
|
}
|
|
608
104
|
}
|
|
609
105
|
|
|
610
|
-
- (
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
106
|
+
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
107
|
+
UIViewController *poppingVC = self.poppingViewController;
|
|
108
|
+
if (poppingVC && [poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
109
|
+
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
615
110
|
}
|
|
616
|
-
|
|
111
|
+
|
|
112
|
+
self.poppingViewController = nil;
|
|
617
113
|
}
|
|
618
114
|
|
|
619
115
|
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
|
|
@@ -640,119 +136,4 @@
|
|
|
640
136
|
return [super popToRootViewControllerAnimated:animated];
|
|
641
137
|
}
|
|
642
138
|
|
|
643
|
-
- (void)updateNavigationBarForViewController:(UIViewController *)vc {
|
|
644
|
-
// 仅全局 topBarHidden 时直接隐藏 UINavigationBar
|
|
645
|
-
if ([GlobalStyle globalStyle].topBarHidden) {
|
|
646
|
-
[self setNavigationBarHidden:YES animated:NO];
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
[self updateNavigationBarStyleForViewController:vc];
|
|
650
|
-
[self updateNavigationBarAlphaForViewController:vc];
|
|
651
|
-
[self updateNavigationBarBackgroundForViewController:vc];
|
|
652
|
-
[self updateNavigationBarTintColorForViewController:vc];
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
- (void)updateNavigationBarStyleForViewController:(UIViewController *)vc {
|
|
656
|
-
self.navigationBar.barStyle = vc.hbd_barStyle;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
- (void)updateNavigationBarTintColorForViewController:(UIViewController *)vc {
|
|
660
|
-
self.navigationBar.tintColor = vc.hbd_tintColor;
|
|
661
|
-
self.navigationBar.titleTextAttributes = vc.hbd_titleTextAttributes;
|
|
662
|
-
self.navigationBar.scrollEdgeAppearance.titleTextAttributes = vc.hbd_titleTextAttributes;
|
|
663
|
-
self.navigationBar.standardAppearance.titleTextAttributes = vc.hbd_titleTextAttributes;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
- (void)updateNavigationBarAlphaForViewController:(UIViewController *)vc {
|
|
667
|
-
self.navigationBar.fakeBackgroundView.alpha = vc.hbd_barAlpha;
|
|
668
|
-
self.navigationBar.fakeShadowView.alpha = vc.hbd_barShadowAlpha;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
- (void)updateNavigationBarBackgroundForViewController:(UIViewController *)vc {
|
|
672
|
-
self.navigationBar.barTintColor = vc.hbd_barTintColor;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
- (void)showFakeBarFrom:(UIViewController *)from to:(UIViewController *_Nonnull)to {
|
|
676
|
-
[UIView setAnimationsEnabled:NO];
|
|
677
|
-
self.navigationBar.fakeBackgroundView.alpha = 0;
|
|
678
|
-
self.navigationBar.fakeShadowView.alpha = 0;
|
|
679
|
-
[self showFakeBarFrom:from];
|
|
680
|
-
[self showFakeBarTo:to];
|
|
681
|
-
[UIView setAnimationsEnabled:YES];
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
- (void)showFakeBarFrom:(UIViewController *)from {
|
|
685
|
-
self.fromFakeBar.backgroundColor = from.hbd_barTintColor;
|
|
686
|
-
self.fromFakeBar.alpha = from.hbd_barAlpha;
|
|
687
|
-
self.fromFakeBar.frame = [self fakeBarFrameForViewController:from];
|
|
688
|
-
[from.view addSubview:self.fromFakeBar];
|
|
689
|
-
self.fromFakeShadow.alpha = from.hbd_barShadowAlpha;
|
|
690
|
-
self.fromFakeShadow.frame = [self fakeShadowFrameWithBarFrame:self.fromFakeBar.frame];
|
|
691
|
-
[from.view addSubview:self.fromFakeShadow];
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
- (void)showFakeBarTo:(UIViewController *_Nonnull)to {
|
|
695
|
-
self.toFakeBar.backgroundColor = to.hbd_barTintColor;
|
|
696
|
-
self.toFakeBar.alpha = to.hbd_barAlpha;
|
|
697
|
-
self.toFakeBar.frame = [self fakeBarFrameForViewController:to];
|
|
698
|
-
[to.view addSubview:self.toFakeBar];
|
|
699
|
-
self.toFakeShadow.alpha = to.hbd_barShadowAlpha;
|
|
700
|
-
self.toFakeShadow.frame = [self fakeShadowFrameWithBarFrame:self.toFakeBar.frame];
|
|
701
|
-
[to.view addSubview:self.toFakeShadow];
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
- (UIView *)fromFakeBar {
|
|
705
|
-
if (!_fromFakeBar) {
|
|
706
|
-
_fromFakeBar = [[UIView alloc] init];
|
|
707
|
-
}
|
|
708
|
-
return _fromFakeBar;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
- (UIView *)toFakeBar {
|
|
712
|
-
if (!_toFakeBar) {
|
|
713
|
-
_toFakeBar = [[UIView alloc] init];
|
|
714
|
-
}
|
|
715
|
-
return _toFakeBar;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
- (UIImageView *)fromFakeShadow {
|
|
719
|
-
if (!_fromFakeShadow) {
|
|
720
|
-
_fromFakeShadow = [[UIImageView alloc] initWithImage:self.navigationBar.fakeShadowView.image];
|
|
721
|
-
_fromFakeShadow.backgroundColor = self.navigationBar.fakeShadowView.backgroundColor;
|
|
722
|
-
}
|
|
723
|
-
return _fromFakeShadow;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
- (UIImageView *)toFakeShadow {
|
|
727
|
-
if (!_toFakeShadow) {
|
|
728
|
-
_toFakeShadow = [[UIImageView alloc] initWithImage:self.navigationBar.fakeShadowView.image];
|
|
729
|
-
_toFakeShadow.backgroundColor = self.navigationBar.fakeShadowView.backgroundColor;
|
|
730
|
-
}
|
|
731
|
-
return _toFakeShadow;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
- (void)clearFake {
|
|
735
|
-
[self.fromFakeBar removeFromSuperview];
|
|
736
|
-
[self.toFakeBar removeFromSuperview];
|
|
737
|
-
[self.fromFakeShadow removeFromSuperview];
|
|
738
|
-
[self.toFakeShadow removeFromSuperview];
|
|
739
|
-
_fromFakeBar = nil;
|
|
740
|
-
_toFakeBar = nil;
|
|
741
|
-
_fromFakeShadow = nil;
|
|
742
|
-
_toFakeShadow = nil;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
- (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
|
|
746
|
-
CGFloat height = self.navigationBar.frame.size.height + self.navigationBar.frame.origin.y;
|
|
747
|
-
if (vc.view.frame.size.height == self.view.frame.size.height) {
|
|
748
|
-
return CGRectMake(0, 0, self.navigationBar.frame.size.width, height);
|
|
749
|
-
}else{
|
|
750
|
-
return CGRectMake(0, -height, self.navigationBar.frame.size.width, height);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
- (CGRect)fakeShadowFrameWithBarFrame:(CGRect)frame {
|
|
755
|
-
return CGRectMake(frame.origin.x, frame.size.height + frame.origin.y - hairlineWidth, frame.size.width, hairlineWidth);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
139
|
@end
|