remove appearance juggling

pull/1/head
Michael Kirk 7 years ago
parent d5fa7f9b25
commit 104e63ded9

@ -171,7 +171,7 @@ static NSTimeInterval launchStartedAt;
[self versionMigrationsDidComplete];
}];
[UIUtil applySignalAppearence];
[UIUtil setupSignalAppearence];
if (CurrentAppContext().isRunningTests) {
return YES;

@ -87,17 +87,6 @@ class AddContactShareToExistingContactViewController: ContactsPicker, ContactsPi
contactViewController.delegate = self
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()
}
self.present(modal, animated: true)
}
@ -146,16 +135,6 @@ 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]

@ -81,9 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage ];
[self.delegate.fromViewController presentViewController:picker
animated:YES
completion:[UIUtil modalCompletionBlock]];
[self.delegate.fromViewController presentViewController:picker animated:YES completion:nil];
}];
}
@ -103,9 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage ];
[self.delegate.fromViewController presentViewController:picker
animated:YES
completion:[UIUtil modalCompletionBlock]];
[self.delegate.fromViewController presentViewController:picker animated:YES completion:nil];
}];
}
@ -144,10 +140,9 @@ NS_ASSUME_NONNULL_BEGIN
[self.delegate avatarDidChange:dstImage];
});
}];
[self.delegate.fromViewController
presentViewController:vc
animated:YES
completion:[UIUtil modalCompletionBlock]];
[self.delegate.fromViewController presentViewController:vc
animated:YES
completion:nil];
}
}];
}

@ -167,16 +167,6 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
action: #selector(didFinishEditingContact))
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()
}
fromViewController.present(modal, animated: true)
}
@ -197,7 +187,6 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
}
let viewController = AddContactShareToExistingContactViewController(contactShare: contactShare)
UIUtil.applySignalAppearence()
navigationController.pushViewController(viewController, animated: true)
}
@ -211,7 +200,6 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
return
}
UIUtil.applySignalAppearence()
delegate.didCreateOrEditContact()
}
@ -223,7 +211,6 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
return
}
UIUtil.applySignalAppearence()
delegate.didCreateOrEditContact()
}
}

@ -78,12 +78,6 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// 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")
return
@ -677,7 +671,6 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
Logger.info("\(logTag) \(#function)")
updateContent()
UIUtil.applySignalAppearence()
self.dismiss(animated: true)
}
}

@ -676,9 +676,6 @@ typedef enum : NSUInteger {
[super viewWillAppear:animated];
// In case we're dismissing a CNContactViewController, or DocumentPicker which requires default system appearance
[UIUtil applySignalAppearence];
// We need to recheck on every appearance, since the user may have left the group in the settings VC,
// or on another device.
[self hideInputIfNeeded];
@ -2781,10 +2778,6 @@ typedef enum : NSUInteger {
didPickDocumentPicker:(UIDocumentPickerViewController *)documentPicker
{
documentPicker.delegate = self;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 0)) {
// post iOS11, document picker has no blue header.
[UIUtil applyDefaultSystemAppearence];
}
[self dismissKeyBoard];
[self presentViewController:documentPicker animated:YES completion:nil];
@ -2796,16 +2789,6 @@ typedef enum : NSUInteger {
{
DDLogDebug(@"%@ Picked document at url: %@", self.logTag, url);
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 0)) {
// post iOS11, document picker has no blue header.
[UIUtil applySignalAppearence];
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 0)) {
// post iOS11, document picker has no blue header.
[UIUtil applySignalAppearence];
}
NSString *type;
NSError *typeError;
[url getResourceValue:&type forKey:NSURLTypeIdentifierKey error:&typeError];
@ -2896,7 +2879,7 @@ typedef enum : NSUInteger {
picker.delegate = self;
[self dismissKeyBoard];
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
[self presentViewController:picker animated:YES completion:nil];
}];
}
@ -2932,7 +2915,7 @@ typedef enum : NSUInteger {
picker.mediaTypes = @[ (__bridge NSString *)kUTTypeImage, (__bridge NSString *)kUTTypeMovie ];
[self dismissKeyBoard];
[self presentViewController:picker animated:YES completion:[UIUtil modalCompletionBlock]];
[self presentViewController:picker animated:YES completion:nil];
}];
}
@ -2942,7 +2925,6 @@ typedef enum : NSUInteger {
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[UIUtil modalCompletionBlock]();
[self dismissViewControllerAnimated:YES completion:nil];
}
@ -2959,7 +2941,6 @@ typedef enum : NSUInteger {
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary<NSString *, id> *)info
{
[UIUtil modalCompletionBlock]();
[self resetFrame];
NSURL *referenceURL = [info valueForKey:UIImagePickerControllerReferenceURL];

@ -189,14 +189,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
@objc
public func sendSMSTo(phoneNumbers: [String]) {
if #available(iOS 10.0, *) {
// iOS10 message compose view doesn't respect some system appearence attributes.
// Specifically, the title is white, but the navbar is gray.
// So, we have to set system appearence before init'ing the message compose view controller in order
// to make its colors legible.
// Then we have to be sure to set it back in the ComposeViewControllerDelegate callback.
UIUtil.applyDefaultSystemAppearence()
}
let messageComposeViewController = MFMessageComposeViewController()
messageComposeViewController.messageComposeDelegate = self
messageComposeViewController.recipients = phoneNumbers
@ -209,8 +201,6 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
// MARK: MessageComposeViewControllerDelegate
func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
// Revert system styling applied to make messaging app legible on iOS10.
UIUtil.applySignalAppearence()
self.presentingViewController.dismiss(animated: true) {
switch result {
case .failed:

@ -143,11 +143,6 @@ NS_ASSUME_NONNULL_BEGIN
[super viewDidLoad];
[self createContents];
// Even though bars are opaque, we want content to be layed out behind them.
// The bars might obscure part of the content, but they can easily be hidden by tapping
// The alternative would be that content would shift when the navbars hide.
self.extendedLayoutIncludesOpaqueBars = YES;
}
- (void)viewWillAppear:(BOOL)animated

@ -745,12 +745,10 @@ NS_ASSUME_NONNULL_BEGIN
if ([self presentedViewController]) {
[self dismissViewControllerAnimated:YES
completion:^{
[self presentViewController:alertController
animated:YES
completion:[UIUtil modalCompletionBlock]];
[self presentViewController:alertController animated:YES completion:nil];
}];
} else {
[self presentViewController:alertController animated:YES completion:[UIUtil modalCompletionBlock]];
[self presentViewController:alertController animated:YES completion:nil];
}
}

@ -485,7 +485,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
countryCodeController.countryCodeDelegate = self;
OWSNavigationController *navigationController =
[[OWSNavigationController alloc] initWithRootViewController:countryCodeController];
[self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];
[self presentViewController:navigationController animated:YES completion:nil];
}
- (void)backgroundTapped:(UIGestureRecognizer *)sender

@ -398,12 +398,6 @@ typedef void (^CustomLayoutBlock)(void);
[self.view setNeedsLayout];
}
- (void)viewWillAppear:(BOOL)animated
{
// In case we're returning from activity view that needed default system styles.
[UIUtil applySignalAppearence];
}
#pragma mark -
- (void)showSharingActivityWithCompletion:(nullable void (^)(void))completionHandler
@ -427,7 +421,6 @@ typedef void (^CustomLayoutBlock)(void);
if (completionHandler) {
completionHandler();
}
[UIUtil applySignalAppearence];
};
// This value was extracted by inspecting `activityType` in the activityController.completionHandler
@ -440,7 +433,6 @@ typedef void (^CustomLayoutBlock)(void);
iCloudActivityType // This isn't being excluded. RADAR https://openradar.appspot.com/27493621
];
[UIUtil applyDefaultSystemAppearence];
[self presentViewController:activityController animated:YES completion:nil];
}

@ -100,20 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
[cameraInstructionLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:instructionsVMargin];
}
- (void)viewWillAppear:(BOOL)animated
{
// In case we're returning from activity view that needed default system styles.
[UIUtil applySignalAppearence];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:YES];
}
#pragma mark - Action
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];

@ -180,9 +180,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// In case we're dismissing a CNContactViewController which requires default system appearance
[UIUtil applySignalAppearence];
}
#pragma mark - Actions

@ -852,9 +852,6 @@ NS_ASSUME_NONNULL_BEGIN
{
[super viewWillAppear:animated];
// In case we're dismissing a CNContactViewController which requires default system appearance
[UIUtil applySignalAppearence];
// HACK to unselect rows when swiping back
// http://stackoverflow.com/questions/19379510/uitableviewcell-doesnt-get-deselected-when-swiping-back-quickly
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:animated];

@ -105,14 +105,6 @@ NS_ASSUME_NONNULL_BEGIN
[self updateTableContents];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// In case we're dismissing a CNContactViewController which requires default system appearance
[UIUtil applySignalAppearence];
}
#pragma mark - Table Contents
- (void)updateTableContents

@ -136,11 +136,6 @@ NS_ASSUME_NONNULL_BEGIN
[[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft;
}
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle
{
[[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle];
}
- (void)setStatusBarHidden:(BOOL)isHidden animated:(BOOL)isAnimated
{
[[UIApplication sharedApplication] setStatusBarHidden:isHidden animated:isAnimated];

@ -68,10 +68,6 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<Contact *> *)nonSignalContactsMatchingSearchString:(NSString *)searchText;
/**
* NOTE: This method calls `[UIUtil applyDefaultSystemAppearence]`.
* When using this method, you must call `[UIUtil applySignalAppearence]` once contact editing is finished;
*/
- (void)presentContactViewControllerForRecipientId:(NSString *)recipientId
fromViewController:(UIViewController<ContactEditingDelegate> *)fromViewController
editImmediately:(BOOL)shouldEditImmediately;

@ -394,16 +394,6 @@ NS_ASSUME_NONNULL_BEGIN
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) {
modal.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

@ -74,9 +74,6 @@ NS_ASSUME_NONNULL_BEGIN
NSArray *__nullable returnedItems,
NSError *__nullable activityError) {
DDLogDebug(@"%@ applying signal appearence", self.logTag);
[UIUtil applySignalAppearence];
if (activityError) {
DDLogInfo(@"%@ Failed to share with activityError: %@", self.logTag, activityError);
} else if (completed) {
@ -93,12 +90,7 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController = fromViewController.presentedViewController;
}
OWSAssert(fromViewController);
[fromViewController presentViewController:activityViewController
animated:YES
completion:^{
DDLogDebug(@"%@ applying default system appearence", self.logTag);
[UIUtil applyDefaultSystemAppearence];
}];
[fromViewController presentViewController:activityViewController animated:YES completion:nil];
});
}

@ -270,7 +270,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
} else {
OWSNavigationController *navigationController =
[[OWSNavigationController alloc] initWithRootViewController:countryCodeController];
[self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];
[self presentViewController:navigationController animated:YES completion:nil];
}
}

@ -20,8 +20,6 @@ typedef void (^completionBlock)(void);
+ (void)applyRoundedBorderToImageView:(UIImageView *)imageView;
+ (void)removeRoundedBorderToImageView:(UIImageView *__strong *)imageView;
+ (completionBlock)modalCompletionBlock;
+ (void)applyDefaultSystemAppearence;
+ (void)applySignalAppearence;
+ (void)setupSignalAppearence;
@end

@ -24,31 +24,9 @@
[[*imageView layer] setCornerRadius:0];
}
+ (completionBlock)modalCompletionBlock
+ (void)setupSignalAppearence
{
completionBlock block = ^void() {
[CurrentAppContext() setStatusBarStyle:UIStatusBarStyleLightContent];
};
return block;
}
+ (void)applyDefaultSystemAppearence
{
// [CurrentAppContext() setStatusBarStyle:UIStatusBarStyleDefault];
// [[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
// [[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
// [[UIBarButtonItem appearance] setTintColor:[UIColor blackColor]];
// [[UINavigationBar appearance] setTitleTextAttributes:@{
// NSForegroundColorAttributeName : [UIColor blackColor],
// }];
}
+ (void)applySignalAppearence
{
// [CurrentAppContext() setStatusBarStyle:UIStatusBarStyleLightContent];
UINavigationBar.appearance.barTintColor = UIColor.ows_navbarBackgroundColor;
// [[UINavigationBar appearance] setBarTintColor:[UIColor ows_materialBlueColor]];
UINavigationBar.appearance.tintColor = UIColor.ows_navbarForegroundColor;
UIToolbar.appearance.barTintColor = UIColor.ows_navbarBackgroundColor;
UIToolbar.appearance.tintColor = UIColor.ows_navbarForegroundColor;

@ -130,11 +130,6 @@ NS_ASSUME_NONNULL_BEGIN
== NSLocaleLanguageDirectionRightToLeft;
}
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle
{
DDLogInfo(@"Ignoring request to set status bar style since we're in an app extension");
}
- (void)setStatusBarHidden:(BOOL)isHidden animated:(BOOL)isAnimated
{
DDLogInfo(@"Ignoring request to show/hide status bar style since we're in an app extension");

Loading…
Cancel
Save