diff --git a/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift b/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift index 79c7c808b..713edd1fe 100644 --- a/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift +++ b/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift @@ -150,7 +150,7 @@ extension OCShare: DataItemSelectionInteraction { // Single share editViewController = ShareViewController(mode: .edit, share: self, clientContext: context, completion: { _ in }) } - + if let editViewController { let navigationController = ThemeNavigationController(rootViewController: editViewController) context.present(navigationController, animated: true) diff --git a/ownCloudAppShared/Client/Sharing/ShareViewController.swift b/ownCloudAppShared/Client/Sharing/ShareViewController.swift index 8830bee0a..18bc74f1d 100644 --- a/ownCloudAppShared/Client/Sharing/ShareViewController.swift +++ b/ownCloudAppShared/Client/Sharing/ShareViewController.swift @@ -123,6 +123,16 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe self.item = (item != nil) ? item! : ((location != nil) ? try? clientContext.core?.cachedItem(at: location!) : nil) self.mode = mode self.completionHandler = completion + + // Item section + if let item = item { + let itemSectionContext = ClientContext(with: clientContext, modifier: { context in + context.permissions = [] + }) + var itemSectionDatasource = OCDataSourceArray(items: [item]) + var itemSection = CollectionViewSection(identifier: "item", dataSource: itemSectionDatasource, cellStyle: .init(with: .header), cellLayout: .list(appearance: .plain, contentInsets: NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)), clientContext: itemSectionContext) + sections.append(itemSection) + } // Managament section cell style let managementCellStyle: CollectionViewCellStyle = .init(with: .tableCell) @@ -220,25 +230,20 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe collectionView.contentInset = extraContentInset // Set navigation bar title - let itemDisplayName = location?.displayName(in: clientContext) var navigationTitle: String? - - if let itemDisplayName { - navigationTitle = "Share {{itemName}}".localized([ "itemName" : itemDisplayName ]) - } else { - switch mode { - case .create: - navigationTitle = "Share".localized - - case .edit: - navigationTitle = "Edit".localized - } + + switch mode { + case .create: + navigationTitle = (type == .link) ? "Create link".localized : "Invite".localized + + case .edit: + navigationTitle = "Edit".localized } navigationItem.titleLabelText = navigationTitle - + // Add bottom button bar let title = (mode == .create) ? ((type == .link) ? "Create link".localized : "Invite".localized) : "Save changes".localized - + bottomButtonBar = BottomButtonBar(selectButtonTitle: title, cancelButtonTitle: "Cancel".localized, hasCancelButton: true, selectAction: UIAction(handler: { [weak self] _ in self?.save() }), cancelAction: UIAction(handler: { [weak self] _ in @@ -250,26 +255,11 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe bottomButtonBarViewController.view = bottomButtonBar // - Add delete button for existing shares - if mode == .edit, let bottomButtonBar { - var deleteButtonConfig = UIButton.Configuration.borderedProminent() - deleteButtonConfig.title = "Unshare".localized - deleteButtonConfig.cornerStyle = .large - deleteButtonConfig.baseBackgroundColor = .systemRed - deleteButtonConfig.baseForegroundColor = .white - - let deleteButton = UIButton() - deleteButton.translatesAutoresizingMaskIntoConstraints = false - deleteButton.configuration = deleteButtonConfig - deleteButton.addAction(UIAction(handler: { [weak self] action in - self?.deleteShare() - }), for: .primaryActionTriggered) - - bottomButtonBar.addSubview(deleteButton) - - NSLayoutConstraint.activate([ - deleteButton.leadingAnchor.constraint(equalTo: bottomButtonBar.leadingAnchor, constant: 20), - deleteButton.centerYAnchor.constraint(equalTo: bottomButtonBar.selectButton.centerYAnchor) - ]) + if mode == .edit { + let unshare = UIBarButtonItem(title: "Unshare".localized, style: .plain, target: self, action: #selector(deleteShare)) + unshare.tintColor = .red + + self.navigationItem.rightBarButtonItem = unshare } self.addStacked(child: bottomButtonBarViewController, position: .bottom) @@ -748,7 +738,7 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe } } - func deleteShare() { + @objc func deleteShare() { guard let core = clientContext?.core, let share else { self.showError(NSError(ocError: .internal)) return