Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Friend-LGA committed Nov 30, 2015
1 parent cda3e47 commit d9b5847
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
6 changes: 3 additions & 3 deletions LGSideMenuController/LGSideMenuController.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ typedef NS_ENUM(NSUInteger, LGSideMenuSwipeGestureArea)
/** Default is 0.5 */
@property (assign, nonatomic) IBInspectable NSTimeInterval rightViewAnimationSpeed;

@property (assign, nonatomic) IBInspectable BOOL shouldShowLeftView;
@property (assign, nonatomic) IBInspectable BOOL shouldShowRightView;

- (instancetype)initWithRootViewController:(UIViewController *)rootViewController;

- (UIView *)leftView;
Expand Down Expand Up @@ -257,9 +260,6 @@ typedef NS_ENUM(NSUInteger, LGSideMenuSwipeGestureArea)
- (void)hideRightViewAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler;
- (void)showHideRightViewAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler;

- (BOOL)shouldShowLeftView;
- (BOOL)shouldShowRightView;

/** Unavailable, select it on your rootViewController */
- (BOOL)shouldAutorotate __attribute__((unavailable("select it on your rootViewController")));
/** Unavailable, select it on your rootViewController */
Expand Down
21 changes: 9 additions & 12 deletions LGSideMenuController/LGSideMenuController.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ - (void)setupDefaults

// -----

_shouldShowLeftView = YES;
_shouldShowRightView = YES;

// -----

_backgroundImageViewForLeftView = [UIImageView new];
_backgroundImageViewForLeftView.hidden = YES;
_backgroundImageViewForLeftView.contentMode = UIViewContentModeScaleAspectFill;
Expand Down Expand Up @@ -540,14 +545,6 @@ - (void)setGesturesCancelsTouchesInView:(BOOL)gesturesCancelsTouchesInView
_panGesture.cancelsTouchesInView = gesturesCancelsTouchesInView;
}

- (BOOL)shouldShowLeftView {
return YES;
}

- (BOOL)shouldShowRightView {
return YES;
}

#pragma mark - Layout Subviews

- (void)leftViewWillLayoutSubviewsWithSize:(CGSize)size
Expand Down Expand Up @@ -1323,7 +1320,7 @@ - (void)showLeftViewPrepare

- (void)showLeftViewAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler
{
if (!kLGSideMenuIsLeftViewAlwaysVisible && !self.isLeftViewShowing &&
if (!kLGSideMenuIsLeftViewAlwaysVisible && !self.isLeftViewShowing && self.shouldShowLeftView &&
!(kLGSideMenuIsRightViewAlwaysVisible && _leftViewPresentationStyle != LGSideMenuPresentationStyleSlideAbove))
{
[self showLeftViewPrepare];
Expand Down Expand Up @@ -1481,7 +1478,7 @@ - (void)showRightViewPrepare

- (void)showRightViewAnimated:(BOOL)animated completionHandler:(void(^)())completionHandler
{
if (!kLGSideMenuIsRightViewAlwaysVisible && !self.isRightViewShowing &&
if (!kLGSideMenuIsRightViewAlwaysVisible && !self.isRightViewShowing && self.shouldShowRightView &&
!(kLGSideMenuIsLeftViewAlwaysVisible && _rightViewPresentationStyle != LGSideMenuPresentationStyleSlideAbove))
{
[self showRightViewPrepare];
Expand Down Expand Up @@ -1632,7 +1629,7 @@ - (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer

// -----

if (_leftView && self.isLeftViewSwipeGestureEnabled && !kLGSideMenuIsLeftViewAlwaysVisible && !_rightViewGestireStartX && !self.isRightViewShowing && [self shouldShowLeftView])
if (_leftView && self.isLeftViewSwipeGestureEnabled && !kLGSideMenuIsLeftViewAlwaysVisible && !_rightViewGestireStartX && !self.isRightViewShowing && self.shouldShowLeftView)
{
if (!_leftViewGestireStartX && (gestureRecognizer.state == UIGestureRecognizerStateBegan || gestureRecognizer.state == UIGestureRecognizerStateChanged))
{
Expand Down Expand Up @@ -1685,7 +1682,7 @@ - (void)panGesture:(UIPanGestureRecognizer *)gestureRecognizer

// -----

if (_rightView && self.isRightViewSwipeGestureEnabled && !kLGSideMenuIsRightViewAlwaysVisible && !_leftViewGestireStartX && !self.isLeftViewShowing && [self shouldShowRightView])
if (_rightView && self.isRightViewSwipeGestureEnabled && !kLGSideMenuIsRightViewAlwaysVisible && !_leftViewGestireStartX && !self.isLeftViewShowing && self.shouldShowRightView)
{
if (!_rightViewGestireStartX && (gestureRecognizer.state == UIGestureRecognizerStateBegan || gestureRecognizer.state == UIGestureRecognizerStateChanged))
{
Expand Down

0 comments on commit d9b5847

Please sign in to comment.