Make share extension container picker update the main ui
This commit is contained in:
parent
26031f7a4d
commit
b8d2a5a054
|
@ -10,7 +10,7 @@ import UIKit
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
protocol ShareFolderPickerControllerDelegate: class {
|
protocol ShareFolderPickerControllerDelegate: class {
|
||||||
func shareFolderPickerDidSelect(_ container: Container)
|
func shareFolderPickerDidSelect(_ container: Container, _ selectionName: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShareFolderPickerController: UITableViewController {
|
class ShareFolderPickerController: UITableViewController {
|
||||||
|
@ -45,8 +45,7 @@ class ShareFolderPickerController: UITableViewController {
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
guard let pickerData = pickerData else { return }
|
guard let pickerData = pickerData else { return }
|
||||||
delegate?.shareFolderPickerDidSelect(pickerData.containers[indexPath.row])
|
delegate?.shareFolderPickerDidSelect(pickerData.containers[indexPath.row], pickerData.containerNames[indexPath.row])
|
||||||
navigationController?.popViewController(animated: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
|
||||||
|
|
||||||
private var url: URL?
|
private var url: URL?
|
||||||
private var container: Container?
|
private var container: Container?
|
||||||
|
private var folderItem: SLComposeSheetConfigurationItem!
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
|
||||||
|
@ -100,7 +101,6 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didSelectPost() {
|
override func didSelectPost() {
|
||||||
|
|
||||||
var account: Account?
|
var account: Account?
|
||||||
if let containerAccount = container as? Account {
|
if let containerAccount = container as? Account {
|
||||||
account = containerAccount
|
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.container = container
|
||||||
|
self.folderItem.value = selectionName
|
||||||
|
self.popConfigurationViewController()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func configurationItems() -> [Any]! {
|
override func configurationItems() -> [Any]! {
|
||||||
|
@ -146,7 +142,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
|
||||||
urlItem.title = "URL"
|
urlItem.title = "URL"
|
||||||
urlItem.value = url?.absoluteString ?? ""
|
urlItem.value = url?.absoluteString ?? ""
|
||||||
|
|
||||||
guard let folderItem = SLComposeSheetConfigurationItem() else { return nil }
|
folderItem = SLComposeSheetConfigurationItem()
|
||||||
folderItem.title = "Folder"
|
folderItem.title = "Folder"
|
||||||
|
|
||||||
if let nameProvider = container as? DisplayNameProvider {
|
if let nameProvider = container as? DisplayNameProvider {
|
||||||
|
@ -166,7 +162,7 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [folderItem, urlItem]
|
return [folderItem!, urlItem]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue