Skip to content

Commit 8afea1d

Browse files
Jeff Arenaenriquez
Jeff Arena
authored andcommitted
Elilminate full-screen assumptions, while fixing an issue with screen rotation. Fixes ECSlidingViewController#63.
1 parent 3d02df0 commit 8afea1d

File tree

1 file changed

+8
-44
lines changed

1 file changed

+8
-44
lines changed

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ - (void)removeTopViewSnapshot;
4343
- (CGFloat)anchorRightTopViewCenter;
4444
- (CGFloat)anchorLeftTopViewCenter;
4545
- (CGFloat)resettedCenter;
46-
- (CGFloat)screenWidth;
47-
- (CGFloat)screenWidthForOrientation:(UIInterfaceOrientation)orientation;
4846
- (void)underLeftWillAppear;
4947
- (void)underRightWillAppear;
5048
- (void)topDidReset;
@@ -242,7 +240,7 @@ - (void)adjustLayout
242240
[self updateTopViewHorizontalCenter:self.anchorRightTopViewCenter];
243241
} else if ([self underLeftShowing] && [self topViewIsOffScreen]) {
244242
[self updateUnderLeftLayout];
245-
[self updateTopViewHorizontalCenter:self.screenWidth + self.resettedCenter];
243+
[self updateTopViewHorizontalCenter:self.view.bounds.size.width + self.resettedCenter];
246244
}
247245
}
248246

@@ -340,7 +338,7 @@ - (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations o
340338
if (side == ECLeft) {
341339
newCenter = -self.resettedCenter;
342340
} else if (side == ECRight) {
343-
newCenter = self.screenWidth + self.resettedCenter;
341+
newCenter = self.view.bounds.size.width + self.resettedCenter;
344342
}
345343

346344
[self topViewHorizontalCenterWillChange:newCenter];
@@ -477,7 +475,7 @@ - (void)removeTopViewSnapshot
477475
- (CGFloat)anchorRightTopViewCenter
478476
{
479477
if (self.anchorRightPeekAmount) {
480-
return self.screenWidth + self.resettedCenter - self.anchorRightPeekAmount;
478+
return self.view.bounds.size.width + self.resettedCenter - self.anchorRightPeekAmount;
481479
} else if (self.anchorRightRevealAmount) {
482480
return self.resettedCenter + self.anchorRightRevealAmount;
483481
} else {
@@ -490,35 +488,15 @@ - (CGFloat)anchorLeftTopViewCenter
490488
if (self.anchorLeftPeekAmount) {
491489
return -self.resettedCenter + self.anchorLeftPeekAmount;
492490
} else if (self.anchorLeftRevealAmount) {
493-
return -self.resettedCenter + (self.screenWidth - self.anchorLeftRevealAmount);
491+
return -self.resettedCenter + (self.view.bounds.size.width - self.anchorLeftRevealAmount);
494492
} else {
495493
return NSNotFound;
496494
}
497495
}
498496

499497
- (CGFloat)resettedCenter
500498
{
501-
return ceil(self.screenWidth / 2);
502-
}
503-
504-
- (CGFloat)screenWidth
505-
{
506-
return [self screenWidthForOrientation:[UIApplication sharedApplication].statusBarOrientation];
507-
}
508-
509-
- (CGFloat)screenWidthForOrientation:(UIInterfaceOrientation)orientation
510-
{
511-
CGSize size = [UIScreen mainScreen].bounds.size;
512-
UIApplication *application = [UIApplication sharedApplication];
513-
if (UIInterfaceOrientationIsLandscape(orientation))
514-
{
515-
size = CGSizeMake(size.height, size.width);
516-
}
517-
if (application.statusBarHidden == NO)
518-
{
519-
size.height -= MIN(application.statusBarFrame.size.width, application.statusBarFrame.size.height);
520-
}
521-
return size.width;
499+
return (self.view.bounds.size.width / 2);
522500
}
523501

524502
- (void)underLeftWillAppear
@@ -574,16 +552,8 @@ - (void)updateUnderLeftLayout
574552
[self.underLeftView setFrame:self.view.bounds];
575553
} else if (self.underLeftWidthLayout == ECVariableRevealWidth && !self.topViewIsOffScreen) {
576554
CGRect frame = self.view.bounds;
577-
CGFloat newWidth;
578-
579-
if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
580-
newWidth = [UIScreen mainScreen].bounds.size.height - self.anchorRightPeekAmount;
581-
} else {
582-
newWidth = [UIScreen mainScreen].bounds.size.width - self.anchorRightPeekAmount;
583-
}
584-
585-
frame.size.width = newWidth;
586555

556+
frame.size.width = frame.size.width - self.anchorRightPeekAmount;
587557
self.underLeftView.frame = frame;
588558
} else if (self.underLeftWidthLayout == ECFixedRevealWidth) {
589559
CGRect frame = self.view.bounds;
@@ -604,13 +574,7 @@ - (void)updateUnderRightLayout
604574
CGRect frame = self.view.bounds;
605575

606576
CGFloat newLeftEdge;
607-
CGFloat newWidth;
608-
609-
if (UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
610-
newWidth = [UIScreen mainScreen].bounds.size.height;
611-
} else {
612-
newWidth = [UIScreen mainScreen].bounds.size.width;
613-
}
577+
CGFloat newWidth = frame.size.width;
614578

615579
if (self.topViewIsOffScreen) {
616580
newLeftEdge = 0;
@@ -626,7 +590,7 @@ - (void)updateUnderRightLayout
626590
} else if (self.underRightWidthLayout == ECFixedRevealWidth) {
627591
CGRect frame = self.view.bounds;
628592

629-
CGFloat newLeftEdge = self.screenWidth - self.anchorLeftRevealAmount;
593+
CGFloat newLeftEdge = frame.size.width - self.anchorLeftRevealAmount;
630594
CGFloat newWidth = self.anchorLeftRevealAmount;
631595

632596
frame.origin.x = newLeftEdge;

0 commit comments

Comments
 (0)