Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix/overlapping-sharing-buttons] Overlapping Sharing Buttons #1248

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
60 changes: 25 additions & 35 deletions ownCloudAppShared/Client/Sharing/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
felix-schwarz marked this conversation as resolved.
Show resolved Hide resolved
}

self.addStacked(child: bottomButtonBarViewController, position: .bottom)
Expand Down Expand Up @@ -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
Expand Down