diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 9059a8888..ad2ecdf66 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2836,7 +2836,9 @@ typedef enum : NSUInteger { OWSImagePickerGridController *picker = [OWSImagePickerGridController new]; picker.delegate = self; - pickerModal = [[OWSNavigationController alloc] initWithRootViewController:picker]; + OWSNavigationController *modal = [[OWSNavigationController alloc] initWithRootViewController:picker]; + modal.ows_prefersStatusBarHidden = @(YES); + pickerModal = modal; } else { UIImagePickerController *picker = [OWSImagePickerController new]; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index 10fc300cb..66e9a6973 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -169,6 +169,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC let vc = AttachmentApprovalViewController(mode: .modal, attachments: attachments) vc.approvalDelegate = approvalDelegate let navController = OWSNavigationController(rootViewController: vc) + navController.ows_prefersStatusBarHidden = true guard let navigationBar = navController.navigationBar as? OWSNavigationBar else { owsFailDebug("navigationBar was nil or unexpected class") @@ -198,6 +199,10 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC // MARK: - View Lifecycle + public override var prefersStatusBarHidden: Bool { + return true + } + override public func viewDidLoad() { super.viewDidLoad() @@ -229,8 +234,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC Logger.debug("") super.viewWillAppear(animated) - CurrentAppContext().setStatusBarHidden(true, animated: animated) - guard let navigationBar = navigationController?.navigationBar as? OWSNavigationBar else { owsFailDebug("navigationBar was nil or unexpected class") return @@ -251,10 +254,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC override public func viewWillDisappear(_ animated: Bool) { Logger.debug("") super.viewWillDisappear(animated) - - // Since this VC is being dismissed, the "show status bar" animation would feel like - // it's occuring on the presenting view controller - it's better not to animate at all. - CurrentAppContext().setStatusBarHidden(false, animated: false) } override public var inputAccessoryView: UIView? { diff --git a/SignalMessaging/ViewControllers/OWSNavigationController.h b/SignalMessaging/ViewControllers/OWSNavigationController.h index 533a5b4d0..3cc656c8a 100644 --- a/SignalMessaging/ViewControllers/OWSNavigationController.h +++ b/SignalMessaging/ViewControllers/OWSNavigationController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import @@ -23,6 +23,11 @@ NS_ASSUME_NONNULL_BEGIN // unsaved changes. @interface OWSNavigationController : UINavigationController +// If set, this property lets us override prefersStatusBarHidden behavior. +// This is useful for supressing the status bar while a modal is presented, +// regardless of which view is currently visible. +@property (nonatomic, nullable) NSNumber *ows_prefersStatusBarHidden; + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/ViewControllers/OWSNavigationController.m b/SignalMessaging/ViewControllers/OWSNavigationController.m index 64fa3604b..b2e40a3a5 100644 --- a/SignalMessaging/ViewControllers/OWSNavigationController.m +++ b/SignalMessaging/ViewControllers/OWSNavigationController.m @@ -69,6 +69,14 @@ NS_ASSUME_NONNULL_BEGIN self.interactivePopGestureRecognizer.delegate = self; } +- (BOOL)prefersStatusBarHidden +{ + if (self.ows_prefersStatusBarHidden) { + return self.ows_prefersStatusBarHidden.boolValue; + } + return [super prefersStatusBarHidden]; +} + #pragma mark - UINavigationBarDelegate - (void)setupNavbar