initial render is wrong, but settles somewhere nice

-[x] fix initial placement
-[x] add additional top safe area?

// FREEBIE
pull/1/head
Michael Kirk 7 years ago committed by Matthew Chen
parent 3a9391f4fb
commit a2b1793262

@ -528,7 +528,7 @@ typedef enum : NSUInteger {
[super loadView];
// extendedLayoutIncludesOpaqueBars
self.extendedLayoutIncludesOpaqueBars = YES;
// self.extendedLayoutIncludesOpaqueBars = YES;
self.view.backgroundColor = [UIColor ows_toolbarBackgroundColor];
}

@ -49,9 +49,9 @@ static double const STALLED_PROGRESS = 0.9;
// Attempt 7: Since we can't seem to *shrink* the navbar, maybe we can grow it.
// make additionalSafeAreaInsets
// self.additionalSafeAreaInsets = UIEdgeInsetsMake(100, 0, 0, 0);
[self updateAdditionalSafeAreaInsets];
self = [self initWithNavigationBarClass:[SignalNavigationBar class] toolbarClass:nil];
[self pushViewController:rootViewController animated:NO];
@ -82,9 +82,15 @@ static double const STALLED_PROGRESS = 0.9;
- (void)windowManagerCallDidChange:(NSNotification *)notification
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
if (OWSWindowManager.sharedManager.hasCall) {
[self updateAdditionalSafeAreaInsets];
}
- (void)updateAdditionalSafeAreaInsets
{
if (OWSWindowManager.sharedManager.hasCall) {
self.additionalSafeAreaInsets = UIEdgeInsetsMake(64, 0, 0, 0);
} else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
}
}

@ -323,15 +323,15 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
}
CGRect defaultFrame = [UIScreen mainScreen].bounds;
if (isActiveCall) {
CGRect frameWithActiveCall = CGRectMake(0,
OWSWindowManagerCallScreenHeight(),
defaultFrame.size.width,
defaultFrame.size.height - OWSWindowManagerCallScreenHeight());
self.rootWindow.frame = frameWithActiveCall;
} else {
self.rootWindow.frame = defaultFrame;
}
// if (isActiveCall) {
// CGRect frameWithActiveCall = CGRectMake(0,
// OWSWindowManagerCallScreenHeight(),
// defaultFrame.size.width,
// defaultFrame.size.height - OWSWindowManagerCallScreenHeight());
// 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`

@ -11,6 +11,7 @@ class SignalNavigationBar: UINavigationBar {
// TODO - get a more precise value
// TODO - test with other heights, e.g. w/ hotspot, w/ call in other app
let navbarHeight: CGFloat = 44
let callBannerHeight: CGFloat = 40
override init(frame: CGRect) {
super.init(frame: frame)
@ -24,6 +25,11 @@ class SignalNavigationBar: UINavigationBar {
}
private func callDidChange() {
// if OWSWindowManager.shared().hasCall() {
// self.bounds.origin.y = -20
// } else {
// self.bounds.origin.y = 0
// }
if #available(iOS 11, *) {
self.layoutSubviews()
} else {
@ -53,6 +59,23 @@ class SignalNavigationBar: UINavigationBar {
return result
}
// override var center: CGPoint {
// get {
// Logger.debug("\(self.logTag) in \(#function)")
// return super.center
// }
// set {
// Logger.debug("\(self.logTag) in \(#function)")
// if OWSWindowManager.shared().hasCall() {
// var translated = newValue
//// translated.y -= 20
// super.center = translated
// } else {
// super.center = newValue
// }
// }
// }
// seems unused.
// override var intrinsicContentSize: CGSize {
// return CGSize(width: UIScreen.main.bounds.width, height: navbarHeight)
@ -87,7 +110,7 @@ class SignalNavigationBar: UINavigationBar {
// let rect = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: self.navbarHeightWithoutStatusBar)
// self.frame = CGRect(x: 0, y: 20, width: UI Screen.main.bounds.width, height: ios11NavbarHeight)
self.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: navbarHeight)
self.frame = CGRect(x: 0, y: callBannerHeight, width: UIScreen.main.bounds.width, height: navbarHeight)
self.bounds = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: navbarHeight)
super.layoutSubviews()
@ -95,9 +118,9 @@ class SignalNavigationBar: UINavigationBar {
for subview in self.subviews {
let stringFromClass = NSStringFromClass(subview.classForCoder)
if stringFromClass.contains("BarBackground") {
subview.frame = self.bounds
subview.frame = self.bounds//.offsetBy(dx: 0, dy: 20)
} else if stringFromClass.contains("BarContentView") {
subview.frame = self.bounds
subview.frame = self.bounds//.offsetBy(dx: 0, dy: 20)
}
}
}

Loading…
Cancel
Save