Skip to content

Commit

Permalink
Version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Lluch committed Mar 9, 2014
1 parent b669863 commit 09e104e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
10 changes: 10 additions & 0 deletions RevealControllerExample/RevealControllerProject/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ - (void)revealController:(SWRevealViewController *)revealController panGestureEn
NSLog( @"%@: %f, %f", NSStringFromSelector(_cmd), location, progress);
}

- (void)revealController:(SWRevealViewController *)revealController willAddViewController:(UIViewController *)viewController forOperation:(SWRevealControllerOperation)operation animated:(BOOL)animated
{
NSLog( @"%@: %@, %d", NSStringFromSelector(_cmd), viewController, operation);
}

- (void)revealController:(SWRevealViewController *)revealController didAddViewController:(UIViewController *)viewController forOperation:(SWRevealControllerOperation)operation animated:(BOOL)animated
{
NSLog( @"%@: %@, %d", NSStringFromSelector(_cmd), viewController, operation);
}

#endif


Expand Down
47 changes: 26 additions & 21 deletions SWRevealViewController/SWRevealViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ static CGFloat scaledValue( CGFloat v1, CGFloat min2, CGFloat max2, CGFloat min1
return result;
}


- (id)initWithFrame:(CGRect)frame controller:(SWRevealViewController*)controller
{
self = [super initWithFrame:frame];
Expand Down Expand Up @@ -189,6 +190,7 @@ - (CGRect)hierarchycalFrameAdjustment:(CGRect)frame
return frame;
}


- (void)layoutSubviews
{
if ( _disableLayout ) return;
Expand Down Expand Up @@ -365,6 +367,7 @@ @implementation SWContextTransitionObject
void (^_completion)(void);
}


- (id)initWithRevealController:(SWRevealViewController*)revealVC containerView:(UIView*)view fromVC:(UIViewController*)fromVC
toVC:(UIViewController*)toVC completion:(void (^)(void))completion
{
Expand All @@ -380,16 +383,19 @@ - (id)initWithRevealController:(SWRevealViewController*)revealVC containerView:(
return self;
}


- (UIView *)containerView
{
return _view;
}


- (BOOL)isAnimated
{
return YES;
}


- (BOOL)isInteractive
{
return NO; // not supported
Expand All @@ -400,31 +406,37 @@ - (BOOL)transitionWasCancelled
return NO; // not supported
}


- (UIModalPresentationStyle)presentationStyle
{
return UIModalPresentationNone; // not applicable
}


- (void)updateInteractiveTransition:(CGFloat)percentComplete
{
// not supported
}


- (void)finishInteractiveTransition
{
// not supported
}


- (void)cancelInteractiveTransition
{
// not supported
}


- (void)completeTransition:(BOOL)didComplete
{
_completion();
}


- (UIViewController *)viewControllerForKey:(NSString *)key
{
if ( [key isEqualToString:UITransitionContextFromViewControllerKey] )
Expand All @@ -436,11 +448,13 @@ - (UIViewController *)viewControllerForKey:(NSString *)key
return nil;
}


- (CGRect)initialFrameForViewController:(UIViewController *)vc
{
return _view.bounds;
}


- (CGRect)finalFrameForViewController:(UIViewController *)vc
{
return _view.bounds;
Expand All @@ -459,6 +473,7 @@ @implementation SWDefaultAnimationController
NSTimeInterval _duration;
}


- (id)initWithDuration:(NSTimeInterval)duration
{
self = [super init];
Expand All @@ -469,11 +484,13 @@ - (id)initWithDuration:(NSTimeInterval)duration
return self;
}


- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
{
return _duration;
}


- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
Expand Down Expand Up @@ -739,13 +756,13 @@ - (NSUInteger)supportedInterfaceOrientations
return [super supportedInterfaceOrientations];
}

// Support for earlier than iOS 6.0
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
#endif
//// Support for earlier than iOS 6.0
//#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
//{
// return YES;
//}
//#endif


#pragma mark - Public methods and property accessors
Expand Down Expand Up @@ -798,17 +815,6 @@ - (void)setRearViewController:(UIViewController *)rearViewController animated:(B
}


//- (void)setRightViewController:(UIViewController *)rightViewController
//{
// if ( ![self isViewLoaded])
// {
// [self _setRightViewController:rightViewController];
// return;
// }
//
// [self _dispatchSetRightViewController:rightViewController];
//}

- (void)setRightViewController:(UIViewController *)rightViewController
{
[self setRightViewController:rightViewController animated:NO];
Expand Down Expand Up @@ -836,6 +842,7 @@ - (void)revealToggleAnimated:(BOOL)animated
[self setFrontViewPosition:toogledFrontViewPosition animated:animated];
}


- (void)rightRevealToggleAnimated:(BOOL)animated
{
FrontViewPosition toogledFrontViewPosition = FrontViewPositionLeft;
Expand Down Expand Up @@ -904,6 +911,7 @@ - (void)revealToggle:(id)sender
[self revealToggleAnimated:YES];
}


- (void)rightRevealToggle:(id)sender
{
[self rightRevealToggleAnimated:YES];
Expand Down Expand Up @@ -1029,7 +1037,6 @@ - (void)_dequeue

#pragma mark - Gesture Delegate


- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)recognizer
{
// only allow gesture if no previous request is in process
Expand Down Expand Up @@ -1084,15 +1091,13 @@ - (BOOL)_panGestureShouldBegin

#pragma mark - Gesture Based Reveal


- (void)_handleTapGesture:(UITapGestureRecognizer *)recognizer
{
NSTimeInterval duration = _toggleAnimationDuration;
[self _setFrontViewPosition:FrontViewPositionLeft withDuration:duration];
}



- (void)_handleRevealGesture:(UIPanGestureRecognizer *)recognizer
{
switch ( recognizer.state )
Expand Down

0 comments on commit 09e104e

Please sign in to comment.