mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
1e34affc01
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
53 lines
1.7 KiB
Swift
53 lines
1.7 KiB
Swift
//
|
|
// DocumentActionViewController.swift
|
|
// FileProviderUIExt
|
|
//
|
|
// Created by Claudio Cambra on 20/2/24.
|
|
//
|
|
|
|
import FileProviderUI
|
|
import OSLog
|
|
|
|
class DocumentActionViewController: FPUIActionExtensionViewController {
|
|
var domain: NSFileProviderDomain {
|
|
guard let identifier = extensionContext.domainIdentifier else {
|
|
fatalError("not expected to be called with default domain")
|
|
}
|
|
return NSFileProviderDomain(
|
|
identifier: NSFileProviderDomainIdentifier(rawValue: identifier.rawValue),
|
|
displayName: ""
|
|
)
|
|
}
|
|
|
|
func prepare(childViewController: NSViewController) {
|
|
addChild(childViewController)
|
|
view.addSubview(childViewController.view)
|
|
|
|
NSLayoutConstraint.activate([
|
|
view.leadingAnchor.constraint(equalTo: childViewController.view.leadingAnchor),
|
|
view.trailingAnchor.constraint(equalTo: childViewController.view.trailingAnchor),
|
|
view.topAnchor.constraint(equalTo: childViewController.view.topAnchor),
|
|
view.bottomAnchor.constraint(equalTo: childViewController.view.bottomAnchor)
|
|
])
|
|
}
|
|
|
|
override func prepare(
|
|
forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]
|
|
) {
|
|
Logger.actionViewController.info("Preparing for action: \(actionIdentifier)")
|
|
|
|
if actionIdentifier == "com.nextcloud.desktopclient.FileProviderUIExt.ShareAction" {
|
|
prepare(childViewController: ShareViewController(itemIdentifiers))
|
|
}
|
|
|
|
}
|
|
|
|
override func prepare(forError error: Error) {
|
|
Logger.actionViewController.info("Preparing for error: \(error.localizedDescription)")
|
|
}
|
|
|
|
override public func loadView() {
|
|
self.view = NSView()
|
|
}
|
|
}
|
|
|