diff --git a/Signal/src/ViewControllers/ContactShareViewHelper.swift b/Signal/src/ViewControllers/ContactShareViewHelper.swift index 89e6c4d74..200c8e4ca 100644 --- a/Signal/src/ViewControllers/ContactShareViewHelper.swift +++ b/Signal/src/ViewControllers/ContactShareViewHelper.swift @@ -158,23 +158,18 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate { contactViewController.delegate = self contactViewController.allowsActions = false contactViewController.allowsEditing = true - contactViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: CommonStrings.cancelButton, style: .plain, target: self, action: #selector(didFinishEditingContact)) contactViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: CommonStrings.cancelButton, style: .plain, target: self, action: #selector(didFinishEditingContact)) - guard let navigationController = fromViewController.navigationController else { - owsFail("\(logTag) missing navigationController") - return - } - - navigationController.pushViewController(contactViewController, animated: true) - // HACK otherwise CNContactViewController Navbar is shown as black. // RADAR rdar://28433898 http://www.openradar.me/28433898 // CNContactViewController incompatible with opaque navigation bar UIUtil.applyDefaultSystemAppearence() + + let modal = UINavigationController(rootViewController: contactViewController) + fromViewController.present(modal, animated: true) } private func presentSelectAddToExistingContactView(contactShare: ContactShareViewModel, fromViewController: UIViewController) { @@ -208,6 +203,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate { return } + UIUtil.applySignalAppearence() delegate.didCreateOrEditContact() } @@ -219,6 +215,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate { return } + UIUtil.applySignalAppearence() delegate.didCreateOrEditContact() } } diff --git a/Signal/src/ViewControllers/ContactViewController.swift b/Signal/src/ViewControllers/ContactViewController.swift index 00d41c001..f4d200ef1 100644 --- a/Signal/src/ViewControllers/ContactViewController.swift +++ b/Signal/src/ViewControllers/ContactViewController.swift @@ -39,8 +39,6 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate { private var contactShareViewHelper: ContactShareViewHelper - private weak var postDismissNavigationController: UINavigationController? - // MARK: - Initializers @available(*, unavailable, message: "use init(call:) constructor instead.") @@ -77,8 +75,11 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - // Use "dark" style navigation bar in this view. - UIUtil.applyDefaultSystemAppearence() + // Use "dark" style status bar in this view, + // But we don't apply the entire default system UI (UIUtil.applyDefaultSystemAppearence) because + // doing so while pushing onto an existing nav controller who's navbars are hidden corrupts the + // title label/navbar items elsewhere in the stack. + CurrentAppContext().setStatusBarStyle(.default) guard let navigationController = self.navigationController else { owsFail("\(logTag) in \(#function) navigationController was unexpectedly nil") @@ -86,35 +87,26 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate { } navigationController.isNavigationBarHidden = true - // self.navigationController is nil in viewDidDisappear when transition via message/call buttons - // so we maintain our own reference. - self.postDismissNavigationController = navigationController - contactsManager.requestSystemContactsOnce(completion: { [weak self] _ in guard let strongSelf = self else { return } strongSelf.updateMode() }) } - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - - // Use "dark" style navigation bar in this view. - UIUtil.applyDefaultSystemAppearence() - } - override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - // We don't need to use UIUtil to restore appearance (e.g. of navigation bar). - // This view is only presented from conversation view which will restore - // "Signal" appearance. + if self.presentedViewController == nil { + // No need to do this when we're disappearing due to a modal presentation. + // We'll eventually return to to this view and need to hide again. But also, there is a visible animation glitch where the navigation bar for this view controller starts to appear while the whole nav stack is about to be obscured by the modal we are presenting. - guard let strongNavigationController = postDismissNavigationController else { - owsFail("\(self.logTag) in \(#function) navigationController was unexpectedly nil") - return + guard let navigationController = self.navigationController else { + owsFail("\(logTag) in \(#function) navigationController was unexpectedly nil") + return + } + + navigationController.setNavigationBarHidden(false, animated: animated) } - strongNavigationController.isNavigationBarHidden = false } override func loadView() { @@ -675,13 +667,9 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate { public func didCreateOrEditContact() { Logger.info("\(logTag) \(#function)") - - guard let navigationController = self.navigationController else { - owsFail("\(logTag) in \(#function) navigationController was unexpectedly nil") - return - } - navigationController.popToViewController(self, animated: true) - updateContent() + + UIUtil.applySignalAppearence() + self.dismiss(animated: true) } } diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 378c9052a..c1fd6ad52 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -5058,8 +5058,7 @@ interactionControllerForAnimationController:(id