Modal conversation picker, hide loading screen when possible

The first usable screen in the conversation picker, that's the first
thing we want to show the user, and the modal presentation feels like
the right way to introduce this new context.

Long load times should be the exception, not the normal flow, so we
delay it's presentation in hopes that it will generally never be seen.

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 6bb9b9cbc6
commit 3bb772f135

@ -20,6 +20,12 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
Logger.debug("\(self.logTag) \(#function)") Logger.debug("\(self.logTag) \(#function)")
// We can't show the conversation picker until the DB is set up.
// Normally this will only take a moment, so rather than flickering and then hiding the loading screen
// We start with as invisible, and only fade it in if it's going to take a while
self.view.isHidden = true
self.view.alpha = 0
// This should be the first thing we do. // This should be the first thing we do.
let appContext = ShareAppExtensionContext(rootViewController:self) let appContext = ShareAppExtensionContext(rootViewController:self)
SetCurrentAppContext(appContext) SetCurrentAppContext(appContext)
@ -78,7 +84,7 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
let loadViewController = SAELoadViewController(delegate:self) let loadViewController = SAELoadViewController(delegate:self)
self.pushViewController(loadViewController, animated: false) self.pushViewController(loadViewController, animated: false)
self.isNavigationBarHidden = false self.isNavigationBarHidden = true
// We don't need to use "screen protection" in the SAE. // We don't need to use "screen protection" in the SAE.
@ -225,7 +231,7 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
Logger.info("Presenting initial root view controller") Logger.info("Presenting initial root view controller")
if TSAccountManager.isRegistered() { if TSAccountManager.isRegistered() {
showConversationPicker() presentConversationPicker()
} else { } else {
showNotRegisteredView() showNotRegisteredView()
} }
@ -278,7 +284,6 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
private func showErrorView(title: String, message: String) { private func showErrorView(title: String, message: String) {
let viewController = SAEFailedViewController(delegate:self, title:title, message:message) let viewController = SAEFailedViewController(delegate:self, title:title, message:message)
self.setViewControllers([viewController], animated: false) self.setViewControllers([viewController], animated: false)
self.isNavigationBarHidden = false
} }
// MARK: View Lifecycle // MARK: View Lifecycle
@ -303,6 +308,14 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
Logger.debug("\(self.logTag) \(#function)") Logger.debug("\(self.logTag) \(#function)")
super.viewDidAppear(animated) super.viewDidAppear(animated)
// We can't show the conversation picker until the DB is set up.
// Normally this will only take a moment, so rather than flickering and then hiding the loading screen
// We start with as invisible, and only fade it in if it's going to take a while
self.view.isHidden = false
UIView.animate(withDuration: 0.1, delay: 0.5, options: [.curveEaseInOut], animations: {
self.view.alpha = 1
}, completion: nil)
} }
override open func viewWillDisappear(_ animated: Bool) { override open func viewWillDisappear(_ animated: Bool) {
@ -329,11 +342,13 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
// MARK: Helpers // MARK: Helpers
private func showConversationPicker() { private func presentConversationPicker() {
let conversationPicker = SendExternalFileViewController() self.buildAttachment().then { attachment -> Void in
buildAttachment().then { attachment -> Void in let conversationPicker = SendExternalFileViewController()
let navigationController = UINavigationController(rootViewController: conversationPicker)
navigationController.isNavigationBarHidden = true
conversationPicker.attachment = attachment conversationPicker.attachment = attachment
self.setViewControllers([conversationPicker], animated: true) self.present(navigationController, animated: true, completion: nil)
Logger.info("showing picker with attachment: \(attachment)") Logger.info("showing picker with attachment: \(attachment)")
}.catch { error in }.catch { error in
let alertTitle = NSLocalizedString("SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE", comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details.") let alertTitle = NSLocalizedString("SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE", comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details.")

Loading…
Cancel
Save