remove debug code, reorder for clarity

// FREEBIE
This commit is contained in:
Michael Kirk 2018-05-21 16:00:35 -04:00 committed by Matthew Chen
parent fe62a6ac92
commit 20424d9a7e
3 changed files with 62 additions and 62 deletions

View File

@ -38,51 +38,6 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (void)navBarCallLayoutDidChangeWithNavbar:(OWSNavigationBar *)navbar
{
[self updateLayoutForNavbar:navbar];
}
- (void)updateLayoutForNavbar:(OWSNavigationBar *)navbar
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
if (@available(iOS 11.0, *)) {
if (OWSWindowManager.sharedManager.hasCall) {
if (UIDevice.currentDevice.isIPhoneX) {
// iPhoneX computes status bar height differently.
self.additionalSafeAreaInsets = UIEdgeInsetsMake(navbar.navbarWithoutStatusHeight + 20, 0, 0, 0);
} else {
self.additionalSafeAreaInsets
= UIEdgeInsetsMake(navbar.navbarWithoutStatusHeight + CurrentAppContext().statusBarHeight, 0, 0, 0);
}
} else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
}
// in iOS11 we have to ensure the navbar frame *in* layoutSubviews.
[navbar layoutSubviews];
} else {
// Pre iOS11 we size the navbar, and position it vertically once.
[navbar sizeToFit];
if (OWSWindowManager.sharedManager.hasCall) {
CGRect oldFrame = navbar.frame;
CGRect newFrame
= CGRectMake(oldFrame.origin.x, navbar.callBannerHeight, oldFrame.size.width, oldFrame.size.height);
navbar.frame = newFrame;
} else {
CGRect oldFrame = navbar.frame;
CGRect newFrame
= CGRectMake(oldFrame.origin.x, navbar.statusBarHeight, oldFrame.size.width, oldFrame.size.height);
navbar.frame = newFrame;
}
// Since the navbar's frame was updated, we need to be sure our child VC's
// container view is updated.
[self.view setNeedsLayout];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
@ -138,6 +93,54 @@ NS_ASSUME_NONNULL_BEGIN
}
}
#pragma mark - NavBarLayoutDelegate
- (void)navBarCallLayoutDidChangeWithNavbar:(OWSNavigationBar *)navbar
{
[self updateLayoutForNavbar:navbar];
}
- (void)updateLayoutForNavbar:(OWSNavigationBar *)navbar
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
if (@available(iOS 11.0, *)) {
if (OWSWindowManager.sharedManager.hasCall) {
if (UIDevice.currentDevice.isIPhoneX) {
// iPhoneX computes status bar height differently.
self.additionalSafeAreaInsets = UIEdgeInsetsMake(navbar.navbarWithoutStatusHeight + 20, 0, 0, 0);
} else {
self.additionalSafeAreaInsets
= UIEdgeInsetsMake(navbar.navbarWithoutStatusHeight + CurrentAppContext().statusBarHeight, 0, 0, 0);
}
} else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
}
// in iOS11 we have to ensure the navbar frame *in* layoutSubviews.
[navbar layoutSubviews];
} else {
// Pre iOS11 we size the navbar, and position it vertically once.
[navbar sizeToFit];
if (OWSWindowManager.sharedManager.hasCall) {
CGRect oldFrame = navbar.frame;
CGRect newFrame
= CGRectMake(oldFrame.origin.x, navbar.callBannerHeight, oldFrame.size.width, oldFrame.size.height);
navbar.frame = newFrame;
} else {
CGRect oldFrame = navbar.frame;
CGRect newFrame
= CGRectMake(oldFrame.origin.x, navbar.statusBarHeight, oldFrame.size.width, oldFrame.size.height);
navbar.frame = newFrame;
}
// Since the navbar's frame was updated, we need to be sure our child VC's
// container view is updated.
[self.view setNeedsLayout];
}
}
@end
NS_ASSUME_NONNULL_END

View File

@ -65,17 +65,11 @@ class OWSNavigationBar: UINavigationBar {
// pre iOS11, sizeThatFits is repeatedly called to determine how much space to reserve for that navbar.
// That is, increasing this causes the child view controller to be pushed down.
// (as of iOS11, this is not used and instead we use additionalSafeAreaInsets)
let result = CGSize(width: fullWidth, height: navbarWithoutStatusHeight + statusBarHeight)
Logger.debug("\(self.logTag) in \(#function): \(result)")
return result
return CGSize(width: fullWidth, height: navbarWithoutStatusHeight + statusBarHeight)
}
}
override func layoutSubviews() {
Logger.debug("\(self.logTag) in \(#function) with frame: \(frame)")
guard OWSWindowManager.shared().hasCall() else {
super.layoutSubviews()
return

View File

@ -28,10 +28,6 @@ const CGFloat OWSWindowManagerCallScreenHeight(void)
// Behind everything, especially the root window.
const UIWindowLevel UIWindowLevel_Background = -1.f;
// Putting the call banner above the status bar is not ideal.
// It obscures status bar content like the system clock
// But being behind the status bar introduces two worse problems that'd we'd need to address
// 1. Tap target is too small, only the 20px below the status bar are tappable
const UIWindowLevel UIWindowLevel_ReturnToCall(void);
const UIWindowLevel UIWindowLevel_ReturnToCall(void)
{
@ -124,9 +120,6 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
OWSAssert(screenBlockingWindow);
OWSAssert(!self.screenBlockingWindow);
// MJK FIXME
rootWindow.backgroundColor = UIColor.yellowColor;
self.rootWindow = rootWindow;
self.screenBlockingWindow = screenBlockingWindow;
@ -211,6 +204,19 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
#pragma mark - Calls
- (void)setCallViewController:(nullable UIViewController *)callViewController
{
OWSAssertIsOnMainThread();
if (callViewController == _callViewController) {
return;
}
_callViewController = callViewController;
[NSNotificationCenter.defaultCenter postNotificationName:OWSWindowManagerCallDidChangeNotification object:nil];
}
- (void)startCall:(UIViewController *)callViewController
{
OWSAssertIsOnMainThread();
@ -218,8 +224,6 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
OWSAssert(!self.callViewController);
self.callViewController = callViewController;
// TODO move to setter?
[NSNotificationCenter.defaultCenter postNotificationName:OWSWindowManagerCallDidChangeNotification object:nil];
// Attach callViewController to window.
[self.callNavigationController popToRootViewControllerAnimated:NO];
@ -243,7 +247,6 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
// Dettach callViewController from window.
[self.callNavigationController popToRootViewControllerAnimated:NO];
self.callViewController = nil;
[NSNotificationCenter.defaultCenter postNotificationName:OWSWindowManagerCallDidChangeNotification object:nil];
self.shouldShowCallView = NO;