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

[feature/link-naming] Link naming #1297

Merged
merged 6 commits into from
Dec 1, 2023
Merged
Changes from 1 commit
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
42 changes: 41 additions & 1 deletion ownCloudAppShared/Client/Sharing/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe
public var share: OCShare?
public var item: OCItem?
public var location: OCLocation?
public var name: String?
public var type: ShareType
public var mode: Mode

Expand Down Expand Up @@ -99,6 +100,8 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe
var linksSectionDatasource: OCDataSourceArray?
var linksSection: CollectionViewSection?

var nameTextField : UITextField?

var customPermissionsSectionOptionGroup: OptionGroup?
var customPermissionsDatasource: OCDataSourceArray?
var customPermissionsSection: CollectionViewSection?
Expand Down Expand Up @@ -175,6 +178,31 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe
sections.append(linksSection)
}

// - Name
if self.type == .link {
let textField : UITextField = ThemeCSSTextField()
textField.translatesAutoresizingMaskIntoConstraints = false
textField.setContentHuggingPriority(.required, for: .vertical)
textField.setContentCompressionResistancePriority(.required, for: .horizontal)
textField.placeholder = "Link".localized
textField.text = share?.name
textField.accessibilityLabel = "Name".localized

nameTextField = textField

let spacerView = UIView()
spacerView.translatesAutoresizingMaskIntoConstraints = false
spacerView.embed(toFillWith: textField, insets: NSDirectionalEdgeInsets(top: 10, leading: 18, bottom: 10, trailing: 18))

let nameSectionDatasource = OCDataSourceArray(items: [spacerView])
let nameSection = CollectionViewSection(identifier: "name", dataSource: nameSectionDatasource, cellStyle: managementCellStyle, cellLayout: .list(appearance: .insetGrouped, contentInsets: .insetGroupedSectionInsets), clientContext: shareControllerContext)
nameSection.boundarySupplementaryItems = [
.mediumTitle("Name".localized)
]

sections.append(nameSection)
}

// - Roles & permissions
rolesSectionDatasource = OCDataSourceArray()

Expand Down Expand Up @@ -264,6 +292,14 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe

self.addStacked(child: bottomButtonBarViewController, position: .bottom)

// Wire up name textfield
self.name = share?.name
nameTextField?.addAction(UIAction(handler: { [weak self, weak nameTextField] _ in
if let nameTextField {
self?.name = nameTextField.text
}
}), for: .allEditingEvents)

// Set up view
if let share, let core = clientContext?.core {
role = core.matchingShareRole(for: share)
Expand Down Expand Up @@ -664,7 +700,7 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe

case .link:
if let location, let permissions {
newShare = OCShare(publicLinkTo: location, linkName: nil, permissions: permissions, password: nil, expiration: nil)
newShare = OCShare(publicLinkTo: location, linkName: name, permissions: permissions, password: nil, expiration: nil)
}
}

Expand Down Expand Up @@ -718,6 +754,10 @@ open class ShareViewController: CollectionViewController, SearchViewControllerDe
share.protectedByPassword = true
}

if self?.type == .link {
share.name = self?.name
}

share.expirationDate = self?.expirationDate
}, completionHandler: { error, share in
OnMainThread {
Expand Down
Loading