Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Xcode 9 and Swift 4.1 and iOS 11.3 #778

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 45 additions & 40 deletions SWRevealViewController/SWRevealViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ - (CGRect)finalFrameForViewController:(UIViewController *)vc
return _view.bounds;
}

- (void)pauseInteractiveTransition {
return;
}


@end


Expand Down Expand Up @@ -762,7 +767,7 @@ - (void)viewDidAppear:(BOOL)animated
}


- (NSUInteger)supportedInterfaceOrientations
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
// we could have simply not implemented this, but we choose to call super to make explicit that we
// want the default behavior.
Expand Down Expand Up @@ -1023,16 +1028,16 @@ - (void)_notifyPanGestureEnded

- (void)_getRevealWidth:(CGFloat*)pRevealWidth revealOverDraw:(CGFloat*)pRevealOverdraw forSymetry:(int)symetry
{
if ( symetry < 0 ) *pRevealWidth = _rightViewRevealWidth, *pRevealOverdraw = _rightViewRevealOverdraw;
else *pRevealWidth = _rearViewRevealWidth, *pRevealOverdraw = _rearViewRevealOverdraw;
if ( symetry < 0 ) (void)(*pRevealWidth = _rightViewRevealWidth), *pRevealOverdraw = _rightViewRevealOverdraw;
Copy link

@phoney phoney May 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the normal way to write this code. Just add braces and semicolons.
if ( symetry < 0 ) {*pRevealWidth = _rightViewRevealWidth; *pRevealOverdraw = _rightViewRevealOverdraw; }
else {*pRevealWidth = _rearViewRevealWidth; *pRevealOverdraw = _rearViewRevealOverdraw; }

Those void's are just not normally used like that.

else (void)(*pRevealWidth = _rearViewRevealWidth), *pRevealOverdraw = _rearViewRevealOverdraw;

if (*pRevealWidth < 0) *pRevealWidth = _contentView.bounds.size.width + *pRevealWidth;
}

- (void)_getBounceBack:(BOOL*)pBounceBack pStableDrag:(BOOL*)pStableDrag forSymetry:(int)symetry
{
if ( symetry < 0 ) *pBounceBack = _bounceBackOnLeftOverdraw, *pStableDrag = _stableDragOnLeftOverdraw;
else *pBounceBack = _bounceBackOnOverdraw, *pStableDrag = _stableDragOnOverdraw;
if ( symetry < 0 ) (void)(*pBounceBack = _bounceBackOnLeftOverdraw), *pStableDrag = _stableDragOnLeftOverdraw;
else (void)(*pBounceBack = _bounceBackOnOverdraw), *pStableDrag = _stableDragOnOverdraw;
}

- (void)_getAdjustedFrontViewPosition:(FrontViewPosition*)frontViewPosition forSymetry:(int)symetry
Expand Down Expand Up @@ -1398,21 +1403,21 @@ - (void)_dispatchTransitionOperation:(SWRevealControllerOperation)operation with
// Primitive method for view controller deployment and animated layout to the given position.
- (void)_setFrontViewPosition:(FrontViewPosition)newPosition withDuration:(NSTimeInterval)duration
{
void (^rearDeploymentCompletion)() = [self _rearViewDeploymentForNewFrontViewPosition:newPosition];
void (^rightDeploymentCompletion)() = [self _rightViewDeploymentForNewFrontViewPosition:newPosition];
void (^frontDeploymentCompletion)() = [self _frontViewDeploymentForNewFrontViewPosition:newPosition];
void (^rearDeploymentCompletion)(void) = [self _rearViewDeploymentForNewFrontViewPosition:newPosition];
void (^rightDeploymentCompletion)(void) = [self _rightViewDeploymentForNewFrontViewPosition:newPosition];
void (^frontDeploymentCompletion)(void) = [self _frontViewDeploymentForNewFrontViewPosition:newPosition];

void (^animations)() = ^()
void (^animations)(void) = ^()
{
// Calling this in the animation block causes the status bar to appear/dissapear in sync with our own animation
[self setNeedsStatusBarAppearanceUpdate];

// We call the layoutSubviews method on the contentView view and send a delegate, which will
// occur inside of an animation block if any animated transition is being performed
[_contentView layoutSubviews];
[self->_contentView layoutSubviews];

if ([_delegate respondsToSelector:@selector(revealController:animateToPosition:)])
[_delegate revealController:self animateToPosition:_frontViewPosition];
if ([self->_delegate respondsToSelector:@selector(revealController:animateToPosition:)])
[self->_delegate revealController:self animateToPosition:self->_frontViewPosition];
};

void (^completion)(BOOL) = ^(BOOL finished)
Expand Down Expand Up @@ -1455,21 +1460,21 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV
UIView *view = nil;

if ( operation == SWRevealControllerOperationReplaceRearController )
old = _rearViewController, _rearViewController = new, view = _contentView.rearView;
(void)(old = _rearViewController), (void)(_rearViewController = new), view = _contentView.rearView;

else if ( operation == SWRevealControllerOperationReplaceFrontController )
old = _frontViewController, _frontViewController = new, view = _contentView.frontView;
(void)(old = _frontViewController), (void)(_frontViewController = new), view = _contentView.frontView;

else if ( operation == SWRevealControllerOperationReplaceRightController )
old = _rightViewController, _rightViewController = new, view = _contentView.rightView;
(void)(old = _rightViewController), (void)(_rightViewController = new), view = _contentView.rightView;

void (^completion)() = [self _transitionFromViewController:old toViewController:new inView:view];
void (^completion)(void) = [self _transitionFromViewController:old toViewController:new inView:view];

void (^animationCompletion)() = ^
void (^animationCompletion)(void) = ^
{
completion();
if ( [_delegate respondsToSelector:@selector(revealController:didAddViewController:forOperation:animated:)] )
[_delegate revealController:self didAddViewController:new forOperation:operation animated:animated];
if ( [self->_delegate respondsToSelector:@selector(revealController:didAddViewController:forOperation:animated:)] )
[self->_delegate revealController:self didAddViewController:new forOperation:operation animated:animated];

[self _dequeue];
};
Expand Down Expand Up @@ -1527,16 +1532,16 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV

_frontViewPosition = newPosition;

void (^deploymentCompletion)() =
void (^deploymentCompletion)(void) =
[self _deploymentForViewController:_frontViewController inView:_contentView.frontView appear:appear disappear:disappear];

void (^completion)() = ^()
void (^completion)(void) = ^()
{
deploymentCompletion();
if ( positionIsChanging )
{
if ( [_delegate respondsToSelector:@selector(revealController:didMoveToPosition:)] )
[_delegate revealController:self didMoveToPosition:newPosition];
if ( [self->_delegate respondsToSelector:@selector(revealController:didMoveToPosition:)] )
[self->_delegate revealController:self didMoveToPosition:newPosition];
}
};

Expand All @@ -1561,14 +1566,14 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV

_rearViewPosition = newPosition;

void (^deploymentCompletion)() =
void (^deploymentCompletion)(void) =
[self _deploymentForViewController:_rearViewController inView:_contentView.rearView appear:appear disappear:disappear];

void (^completion)() = ^()
void (^completion)(void) = ^()
{
deploymentCompletion();
if ( disappear )
[_contentView unloadRearView];
[self->_contentView unloadRearView];
};

return completion;
Expand All @@ -1589,14 +1594,14 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV

_rightViewPosition = newPosition;

void (^deploymentCompletion)() =
void (^deploymentCompletion)(void) =
[self _deploymentForViewController:_rightViewController inView:_contentView.rightView appear:appear disappear:disappear];

void (^completion)() = ^()
void (^completion)(void) = ^()
{
deploymentCompletion();
if ( disappear )
[_contentView unloadRightView];
[self->_contentView unloadRightView];
};

return completion;
Expand Down Expand Up @@ -1626,15 +1631,15 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV
controllerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
controllerView.frame = frame;

if ( [controllerView isKindOfClass:[UIScrollView class]] )
{
BOOL adjust = controller.automaticallyAdjustsScrollViewInsets;
if ( adjust )
{
[(id)controllerView setContentInset:UIEdgeInsetsMake(statusBarAdjustment(_contentView), 0, 0, 0)];
}
}
// if ( [controllerView isKindOfClass:[UIScrollView class]] )
// {
// BOOL adjust = controller.automaticallyAdjustsScrollViewInsets;
//
// if ( adjust )
// {
// [(id)controllerView setContentInset:UIEdgeInsetsMake(statusBarAdjustment(_contentView), 0, 0, 0)];
// }
// }

[view addSubview:controllerView];

Expand Down Expand Up @@ -1672,11 +1677,11 @@ - (void)_performTransitionOperation:(SWRevealControllerOperation)operation withV

if ( toController ) [self addChildViewController:toController];

void (^deployCompletion)() = [self _deployForViewController:toController inView:view];
void (^deployCompletion)(void) = [self _deployForViewController:toController inView:view];

[fromController willMoveToParentViewController:nil];

void (^undeployCompletion)() = [self _undeployForViewController:fromController];
void (^undeployCompletion)(void) = [self _undeployForViewController:fromController];

void (^completionBlock)(void) = ^(void)
{
Expand Down