This commit is contained in:
DDIsFriend
2023-08-18 17:28:57 +08:00
commit f0e8a1709d
4282 changed files with 192396 additions and 0 deletions
@@ -0,0 +1,15 @@
//
// DDBaseNavigationController.h
// DDBasicControlsKit_Private
// Created by DDIsFriend on 2022/9/20.
#import <UIKit/UIKit.h>
#import <DDCategoryKit_Private/UINavigationController+DDCategory.h>
NS_ASSUME_NONNULL_BEGIN
@interface DDBaseNavigationController : UINavigationController
- (void)screenEdgePanGestureRecognizerEnable:(BOOL)enable;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,108 @@
//
// DDBaseNavigationController.m
// DDBasicControlsKit_Private
// Created by DDIsFriend on 2022/9/20.
#import "DDBaseNavigationController.h"
#import "DDNavigationControllerDelegateReceiver.h"
#import <DDLogKit_Private/DDOCLog.h>
@interface DDBaseNavigationController ()
@property (nullable , nonatomic, strong)DDNavigationControllerDelegateReceiver *delegateReceiver;
@property (nullable , nonatomic, strong)UIScreenEdgePanGestureRecognizer *screenEdgePanGestureRecognizer;
@end
@implementation DDBaseNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
[self config];
[self addNavigationControllerDelegateReceiver];
[self addScreenEdgePanGestureRecognizer];
}
// MARK: <Custom Function>
- (void)config{
self.dd_hidesBottomBarWhenPushed = YES;
}
- (void)addNavigationControllerDelegateReceiver{
self.delegateReceiver = [[DDNavigationControllerDelegateReceiver alloc] init];
self.delegate = self.delegateReceiver;
}
// MARK: <ScreenEdgePanGestureRecognizer>
- (void)addScreenEdgePanGestureRecognizer{
UIScreenEdgePanGestureRecognizer *interactivePopGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognizerToPop:)];
interactivePopGestureRecognizer.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:interactivePopGestureRecognizer];
self.screenEdgePanGestureRecognizer = interactivePopGestureRecognizer;
// self.interactivePopGestureRecognizer.delegate = self;
self.interactivePopGestureRecognizer.enabled = NO;
}
- (void)panGestureRecognizerToPop:(UIPanGestureRecognizer *)ges{
if (ges.state == UIGestureRecognizerStateBegan){
if (self.viewControllers.count == 1){
return;
}
self.delegateReceiver.percentDrivenInteractiveTransition = [UIPercentDrivenInteractiveTransition new];
[self popViewControllerAnimated:YES];
}
CGFloat progress = [ges translationInView:self.view].x / [UIScreen mainScreen].bounds.size.width;
if (ges.state == UIGestureRecognizerStateChanged){
[self.delegateReceiver.percentDrivenInteractiveTransition updateInteractiveTransition:progress];
}else if (ges.state == UIGestureRecognizerStateEnded || ges.state == UIGestureRecognizerStateCancelled){
if (progress >= 0.5){
[self.delegateReceiver.percentDrivenInteractiveTransition finishInteractiveTransition];
}else{
[self.delegateReceiver.percentDrivenInteractiveTransition cancelInteractiveTransition];
}
self.delegateReceiver.percentDrivenInteractiveTransition = nil;
}else if (ges.state == UIGestureRecognizerStateFailed){
return;
}
}
- (void)screenEdgePanGestureRecognizerEnable:(BOOL)enable{
self.screenEdgePanGestureRecognizer.enabled = enable;
}
// MARK: <UIStatusBarStyle>
//- (UIStatusBarStyle)preferredStatusBarStyle{
// return UIStatusBarStyleDefault;
//}
// override this method will instead - (UIStatusBarStyle)preferredStatusBarStyle.
- (UIViewController *)childViewControllerForStatusBarStyle{
return self.topViewController;
}
- (UIViewController *)childViewControllerForStatusBarHidden{
return self.topViewController;
}
// MARK: <Orientations>
- (BOOL)shouldAutorotate{
return self.topViewController.shouldAutorotate;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
return self.topViewController.supportedInterfaceOrientations;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return self.topViewController.preferredInterfaceOrientationForPresentation;
}
// MARK: <Dealloc>
- (void)dealloc{
DDLog(@"Attention:控制器 ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----%@ dealloc",[self class]);
}
@end
@@ -0,0 +1,14 @@
//
// DDNavigationControllerDelegateReceiver.h
// DDBasicControlsKit_Private
// Created by DDIsFriend on 2022/9/20.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface DDNavigationControllerDelegateReceiver : NSObject <UINavigationControllerDelegate>
@property (nonatomic, strong, nullable)UIPercentDrivenInteractiveTransition *percentDrivenInteractiveTransition;
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,32 @@
//
// UINavigationControllerDelegateReceiver.m
// DDBasicControlsKit_Private
// Created by DDIsFriend on 2022/9/20.
#import "DDNavigationControllerDelegateReceiver.h"
#import <DDBasicControlsKit_Private/DDViewControllerAnimatedTransition.h>
@implementation DDNavigationControllerDelegateReceiver
// MARK: <UINavigationControllerDelegate>
- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController{
return self.percentDrivenInteractiveTransition;
}
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController *)fromVC
toViewController:(UIViewController *)toVC {
if (operation == UINavigationControllerOperationNone) {
return [[DDViewControllerAnimatedTransition alloc] initWithTransitionType:DDViewControllerAnimatedTransitionNone];
}
if (operation == UINavigationControllerOperationPush){
return [[DDViewControllerAnimatedTransition alloc] initWithTransitionType:DDViewControllerAnimatedTransitionPush];
}
return [[DDViewControllerAnimatedTransition alloc] initWithTransitionType:DDViewControllerAnimatedTransitionPop];
}
@end