From 772af10e500d051aa7859b901d1677706d77d019 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 10 May 2018 15:10:47 -0400 Subject: [PATCH] Resizing call banner window problem is the navigation bar is now too tall, since it has room for status. We could shirnk the nav bar, but maybe it's easier to just have the call banner in the navbar? // FREEBIE --- Signal/src/util/OWSWindowManager.m | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Signal/src/util/OWSWindowManager.m b/Signal/src/util/OWSWindowManager.m index 114dc403c..832623158 100644 --- a/Signal/src/util/OWSWindowManager.m +++ b/Signal/src/util/OWSWindowManager.m @@ -156,6 +156,13 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void) label.font = [UIFont ows_regularFontWithSize:14.f]; [rootView addSubview:label]; + [label autoPinBottomToSuperviewMargin]; + [label setCompressionResistanceHigh]; + [label setContentHuggingHigh]; + [label autoHCenterInSuperview]; + + // TODO animate... + // returnToCallLabel uses manual layout. // // TODO: Is there a better way to do this? @@ -329,21 +336,21 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void) } else if (self.callViewController) { // Show Root Window + "Return to Call". - [self ensureRootWindowShown]; + [self ensureRootWindowShownWithActiveCall:YES]; [self ensureReturnToCallWindowShown]; [self ensureCallViewWindowHidden]; [self ensureScreenBlockWindowHidden]; } else { // Show Root Window - [self ensureRootWindowShown]; + [self ensureRootWindowShownWithActiveCall:NO]; [self ensureReturnToCallWindowHidden]; [self ensureCallViewWindowHidden]; [self ensureScreenBlockWindowHidden]; } } -- (void)ensureRootWindowShown +- (void)ensureRootWindowShownWithActiveCall:(BOOL)isActiveCall { OWSAssertIsOnMainThread(); @@ -351,11 +358,27 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void) DDLogInfo(@"%@ showing root window.", self.logTag); } + static CGRect defaultFrame; + static CGRect frameWithActiveCall; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + defaultFrame = self.rootWindow.frame; + + CGFloat callBannerHeight = self.returnToCallWindow.frame.size.height; + frameWithActiveCall + = CGRectMake(0, callBannerHeight, defaultFrame.size.width, defaultFrame.size.height - callBannerHeight); + }); + + if (isActiveCall) { + self.rootWindow.frame = frameWithActiveCall; + } else { + self.rootWindow.frame = defaultFrame; + } + // By calling makeKeyAndVisible we ensure the rootViewController becomes firt responder. // In the normal case, that means the SignalViewController will call `becomeFirstResponder` // on the vc on top of its navigation stack. [self.rootWindow makeKeyAndVisible]; - } - (void)ensureRootWindowHidden