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

small refactoring #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions SlideMenu/Helper Classes/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ - (BOOL)slideNavigationControllerShouldDisplayRightMenu

- (IBAction)bounceMenu:(id)sender
{
static Menu menu = MenuLeft;
static MenuSide menu = MenuSideLeft;

[[SlideNavigationController sharedInstance] bounceMenu:menu withCompletion:nil];

menu = (menu == MenuLeft) ? MenuRight : MenuLeft;
menu = (menu == MenuSideLeft) ? MenuSideRight : MenuSideLeft;
}

- (IBAction)slideOutAnimationSwitchChanged:(UISwitch *)sender
Expand All @@ -59,7 +59,7 @@ - (IBAction)limitPanGestureSwitchChanged:(UISwitch *)sender

- (IBAction)changeAnimationSelected:(id)sender
{
[[SlideNavigationController sharedInstance] openMenu:MenuRight withCompletion:nil];
[[SlideNavigationController sharedInstance] openMenu:MenuSideRight withCompletion:nil];
}

- (IBAction)shadowSwitchSelected:(UISwitch *)sender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

// Initial state of the view before animation starts
// This gets called right before the menu is about to reveal
- (void)prepareMenuForAnimation:(Menu)menu;
- (void)prepareMenuForAnimation:(MenuSide)menu;

// Animate the view based on the progress (progress is between 0 and 1)
- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress;
- (void)animateMenu:(MenuSide)menu withProgress:(CGFloat)progress;

// Gets called ff for any the instance of animator is being change
// You should make any cleanup that is needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ - (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha andFadeColor:(UIColor *

#pragma mark - SlideNavigationContorllerAnimation Methods -

- (void)prepareMenuForAnimation:(Menu)menu
- (void)prepareMenuForAnimation:(MenuSide)menu
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

self.fadeAnimationView.alpha = self.maximumFadeAlpha;
self.fadeAnimationView.frame = menuViewController.view.bounds;
}

- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress
- (void)animateMenu:(MenuSide)menu withProgress:(CGFloat)progress
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ - (id)initWithMinimumScale:(CGFloat)minimumScale

#pragma mark - SlideNavigationContorllerAnimation Methods -

- (void)prepareMenuForAnimation:(Menu)menu
- (void)prepareMenuForAnimation:(MenuSide)menu
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

menuViewController.view.transform = CGAffineTransformScale(menuViewController.view.transform, self.minimumScale, self.minimumScale);
}

- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress
- (void)animateMenu:(MenuSide)menu withProgress:(CGFloat)progress
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ - (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fa

#pragma mark - SlideNavigationContorllerAnimation Methods -

- (void)prepareMenuForAnimation:(Menu)menu
- (void)prepareMenuForAnimation:(MenuSide)menu
{
[self.fadeAnimation prepareMenuForAnimation:menu];
[self.scaleAnimation prepareMenuForAnimation:menu];
}

- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress
- (void)animateMenu:(MenuSide)menu withProgress:(CGFloat)progress
{
[self.fadeAnimation animateMenu:menu withProgress:progress];
[self.scaleAnimation animateMenu:menu withProgress:progress];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ - (id)initWithSlideMovement:(CGFloat)slideMovement

#pragma mark - SlideNavigationContorllerAnimation Methods -

- (void)prepareMenuForAnimation:(Menu)menu
- (void)prepareMenuForAnimation:(MenuSide)menu
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

Expand All @@ -63,53 +63,53 @@ - (void)prepareMenuForAnimation:(Menu)menu

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
{
rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
rect.origin.x = (menu == MenuSideLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
if (UIDeviceOrientationIsLandscape(orientation))
{
if (orientation == UIDeviceOrientationLandscapeRight)
{
rect.origin.y = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
rect.origin.y = (menu == MenuSideLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
rect.origin.y = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement;
rect.origin.y = (menu == MenuSideRight) ? self.slideMovement*-1 : self.slideMovement;
}
}
else
{
if (orientation == UIDeviceOrientationPortrait)
{
rect.origin.x = (menu == MenuLeft) ? self.slideMovement*-1 : self.slideMovement;
rect.origin.x = (menu == MenuSideLeft) ? self.slideMovement*-1 : self.slideMovement;
}
else
{
rect.origin.x = (menu == MenuRight) ? self.slideMovement*-1 : self.slideMovement;
rect.origin.x = (menu == MenuSideRight) ? self.slideMovement*-1 : self.slideMovement;
}
}
}

menuViewController.view.frame = rect;
}

- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress
- (void)animateMenu:(MenuSide)menu withProgress:(CGFloat)progress
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;

NSInteger location = (menu == MenuLeft)
NSInteger location = (menu == MenuSideLeft)
? (self.slideMovement * -1) + (self.slideMovement * progress)
: (self.slideMovement * (1-progress));

if (menu == MenuLeft)
if (menu == MenuSideLeft)
location = (location > 0) ? 0 : location;

if (menu == MenuRight)
if (menu == MenuSideRight)
location = (location < 0) ? 0 : location;

CGRect rect = menuViewController.view.frame;
Expand All @@ -135,15 +135,15 @@ - (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress

- (void)clear
{
[self clearMenu:MenuLeft];
[self clearMenu:MenuRight];
[self clearMenu:MenuSideLeft];
[self clearMenu:MenuSideRight];
}

#pragma mark - Private Method -

- (void)clearMenu:(Menu)menu
- (void)clearMenu:(MenuSide)menu
{
UIViewController *menuViewController = (menu == MenuLeft)
UIViewController *menuViewController = (menu == MenuSideLeft)
? [SlideNavigationController sharedInstance].leftMenu
: [SlideNavigationController sharedInstance].rightMenu;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ - (id)initWithMaximumFadeAlpha:(CGFloat)maximumFadeAlpha fadeColor:(UIColor *)fa

#pragma mark - SlideNavigationContorllerAnimation Methods -

- (void)prepareMenuForAnimation:(Menu)menu
- (void)prepareMenuForAnimation:(MenuSide)menu
{
[self.fadeAnimation prepareMenuForAnimation:menu];
[self.slideAnimation prepareMenuForAnimation:menu];
}

- (void)animateMenu:(Menu)menu withProgress:(CGFloat)progress
- (void)animateMenu:(MenuSide)menu withProgress:(CGFloat)progress
{
[self.fadeAnimation animateMenu:menu withProgress:progress];
[self.slideAnimation animateMenu:menu withProgress:progress];
Expand Down
12 changes: 6 additions & 6 deletions SlideMenu/Source/SlideNavigationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
- (BOOL)slideNavigationControllerShouldDisplayLeftMenu;
@end

typedef enum{
MenuLeft = 1,
MenuRight = 2
}Menu;
typedef enum {
MenuSideLeft = 1,
MenuSideRight = 2
} MenuSide;

@protocol SlideNavigationContorllerAnimator;
@interface SlideNavigationController : UINavigationController <UINavigationControllerDelegate>
Expand Down Expand Up @@ -68,8 +68,8 @@ extern NSString *const SlideNavigationControllerDidReveal;
- (void)popToRootAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion;
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion;
- (void)popAllAndSwitchToViewController:(UIViewController *)viewController withCompletion:(void (^)())completion;
- (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion;
- (void)openMenu:(Menu)menu withCompletion:(void (^)())completion;
- (void)bounceMenu:(MenuSide)menu withCompletion:(void (^)())completion;
- (void)openMenu:(MenuSide)menu withCompletion:(void (^)())completion;
- (void)closeMenuWithCompletion:(void (^)())completion;
- (void)toggleLeftMenu;
- (void)toggleRightMenu;
Expand Down
Loading