From e2af156cce5494a4d76cd8aeff5e154ce9f32ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Hu=CC=88hne?= Date: Tue, 11 Jul 2023 15:57:25 +0200 Subject: [PATCH 1/4] #5815 fixed overlapping sharing buttons --- ownCloudAppShared/Client/Sharing/ShareViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ownCloudAppShared/Client/Sharing/ShareViewController.swift b/ownCloudAppShared/Client/Sharing/ShareViewController.swift index 332cc7ee6..0d5a0bec9 100644 --- a/ownCloudAppShared/Client/Sharing/ShareViewController.swift +++ b/ownCloudAppShared/Client/Sharing/ShareViewController.swift @@ -268,7 +268,8 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe NSLayoutConstraint.activate([ deleteButton.leadingAnchor.constraint(equalTo: bottomButtonBar.leadingAnchor, constant: 20), - deleteButton.centerYAnchor.constraint(equalTo: bottomButtonBar.selectButton.centerYAnchor) + deleteButton.trailingAnchor.constraint(equalTo: bottomButtonBar.cancelButton.leadingAnchor, constant: -20), + deleteButton.centerYAnchor.constraint(equalTo: bottomButtonBar.cancelButton.centerYAnchor) ]) } From 1b7eebc656ed2aa14d9cc235650848a6851d4713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Hu=CC=88hne?= Date: Mon, 24 Jul 2023 10:20:02 +0200 Subject: [PATCH 2/4] moved unshare button to the navigation bar and removed the long navigation title, with the action title --- .../Client/Sharing/ShareViewController.swift | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/ownCloudAppShared/Client/Sharing/ShareViewController.swift b/ownCloudAppShared/Client/Sharing/ShareViewController.swift index 0d5a0bec9..dc40d28f6 100644 --- a/ownCloudAppShared/Client/Sharing/ShareViewController.swift +++ b/ownCloudAppShared/Client/Sharing/ShareViewController.swift @@ -220,25 +220,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,27 +245,22 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe bottomButtonBarViewController.view = bottomButtonBar // - Add delete button for existing shares - if mode == .edit, let bottomButtonBar { + if mode == .edit { 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.trailingAnchor.constraint(equalTo: bottomButtonBar.cancelButton.leadingAnchor, constant: -20), - deleteButton.centerYAnchor.constraint(equalTo: bottomButtonBar.cancelButton.centerYAnchor) - ]) + + let unshare = UIBarButtonItem(customView: deleteButton) + + self.navigationItem.rightBarButtonItem = unshare } self.addStacked(child: bottomButtonBarViewController, position: .bottom) From 22b66e5c324ad990b6b46c787e096a9e7b0f5a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Hu=CC=88hne?= Date: Mon, 24 Jul 2023 14:04:30 +0200 Subject: [PATCH 3/4] show item information on top of the ShareViewController --- .../OCShare+Interactions.swift | 5 +++-- .../Client/Sharing/ShareViewController.swift | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift b/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift index 79c7c808b..f4b338863 100644 --- a/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift +++ b/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift @@ -148,9 +148,10 @@ extension OCShare: DataItemSelectionInteraction { } } else { // Single share - editViewController = ShareViewController(mode: .edit, share: self, clientContext: context, completion: { _ in }) + let item: OCItem? = try? context.core?.cachedItem(at: itemLocation) + editViewController = ShareViewController(mode: .edit, share: self, item: item, 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 dc40d28f6..7f57c64fc 100644 --- a/ownCloudAppShared/Client/Sharing/ShareViewController.swift +++ b/ownCloudAppShared/Client/Sharing/ShareViewController.swift @@ -91,6 +91,9 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe var recipientSearchController: OCRecipientSearchController? var recipientsSectionDatasource: OCDataSourceComposition? var recipientsSection: CollectionViewSection? + + var itemSection: CollectionViewSection? + var itemSectionDatasource: OCDataSourceArray? var rolesSectionOptionGroup: OptionGroup? var rolesSectionDatasource: OCDataSourceArray? @@ -123,6 +126,19 @@ 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 + let itemSectionContext = ClientContext(with: clientContext, modifier: { context in + context.permissions = [] + }) + + if let item = item { + itemSectionDatasource = OCDataSourceArray(items: [item]) + 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) + if let section = itemSection { + sections.append(section) + } + } // Managament section cell style let managementCellStyle: CollectionViewCellStyle = .init(with: .tableCell) From 8379be9ae39eab45f78ab684b465f426a811ea5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Hu=CC=88hne?= Date: Thu, 3 Aug 2023 13:57:38 +0200 Subject: [PATCH 4/4] fixed CR findings --- .../OCShare+Interactions.swift | 3 +- .../Client/Sharing/ShareViewController.swift | 35 +++++-------------- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift b/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift index f4b338863..713edd1fe 100644 --- a/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift +++ b/ownCloudAppShared/Client/Data Item Interactions/OCShare+Interactions.swift @@ -148,8 +148,7 @@ extension OCShare: DataItemSelectionInteraction { } } else { // Single share - let item: OCItem? = try? context.core?.cachedItem(at: itemLocation) - editViewController = ShareViewController(mode: .edit, share: self, item: item, clientContext: context, completion: { _ in }) + editViewController = ShareViewController(mode: .edit, share: self, clientContext: context, completion: { _ in }) } if let editViewController { diff --git a/ownCloudAppShared/Client/Sharing/ShareViewController.swift b/ownCloudAppShared/Client/Sharing/ShareViewController.swift index 7f57c64fc..6232806b2 100644 --- a/ownCloudAppShared/Client/Sharing/ShareViewController.swift +++ b/ownCloudAppShared/Client/Sharing/ShareViewController.swift @@ -91,9 +91,6 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe var recipientSearchController: OCRecipientSearchController? var recipientsSectionDatasource: OCDataSourceComposition? var recipientsSection: CollectionViewSection? - - var itemSection: CollectionViewSection? - var itemSectionDatasource: OCDataSourceArray? var rolesSectionOptionGroup: OptionGroup? var rolesSectionDatasource: OCDataSourceArray? @@ -128,16 +125,13 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe self.completionHandler = completion // Item section - let itemSectionContext = ClientContext(with: clientContext, modifier: { context in - context.permissions = [] - }) - if let item = item { - itemSectionDatasource = OCDataSourceArray(items: [item]) - 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) - if let section = itemSection { - sections.append(section) - } + 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 @@ -262,19 +256,8 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe // - Add delete button for existing shares if mode == .edit { - var deleteButtonConfig = UIButton.Configuration.borderedProminent() - deleteButtonConfig.title = "Unshare".localized - deleteButtonConfig.cornerStyle = .large - deleteButtonConfig.baseBackgroundColor = .systemRed - deleteButtonConfig.baseForegroundColor = .white - - let deleteButton = UIButton() - deleteButton.configuration = deleteButtonConfig - deleteButton.addAction(UIAction(handler: { [weak self] action in - self?.deleteShare() - }), for: .primaryActionTriggered) - - let unshare = UIBarButtonItem(customView: deleteButton) + let unshare = UIBarButtonItem(title: "Unshare".localized, style: .plain, target: self, action: #selector(deleteShare)) + unshare.tintColor = .red self.navigationItem.rightBarButtonItem = unshare } @@ -755,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