CNContactController needs to be presented in a navcontroller with a

translucent navbar.

In cases where we were presenting modally, we can easily modify the
modal to have a translucent navbar.

In the one place we were pushing onto the SignalsNavigationController,
rather than modifying the SNC.isTranslucent and having to clean it up,
I've opted to convert to a modal presentation.

// FREEBIE
This commit is contained in:
Michael Kirk 2018-05-18 16:17:45 -04:00 committed by Matthew Chen
parent 2709a91b5e
commit fe62a6ac92
4 changed files with 48 additions and 19 deletions

View file

@ -1099,7 +1099,6 @@ static NSTimeInterval launchStartedAt;
// Resume lazy restore.
[OWSBackupLazyRestoreJob runAsync];
#endif
}
- (void)registrationStateDidChange

View file

@ -74,11 +74,19 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
contactViewController.allowsEditing = true
contactViewController.delegate = self
guard let navigationController = self.navigationController else {
owsFail("\(logTag) in \(#function) navigationController was unexpectedly nil")
return
let modal = OWSNavigationController(rootViewController: contactViewController)
// HACK otherwise CNContactViewController Navbar is shows window background color.
// RADAR rdar://28433898 http://www.openradar.me/28433898
// CNContactViewController incompatible with opaque navigation bar
modal.navigationBar.isTranslucent = true
if #available(iOS 10, *) {
// Contact navbar is blue in iOS9, so our white text works,
// but gray on iOS10+, in which case we want the system default black text.
UIUtil.applyDefaultSystemAppearence()
}
navigationController.pushViewController(contactViewController, animated: true)
self.present(modal, animated: true)
}
func contactsPicker(_: ContactsPicker, didSelectMultipleContacts contacts: [Contact]) {
@ -126,8 +134,21 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
return
}
// HACK otherwise CNContactViewController Navbar is shows window background color.
// RADAR rdar://28433898 http://www.openradar.me/28433898
// CNContactViewController incompatible with opaque navigation bar
navigationController.navigationBar.isTranslucent = false
if #available(iOS 10, *) {
// Contact navbar is blue in iOS9, so our white text works,
// but gray on iOS10+, in which case we want the system default black text.
UIUtil.applySignalAppearence()
}
let previousViewControllerIndex = navigationController.viewControllers.index(before: myIndex)
let previousViewController = navigationController.viewControllers[previousViewControllerIndex]
navigationController.popToViewController(previousViewController, animated: true)
self.dismiss(animated: false) {
navigationController.popToViewController(previousViewController, animated: true)
}
}
}

View file

@ -163,12 +163,17 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
target: self,
action: #selector(didFinishEditingContact))
// HACK otherwise CNContactViewController Navbar is shown as black.
let modal = OWSNavigationController(rootViewController: contactViewController)
// HACK otherwise CNContactViewController Navbar is shows window background color.
// RADAR rdar://28433898 http://www.openradar.me/28433898
// CNContactViewController incompatible with opaque navigation bar
UIUtil.applyDefaultSystemAppearence()
modal.navigationBar.isTranslucent = true
if #available(iOS 10, *) {
// Contact navbar is blue in iOS9, so our white text works,
// but gray on iOS10+, in which case we want the system default black text.
UIUtil.applyDefaultSystemAppearence()
}
let modal = OWSNavigationController(rootViewController: contactViewController)
fromViewController.present(modal, animated: true)
}
@ -189,7 +194,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
}
let viewController = AddContactShareToExistingContactViewController(contactShare: contactShare)
UIUtil.applySignalAppearence()
navigationController.pushViewController(viewController, animated: true)
}

View file

@ -392,19 +392,23 @@ NS_ASSUME_NONNULL_BEGIN
target:fromViewController
action:@selector(didFinishEditingContact)];
OWSNavigationController *navigationController =
[[OWSNavigationController alloc] initWithRootViewController:contactViewController];
OWSNavigationController *modal = [[OWSNavigationController alloc] initWithRootViewController:contactViewController];
// HACK otherwise CNContactViewController Navbar is shows window background color.
// RADAR rdar://28433898 http://www.openradar.me/28433898
// CNContactViewController incompatible with opaque navigation bar
modal.navigationBar.translucent = YES;
if (@available(iOS 10, *)) {
// Contact navbar is blue in iOS9, so our white tex works,
// but gray on iOS10+, in which case we want the system default black text.
[UIUtil applyDefaultSystemAppearence];
}
// We want the presentation to imply a "replacement" in this case.
if (shouldEditImmediately) {
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
modal.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
}
[fromViewController presentViewController:navigationController animated:YES completion:nil];
// HACK otherwise CNContactViewController Navbar is shown as black.
// RADAR rdar://28433898 http://www.openradar.me/28433898
// CNContactViewController incompatible with opaque navigation bar
[UIUtil applyDefaultSystemAppearence];
[fromViewController presentViewController:modal animated:YES completion:nil];
}
@end