From b8d2a5a054dd540960f71a9f5ee2d5aaedc8ed99 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 22 Sep 2019 16:36:28 -0500 Subject: [PATCH] Make share extension container picker update the main ui --- .../ShareFolderPickerController.swift | 5 ++--- iOS/ShareExtension/ShareViewController.swift | 16 ++++++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/iOS/ShareExtension/ShareFolderPickerController.swift b/iOS/ShareExtension/ShareFolderPickerController.swift index abec0b370..d20b3e59d 100644 --- a/iOS/ShareExtension/ShareFolderPickerController.swift +++ b/iOS/ShareExtension/ShareFolderPickerController.swift @@ -10,7 +10,7 @@ import UIKit import Account protocol ShareFolderPickerControllerDelegate: class { - func shareFolderPickerDidSelect(_ container: Container) + func shareFolderPickerDidSelect(_ container: Container, _ selectionName: String) } class ShareFolderPickerController: UITableViewController { @@ -45,8 +45,7 @@ class ShareFolderPickerController: UITableViewController { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let pickerData = pickerData else { return } - delegate?.shareFolderPickerDidSelect(pickerData.containers[indexPath.row]) - navigationController?.popViewController(animated: true) + delegate?.shareFolderPickerDidSelect(pickerData.containers[indexPath.row], pickerData.containerNames[indexPath.row]) } } diff --git a/iOS/ShareExtension/ShareViewController.swift b/iOS/ShareExtension/ShareViewController.swift index f3b21e2ec..19d42cb4e 100644 --- a/iOS/ShareExtension/ShareViewController.swift +++ b/iOS/ShareExtension/ShareViewController.swift @@ -20,6 +20,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont private var url: URL? private var container: Container? + private var folderItem: SLComposeSheetConfigurationItem! override func viewDidLoad() { @@ -100,7 +101,6 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont } override func didSelectPost() { - var account: Account? if let containerAccount = container as? Account { account = containerAccount @@ -127,16 +127,12 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont } } - - - - // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments. - - // Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. } - func shareFolderPickerDidSelect(_ container: Container) { + func shareFolderPickerDidSelect(_ container: Container, _ selectionName: String) { self.container = container + self.folderItem.value = selectionName + self.popConfigurationViewController() } override func configurationItems() -> [Any]! { @@ -146,7 +142,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont urlItem.title = "URL" urlItem.value = url?.absoluteString ?? "" - guard let folderItem = SLComposeSheetConfigurationItem() else { return nil } + folderItem = SLComposeSheetConfigurationItem() folderItem.title = "Folder" if let nameProvider = container as? DisplayNameProvider { @@ -166,7 +162,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont } - return [folderItem, urlItem] + return [folderItem!, urlItem] }