From e3e162f51f2517cdf66d871d6bcf657a18199f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 16 Apr 2014 17:37:24 +0200 Subject: [PATCH 1/4] Add JASidePanels.podspec --- JASidePanels.podspec | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 JASidePanels.podspec diff --git a/JASidePanels.podspec b/JASidePanels.podspec new file mode 100644 index 0000000..be93561 --- /dev/null +++ b/JASidePanels.podspec @@ -0,0 +1,13 @@ +Pod::Spec.new do |s| + s.name = 'JASidePanels' + s.version = '1.3.2' + s.license = { :type => 'MIT', :file => 'README.markdown' } + s.summary = 'UIViewController container designed for presenting a center panel with revealable side panels - one to the left and one to the right.' + s.homepage = 'https://github.com/gotosleep/JASidePanels' + s.author = { 'Jesse Andersen' => 'gotosleep@gmail.com' } + s.source = { :git => 'https://github.com/gotosleep/JASidePanels.git', :tag => '1.3.2' } + s.platform = :ios, '5.0' + s.source_files = 'JASidePanels/Source/*' + s.framework = 'QuartzCore' + s.requires_arc = true +end From 83d7b55e4828f4418d184b1c4aab55a0f3b6e44b Mon Sep 17 00:00:00 2001 From: Chung-Ping Lau Date: Sun, 15 Oct 2017 22:05:25 +0800 Subject: [PATCH 2/4] Fix conficting gesture --- JASidePanels/Source/JASidePanelController.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/JASidePanels/Source/JASidePanelController.m b/JASidePanels/Source/JASidePanelController.m index 7cfde70..425398a 100644 --- a/JASidePanels/Source/JASidePanelController.m +++ b/JASidePanels/Source/JASidePanelController.m @@ -473,12 +473,13 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { #pragma mark - Pan Gestures -- (void)_addPanGestureToView:(UIView *)view { +- (UIPanGestureRecognizer*)_addPanGestureToView:(UIView *)view { UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_handlePan:)]; panGesture.delegate = self; panGesture.maximumNumberOfTouches = 1; panGesture.minimumNumberOfTouches = 1; - [view addGestureRecognizer:panGesture]; + [view addGestureRecognizer:panGesture]; + return panGesture; } - (void)_handlePan:(UIGestureRecognizer *)sender { @@ -576,18 +577,20 @@ - (void)setTapView:(UIView *)tapView { if (_tapView) { _tapView.frame = self.centerPanelContainer.bounds; _tapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - [self _addTapGestureToView:_tapView]; + UITapGestureRecognizer *tapGesture = [self _addTapGestureToView:_tapView]; if (self.recognizesPanGesture) { - [self _addPanGestureToView:_tapView]; + UIPanGestureRecognizer *panGesture = [self _addPanGestureToView:_tapView]; + [tapGesture requireGestureRecognizerToFail:panGesture]; } [self.centerPanelContainer addSubview:_tapView]; } } } -- (void)_addTapGestureToView:(UIView *)view { +- (UITapGestureRecognizer*)_addTapGestureToView:(UIView *)view { UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_centerPanelTapped:)]; [view addGestureRecognizer:tapGesture]; + return tapGesture; } - (void)_centerPanelTapped:(__unused UIGestureRecognizer *)gesture { From 8dfa3cbb3580d1d108557e0dac055c8c7e1dcdc4 Mon Sep 17 00:00:00 2001 From: Ernesto Rivera Date: Fri, 21 Dec 2018 09:07:54 -0400 Subject: [PATCH 3/4] Remove iOS 6 code --- JASidePanels/Source/JASidePanelController.m | 22 --------------------- 1 file changed, 22 deletions(-) diff --git a/JASidePanels/Source/JASidePanelController.m b/JASidePanels/Source/JASidePanelController.m index 425398a..39f59ea 100644 --- a/JASidePanels/Source/JASidePanelController.m +++ b/JASidePanels/Source/JASidePanelController.m @@ -192,28 +192,6 @@ - (void)viewDidAppear:(BOOL)animated{ [self _adjustCenterFrame]; //Account for possible rotation while view appearing } -#if !defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0 - -- (void)viewDidUnload { - [super viewDidUnload]; - self.tapView = nil; - self.centerPanelContainer = nil; - self.leftPanelContainer = nil; - self.rightPanelContainer = nil; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { - __strong UIViewController *visiblePanel = self.visiblePanel; - - if (self.shouldDelegateAutorotateToVisiblePanel) { - return [visiblePanel shouldAutorotateToInterfaceOrientation:toInterfaceOrientation]; - } else { - return YES; - } -} - -#else - - (BOOL)shouldAutorotate { __strong UIViewController *visiblePanel = self.visiblePanel; From 5f8df7ff05b78ad39e76c4d76c233ad946759aa6 Mon Sep 17 00:00:00 2001 From: Ernesto Rivera Date: Fri, 21 Dec 2018 09:08:13 -0400 Subject: [PATCH 4/4] Fix all build warnings --- JASidePanels/Source/JASidePanelController.m | 55 ++++++++------------- 1 file changed, 21 insertions(+), 34 deletions(-) diff --git a/JASidePanels/Source/JASidePanelController.m b/JASidePanels/Source/JASidePanelController.m index 39f59ea..581aa5e 100644 --- a/JASidePanels/Source/JASidePanelController.m +++ b/JASidePanels/Source/JASidePanelController.m @@ -202,19 +202,11 @@ - (BOOL)shouldAutorotate { } } - -#endif - -- (void)willAnimateRotationToInterfaceOrientation:(__unused UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { - self.centerPanelContainer.frame = [self _adjustCenterFrame]; - [self _layoutSideContainers:YES duration:duration]; - [self _layoutSidePanels]; - [self styleContainer:self.centerPanelContainer animate:YES duration:duration]; - if (self.centerPanelHidden) { - CGRect frame = self.centerPanelContainer.frame; - frame.origin.x = self.state == JASidePanelLeftVisible ? self.centerPanelContainer.frame.size.width : -self.centerPanelContainer.frame.size.width; - self.centerPanelContainer.frame = frame; - } +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self styleContainer:self.centerPanelContainer animate:YES duration:0]; + }); } #pragma mark - State @@ -348,11 +340,11 @@ - (void)setCenterPanel:(UIViewController *)centerPanel { if (self.bounceOnCenterPanelChange) { // first move the centerPanel offscreen CGFloat x = (previousState == JASidePanelLeftVisible) ? self.view.bounds.size.width : -self.view.bounds.size.width; - _centerPanelRestingFrame.origin.x = x; + self->_centerPanelRestingFrame.origin.x = x; } - self.centerPanelContainer.frame = _centerPanelRestingFrame; + self.centerPanelContainer.frame = self->_centerPanelRestingFrame; } completion:^(__unused BOOL finished) { - [self _swapCenter:previous previousState:previousState with:_centerPanel]; + [self _swapCenter:previous previousState:previousState with:self->_centerPanel]; [self _showCenterPanel:YES bounce:NO]; }]; } @@ -441,7 +433,7 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if (translate.x > 0 && ! self.allowLeftSwipe) { return NO; } - BOOL possible = translate.x != 0 && ((fabsf(translate.y) / fabsf(translate.x)) < 1.0f); + BOOL possible = translate.x != 0 && ((fabs(translate.y) / fabs(translate.x)) < 1.0f); if (possible && ((translate.x > 0 && self.leftPanel) || (translate.x < 0 && self.rightPanel))) { return YES; } @@ -451,13 +443,12 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { #pragma mark - Pan Gestures -- (UIPanGestureRecognizer*)_addPanGestureToView:(UIView *)view { +- (void)_addPanGestureToView:(UIView *)view { UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_handlePan:)]; panGesture.delegate = self; panGesture.maximumNumberOfTouches = 1; panGesture.minimumNumberOfTouches = 1; - [view addGestureRecognizer:panGesture]; - return panGesture; + [view addGestureRecognizer:panGesture]; } - (void)_handlePan:(UIGestureRecognizer *)sender { @@ -555,20 +546,18 @@ - (void)setTapView:(UIView *)tapView { if (_tapView) { _tapView.frame = self.centerPanelContainer.bounds; _tapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - UITapGestureRecognizer *tapGesture = [self _addTapGestureToView:_tapView]; + [self _addTapGestureToView:_tapView]; if (self.recognizesPanGesture) { - UIPanGestureRecognizer *panGesture = [self _addPanGestureToView:_tapView]; - [tapGesture requireGestureRecognizerToFail:panGesture]; + [self _addPanGestureToView:_tapView]; } [self.centerPanelContainer addSubview:_tapView]; } } } -- (UITapGestureRecognizer*)_addTapGestureToView:(UIView *)view { +- (void)_addTapGestureToView:(UIView *)view { UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_centerPanelTapped:)]; [view addGestureRecognizer:tapGesture]; - return tapGesture; } - (void)_centerPanelTapped:(__unused UIGestureRecognizer *)gesture { @@ -590,8 +579,6 @@ - (CGFloat)_correctMovement:(CGFloat)movement { } else if (self.state == JASidePanelRightVisible && !self.allowRightOverpan) { if (position < -self.rightVisibleWidth) { return 0.0f; - } else if ((self.style == JASidePanelMultipleActive || self.pushesSidePanels) && position > 0.0f) { - return -_centerPanelRestingFrame.origin.x; } else if (position > self.rightPanelContainer.frame.origin.x) { return self.rightPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x; } @@ -614,7 +601,7 @@ - (BOOL)_validateThreshold:(CGFloat)movement { return movement <= -minimum; } case JASidePanelCenterVisible: { - return fabsf(movement) >= minimum; + return fabs(movement) >= minimum; } case JASidePanelRightVisible: { return movement >= minimum; @@ -707,8 +694,8 @@ - (void)_unloadPanels { #pragma mark - Animation - (CGFloat)_calculatedDuration { - CGFloat remaining = fabsf(self.centerPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x); - CGFloat max = _locationBeforePan.x == _centerPanelRestingFrame.origin.x ? remaining : fabsf(_locationBeforePan.x - _centerPanelRestingFrame.origin.x); + CGFloat remaining = fabs(self.centerPanelContainer.frame.origin.x - _centerPanelRestingFrame.origin.x); + CGFloat max = _locationBeforePan.x == _centerPanelRestingFrame.origin.x ? remaining : fabs(_locationBeforePan.x - _centerPanelRestingFrame.origin.x); return max > 0.0f ? self.maximumAnimationDuration * (remaining / max) : self.maximumAnimationDuration; } @@ -722,7 +709,7 @@ - (void)_animateCenterPanel:(BOOL)shouldBounce completion:(void (^)(BOOL finishe CGFloat duration = [self _calculatedDuration]; [UIView animateWithDuration:duration delay:0.0f options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionLayoutSubviews animations:^{ - self.centerPanelContainer.frame = _centerPanelRestingFrame; + self.centerPanelContainer.frame = self->_centerPanelRestingFrame; [self styleContainer:self.centerPanelContainer animate:YES duration:duration]; if (self.style == JASidePanelMultipleActive || self.pushesSidePanels) { [self _layoutSideContainers:NO duration:0.0f]; @@ -739,12 +726,12 @@ - (void)_animateCenterPanel:(BOOL)shouldBounce completion:(void (^)(BOOL finishe } // animate the bounce [UIView animateWithDuration:self.bounceDuration delay:0.0f options:UIViewAnimationOptionCurveEaseOut animations:^{ - CGRect bounceFrame = _centerPanelRestingFrame; + CGRect bounceFrame = self->_centerPanelRestingFrame; bounceFrame.origin.x += bounceDistance; self.centerPanelContainer.frame = bounceFrame; } completion:^(__unused BOOL finished2) { [UIView animateWithDuration:self.bounceDuration delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{ - self.centerPanelContainer.frame = _centerPanelRestingFrame; + self.centerPanelContainer.frame = self->_centerPanelRestingFrame; } completion:completion]; }]; } else if (completion) { @@ -1001,7 +988,7 @@ - (void)setCenterPanelHidden:(BOOL)centerPanelHidden animated:(BOOL)animated dur } } completion:^(__unused BOOL finished) { // need to double check in case the user tapped really fast - if (_centerPanelHidden) { + if (self->_centerPanelHidden) { [self _hideCenterPanel]; } }];