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

Route "viewDidAppear" to presented view in left/right panel #150

Open
wants to merge 2 commits 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
3 changes: 3 additions & 0 deletions JASidePanels/Source/JASidePanelController.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ typedef enum _JASidePanelState {
// If set to yes, "shouldAutorotateToInterfaceOrientation:" will be passed to self.visiblePanel instead of handled directly
@property (nonatomic, assign) BOOL shouldDelegateAutorotateToVisiblePanel; // defaults to YES

// If set to yes, "preferredStatusBarStyle" will be passed to self.visiblePanel instead of handled directly
@property (nonatomic, assign) BOOL shouldDelegatePreferredStatusBarStyleToVisiblePanel; // defaults to YES

// Determines whether or not the panel's views are removed when not visble. If YES, rightPanel & leftPanel's views are eligible for viewDidUnload
@property (nonatomic, assign) BOOL canUnloadRightPanel; // defaults to NO
@property (nonatomic, assign) BOOL canUnloadLeftPanel; // defaults to NO
Expand Down
16 changes: 16 additions & 0 deletions JASidePanels/Source/JASidePanelController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ @implementation JASidePanelController
@synthesize bounceOnCenterPanelChange = _bounceOnCenterPanelChange;
@synthesize visiblePanel = _visiblePanel;
@synthesize shouldDelegateAutorotateToVisiblePanel = _shouldDelegateAutorotateToVisiblePanel;
@synthesize shouldDelegatePreferredStatusBarStyleToVisiblePanel = _shouldDelegatePreferredStatusBarStyleToVisiblePanel;
@synthesize centerPanelHidden = _centerPanelHidden;
@synthesize allowLeftSwipe = _allowLeftSwipe;
@synthesize allowRightSwipe = _allowRightSwipe;
Expand Down Expand Up @@ -146,6 +147,7 @@ - (void)_baseInit {
self.bounceOnSidePanelClose = NO;
self.bounceOnCenterPanelChange = YES;
self.shouldDelegateAutorotateToVisiblePanel = YES;
self.shouldDelegatePreferredStatusBarStyleToVisiblePanel = YES;
self.allowRightSwipe = YES;
self.allowLeftSwipe = YES;
}
Expand Down Expand Up @@ -227,6 +229,16 @@ - (BOOL)shouldAutorotate {

#endif

- (UIStatusBarStyle)preferredStatusBarStyle {
__strong UIViewController *visiblePanel = self.visiblePanel;

if (self.shouldDelegatePreferredStatusBarStyleToVisiblePanel && [visiblePanel respondsToSelector:@selector(preferredStatusBarStyle)]) {
return [visiblePanel preferredStatusBarStyle];
} else {
return [UIApplication sharedApplication].statusBarStyle;
}
}

- (void)willAnimateRotationToInterfaceOrientation:(__unused UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
self.centerPanelContainer.frame = [self _adjustCenterFrame];
[self _layoutSideContainers:YES duration:duration];
Expand Down Expand Up @@ -691,6 +703,8 @@ - (void)_loadLeftPanel {
_leftPanel.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self stylePanel:_leftPanel.view];
[self.leftPanelContainer addSubview:_leftPanel.view];
} else {
[self.leftPanel viewDidAppear:YES];
}

self.leftPanelContainer.hidden = NO;
Expand All @@ -706,6 +720,8 @@ - (void)_loadRightPanel {
_rightPanel.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self stylePanel:_rightPanel.view];
[self.rightPanelContainer addSubview:_rightPanel.view];
} else {
[self.leftPanel viewDidAppear:YES];
}

self.rightPanelContainer.hidden = NO;
Expand Down