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

Update status bar when open/close menu [support landscape orientation] #188

Open
wants to merge 3 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
19 changes: 18 additions & 1 deletion MFSideMenu/MFSideMenuContainerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,15 @@ - (void)setMenuState:(MFSideMenuState)menuState completion:(void (^)(void))compl
// these callbacks are called when the menu will become visible, not neccessarily when they will OPEN
- (void)leftMenuWillShow {
[self.leftMenuViewController view].hidden = NO;
[self.leftMenuViewController beginAppearanceTransition:YES animated:YES];
[self.leftMenuViewController endAppearanceTransition];
[self.menuContainerView bringSubviewToFront:[self.leftMenuViewController view]];
}

- (void)rightMenuWillShow {
[self.rightMenuViewController view].hidden = NO;
[self.rightMenuViewController beginAppearanceTransition:YES animated:YES];
[self.rightMenuViewController endAppearanceTransition];
[self.menuContainerView bringSubviewToFront:[self.rightMenuViewController view]];
}

Expand Down Expand Up @@ -716,6 +720,7 @@ - (void)setUserInteractionStateForCenterViewController {
NSArray *viewControllers = [self.centerViewController viewControllers];
for(UIViewController* viewController in viewControllers) {
viewController.view.userInteractionEnabled = (self.menuState == MFSideMenuStateClosed);
viewController.navigationController.interactivePopGestureRecognizer.enabled = (self.menuState == MFSideMenuStateClosed);
}
}
}
Expand Down Expand Up @@ -759,6 +764,18 @@ - (void) setCenterViewControllerOffset:(CGFloat)xOffset {
frame.origin.x = xOffset;
[self.centerViewController view].frame = frame;

if ([self.panGestureDelegate respondsToSelector:@selector(mfSideMenuPanGestureRecognizerDidPanWithOffset:)]) {
[self.panGestureDelegate mfSideMenuPanGestureRecognizerDidPanWithOffset:xOffset];
}
if (darkenStatusBarWhenMenuOpens) {
CGFloat menuWidth = MAX(_leftMenuWidth, _rightMenuWidth);
CGFloat menuOpenedPerecent = ABS(xOffset) / menuWidth;
CGRect statusBarFrame = self.statusBarBackgoundView.frame;
statusBarFrame.size.width = self.view.bounds.size.width;
self.statusBarBackgoundView.frame = statusBarFrame;
self.statusBarBackgoundView.alpha = menuOpenedPerecent;
}

if(!self.menuSlideAnimationEnabled) return;

if(xOffset > 0){
Expand Down Expand Up @@ -791,4 +808,4 @@ - (CGFloat)animationDurationFromStartPosition:(CGFloat)startPosition toEndPositi
return MIN(duration, self.menuAnimationMaxDuration);
}

@end
@end