diff --git a/LGSideMenuController/LGSideMenuController.m b/LGSideMenuController/LGSideMenuController.m index cf38858..dd672c3 100644 --- a/LGSideMenuController/LGSideMenuController.m +++ b/LGSideMenuController/LGSideMenuController.m @@ -70,6 +70,16 @@ LGSideMenuSwipeGestureRange LGSideMenuSwipeGestureRangeMake(CGFloat left, CGFloa return range; } +typedef NS_ENUM(NSUInteger, LGSideMenuState) { + LGSideMenuStateRootViewIsShowing = 0, + LGSideMenuStateLeftViewWillShow = 1, + LGSideMenuStateLeftViewIsShowing = 2, + LGSideMenuStateLeftViewWillHide = 3, + LGSideMenuStateRightViewWillShow = 4, + LGSideMenuStateRightViewIsShowing = 5, + LGSideMenuStateRightViewWillHide = 6 +}; + #pragma mark - Interface @interface LGSideMenuController () @@ -78,14 +88,7 @@ @interface LGSideMenuController () @property (strong, nonatomic, readwrite) LGSideMenuView *leftViewContainer; @property (strong, nonatomic, readwrite) LGSideMenuView *rightViewContainer; -@property (assign, nonatomic, readwrite, getter=isLeftViewShowing) BOOL leftViewShowing; -@property (assign, nonatomic, readwrite, getter=isRightViewShowing) BOOL rightViewShowing; - -@property (assign, nonatomic, getter=isLeftViewWillShow) BOOL leftViewWillShow; -@property (assign, nonatomic, getter=isLeftViewWillHide) BOOL leftViewWillHide; - -@property (assign, nonatomic, getter=isRightViewWillShow) BOOL rightViewWillShow; -@property (assign, nonatomic, getter=isRightViewWillHide) BOOL rightViewWillHide; +@property (assign, nonatomic, readwrite) LGSideMenuState state; @property (assign, nonatomic) CGSize savedSize; @@ -453,17 +456,17 @@ - (BOOL)shouldAutorotate { - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; - if (self.isLeftViewWillShow) { + if (self.state == LGSideMenuStateLeftViewWillShow) { [self showLeftViewDoneWithGesture:(self.leftViewGestireStartX != nil)]; } - else if (self.isLeftViewWillHide) { + else if (self.state == LGSideMenuStateLeftViewWillHide) { [self hideLeftViewDoneWithGesture:(self.leftViewGestireStartX != nil)]; } - if (self.isRightViewWillShow) { + if (self.state == LGSideMenuStateRightViewWillShow) { [self showRightViewDoneWithGesture:(self.rightViewGestireStartX != nil)]; } - else if (self.isRightViewWillHide) { + else if (self.state == LGSideMenuStateRightViewWillHide) { [self hideRightViewDoneWithGesture:(self.rightViewGestireStartX != nil)]; } } @@ -471,50 +474,44 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id