cleanup and move to OWSNavigationController

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

@ -1,8 +1,9 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSNavigationController.h"
#import "Signal-Swift.h"
// We use a category to expose UINavigationController's private
// UINavigationBarDelegate methods.
@ -20,6 +21,62 @@
@implementation OWSNavigationController
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
// Attempt 1: negative additionalSafeArea
// Failure: additionalSafeArea insets cannot be negative
// UIEdgeInsets newSafeArea = UIEdgeInsetsMake(-50, 30, 20, 30);
// rootViewController.additionalSafeAreaInsets = newSafeArea;
// Attempt 2: safeAreaInsets on vc.view
// failure. they're already 0
// UIEdgeInsets existingInsets = rootViewController.view.safeAreaInsets;
// Attempt 3: override topLayoutGuide?
// Failure - not called.
// overriding it does no good - it's not called by default layout code.
// presumably it just existing if you want to use it as an anchor.
// Attemp 4: sizeForChildContentConainer?
// Failure - not called.
// Attempt 5: autoSetDimension on navbar
// Failure: no effect on rendered size
// Attempt 6: manually set child frames in will/didLayoutSubviews
// glitchy, and viewcontrollers re-layout themselves afterwards anyway
// Attempt 7: Since we can't seem to *shrink* the navbar, maybe we can grow it.
// make additionalSafeAreaInsets
[self updateAdditionalSafeAreaInsets];
self = [self initWithNavigationBarClass:[SignalNavigationBar class] toolbarClass:nil];
[self pushViewController:rootViewController animated:NO];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowManagerCallDidChange:)
name:OWSWindowManagerCallDidChangeNotification
object:nil];
return self;
}
- (void)windowManagerCallDidChange:(NSNotification *)notification
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[self updateAdditionalSafeAreaInsets];
}
- (void)updateAdditionalSafeAreaInsets
{
if (OWSWindowManager.sharedManager.hasCall) {
self.additionalSafeAreaInsets = UIEdgeInsetsMake(64, 0, 0, 0);
} else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];

@ -22,123 +22,14 @@ static double const STALLED_PROGRESS = 0.9;
@implementation SignalsNavigationController
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController
{
// Attempt 1: negative additionalSafeArea
// Failure: additionalSafeArea insets cannot be negative
// UIEdgeInsets newSafeArea = UIEdgeInsetsMake(-50, 30, 20, 30);
// rootViewController.additionalSafeAreaInsets = newSafeArea;
// Attempt 2: safeAreaInsets on vc.view
// failure. they're already 0
// UIEdgeInsets existingInsets = rootViewController.view.safeAreaInsets;
// Attempt 3: override topLayoutGuide?
// Failure - not called.
// overriding it does no good - it's not called by default layout code.
// presumably it just existing if you want to use it as an anchor.
// Attemp 4: sizeForChildContentConainer?
// Failure - not called.
// Attempt 5: autoSetDimension on navbar
// Failure: no effect on rendered size
// Attempt 6: manually set child frames in will/didLayoutSubviews
// Attempt 7: Since we can't seem to *shrink* the navbar, maybe we can grow it.
// make additionalSafeAreaInsets
[self updateAdditionalSafeAreaInsets];
self = [self initWithNavigationBarClass:[SignalNavigationBar class] toolbarClass:nil];
[self pushViewController:rootViewController animated:NO];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowManagerCallDidChange:)
name:OWSWindowManagerCallDidChangeNotification
object:nil];
return self;
}
- (CGSize)sizeForChildContentContainer:(id<UIContentContainer>)container
withParentContainerSize:(CGSize)parentSize NS_AVAILABLE_IOS(8_0);
{
CGSize result = [super sizeForChildContentContainer:container withParentContainerSize:parentSize];
DDLogDebug(@"%@ in %s result: %@", self.logTag, __PRETTY_FUNCTION__, NSStringFromCGSize(result));
return result;
}
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
- (void)windowManagerCallDidChange:(NSNotification *)notification
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[self updateAdditionalSafeAreaInsets];
}
- (void)updateAdditionalSafeAreaInsets
{
if (OWSWindowManager.sharedManager.hasCall) {
self.additionalSafeAreaInsets = UIEdgeInsetsMake(64, 0, 0, 0);
} else {
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
}
}
- (id<UILayoutSupport>)topLayoutGuide
{
id<UILayoutSupport> result = [super topLayoutGuide];
DDLogDebug(@"%@ result: %@", self.logTag, result);
return result;
}
- (void)viewDidLoad {
[super viewDidLoad];
// self.view.safeAreaInsets =
// Do any additional setup after loading the view.
[self initializeObserver];
[self updateSocketStatusView];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// UIEdgeInsets newSafeArea = UIEdgeInsetsMake(50, 10, 20, 30);
// // Adjust the safe area insets of the
// // embedded child view controller.
// UIViewController *child = self.childViewControllers[0];
// child.additionalSafeAreaInsets = newSafeArea;
}
- (void)viewWillLayoutSubviews
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[super viewWillLayoutSubviews];
}
- (void)viewDidLayoutSubviews
{
DDLogDebug(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__);
[super viewDidLayoutSubviews];
// if (OWSWindowManager.sharedManager.hasCall) {
// self.topViewController.view.frame = CGRectMake(0, 44, 375, 583);
// self.topViewController.view.bounds = CGRectMake(0, 0, 375, 583);
// }
}
- (void)initializeSocketStatusBar {
if (!_socketStatusView) {
_socketStatusView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];

Loading…
Cancel
Save