BBANavigationController.h
5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// BBANavigationController.h
// BBAPods
//
// Created by guojin on 16/4/7.
// Copyright © 2016年 Baidu. All rights reserved.
//
/******************************************************************************/
// 描述:BBANavigationController
// 目的:负责UINavigationController中子控制器切换过程中的手势(全屏及侧滑手势)禁用/开启|状态栏Style管理|
// 使用的业务:视频落地页
/******************************************************************************/
#import <UIKit/UIKit.h>
#import <BBAUIKit/BBAShouldAutorotateProtocol.h>
#import "FullscreenPopGestureRecognizer.h"
#import "BBAThreeDirectionPopGestureManager.h"
#pragma mark - Notification
#define BBANavWillShowViewControllerNotification @"BBANavWillShowViewControllerNotification"
#define BBANavDidShowViewControllerNotification @"BBANavDidShowViewControllerNotification"
@interface BBANavigationController : UINavigationController
//栈外元素对旋转的控制(栈内元素通过实现UIViewController的shouldAutorotate,supportedInterfaceOrientations来管理)
@property(nonnull, assign)id<BBAShouldAutorotateProtocol> rotateDelegate;
//动画期间pop的视图
@property (nullable, nonatomic, weak) UIViewController * popingController;
//全屏手势响应默认值 默认开启
@property (nonatomic,assign) BOOL defaultFullGesterShouldRecognizer;
//是否跳过转场动画
@property (nonatomic,assign) BOOL needSkipTransitionAnimation;
/// 特定主题
@property (nonatomic, copy) NSString* _Nonnull specificThemeMode;
- (nullable instancetype)initWithNavigationBarClass:(nullable Class)navigationBarClass
rootViewController:(nullable UIViewController*)rootViewController;
//图集多方向手势控制
//手势控制(图集多方向 + 全屏手势)
- (void)forbidCustomizedPopGesture:(BOOL)forbid;
//用于外部调起时,栈内元素退场,需要VC实现bbaDismissBlock属性。(因为页面dismiss前可能会有保存缓存等操作,因此需要页面自己处理dismiss逻辑)
- (void)dismissTriggeredByOpenURL;
// 全屏手势或边缘手势正在响应
- (BOOL)isInScreenPopGesture;
//用于外部控制gesture的优先级
- (nullable UIGestureRecognizer *)fullScreenPopGesture;
- (nullable UIGestureRecognizer *)screenEdgePopGesture;
/**
在调用UINavigationController -setViewControllers:animated:方法后检查位于顶部的vc支持的屏幕方向,旋转到正确方向;
@param viewControllers The view controllers to place in the stack. The front-to-back order of the controllers in this array represents the new bottom-to-top order of the controllers in the navigation stack. Thus, the last item added to the array becomes the top item of the navigation stack.
@param animated If YES, animate the pushing or popping of the top view controller. If NO, replace the view controllers without any animations.
*/
- (void)bba_setViewControllers:(nullable NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated;
@end
@interface UIViewController (BBANavigationControllerItem)
//Push、Pop时根据要展示的UIViewController属性,决定是否禁用右滑返回手势
@property(nonatomic, assign)BOOL bbaPopGestureDisable;
@end
@interface UIViewController (BBADismissTriggeredByOpenURL)
typedef void(^BBADismissBlock)(void);
//处理外部调起时页面退场,需要有退场需求的VC实现
@property (nullable, nonatomic, copy)BBADismissBlock bbaDismissBlock;
//VC退场处理函数,如果是VC销毁必须处理的请放在dealloc中处理,会被导航控制主动调用
- (void)bba_processingBeforeDealloc;
@end
//定义UIViewController生命周期协议,背景:pushViewController:animated:NO时,原栈顶元素收不到对应生命周期方法
@protocol BBAViewControllerLifeCycle <NSObject>
- (void)bbaViewWillDisappearWithNoAnimation;
@end
@interface UINavigationController (BBAUINavigationControllerChildController)
- (nullable UIViewController*)controllerInStack:(nullable Class)controllerClass
fromTop:(BOOL)fromTop;
- (NSInteger)controllerIndexInStack:(nullable Class)controllerClass
fromTop:(BOOL)fromTop;
//用于手势期间获取栈内元素
- (nullable UIViewController *)bbaAnimationTopViewController;
- (nullable UIViewController *)bbaTopViewController;
/**
* @brief 手势和动画期间的 topvc
*
* @return topvc
*/
- (nullable UIViewController *)bbaTransitingTopViewController;
- (nullable NSArray<UIViewController *> *)bbaViewControllers;
//兼容BBANavigation setViewControllers附带转屏校验, 非BBANavigation只进行setViewControllers转发
- (void)bba_setViewControllers:(nullable NSArray<UIViewController *> *)viewControllers animated:(BOOL)animated;
@end
@protocol BBACustomTransitioningProtocol <NSObject>
@optional
- (nullable id <UIViewControllerInteractiveTransitioning>)bba_navigationController:(nullable UINavigationController *)navigationController
interactionControllerForAnimationController:(nullable id <UIViewControllerAnimatedTransitioning>) animationController;
- (nullable id <UIViewControllerAnimatedTransitioning>)bba_navigationController:(nullable UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(nullable UIViewController *)fromVC
toViewController:(nullable UIViewController *)toVC;
- (nullable id)bba_gestureAnimationWithFromView:(nullable UIView *)fromView
toView:(nullable UIView *)toView
containerView:(nullable UIView *)layoutContainerView;
@end