From fea4e8855e72847e8ced644215014783273edbad Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 4 Mar 2024 20:42:52 +0800 Subject: [PATCH] Use ShareController in ShareOptionsView Signed-off-by: Claudio Cambra --- .../FileProviderUIExt/ShareOptionsView.swift | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift index ca197bb30..d0f75a13c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/ShareOptionsView.swift @@ -21,19 +21,42 @@ class ShareOptionsView: NSView { @IBOutlet private weak var saveButton: NSButton! @IBOutlet private weak var deleteButton: NSButton! - var share: NKShare? { + var controller: ShareController? { didSet { - guard let share = share else { return } - labelTextField.stringValue = share.label - uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off - hideDownloadCheckbox.state = share.hideDownload ? .on : .off - passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on - passwordSecureField.isHidden = passwordProtectCheckbox.state == .off - expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on - expirationDatePicker.isHidden = expirationDateCheckbox.state == .off - noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on - noteTextField.isHidden = noteForRecipientCheckbox.state == .off - deleteButton.isEnabled = share.canDelete + update() + + } + } + + private func update() { + guard let share = controller?.share else { + reset() + saveButton.isEnabled = false + deleteButton.isEnabled = false + return } + labelTextField.stringValue = share.label + uploadEditPermissionCheckbox.state = share.canEdit ? .on : .off + hideDownloadCheckbox.state = share.hideDownload ? .on : .off + passwordProtectCheckbox.state = share.password.isEmpty ? .off : .on + passwordSecureField.isHidden = passwordProtectCheckbox.state == .off + expirationDateCheckbox.state = share.expirationDate == nil ? .off : .on + expirationDatePicker.isHidden = expirationDateCheckbox.state == .off + noteForRecipientCheckbox.state = share.note.isEmpty ? .off : .on + noteTextField.isHidden = noteForRecipientCheckbox.state == .off + deleteButton.isEnabled = share.canDelete + saveButton.isEnabled = true + } + + func reset() { + labelTextField.stringValue = "" + uploadEditPermissionCheckbox.state = .off + hideDownloadCheckbox.state = .off + passwordProtectCheckbox.state = .off + passwordSecureField.isHidden = true + expirationDateCheckbox.state = .off + expirationDatePicker.isHidden = true + noteForRecipientCheckbox.state = .off + noteTextField.isHidden = true } } -- 2.30.2