mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Create ShareViewController
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
f44fec2ff1
commit
76045fd989
5 changed files with 103 additions and 23 deletions
|
@ -9,24 +9,30 @@ import FileProviderUI
|
|||
import OSLog
|
||||
|
||||
class DocumentActionViewController: FPUIActionExtensionViewController {
|
||||
|
||||
@IBOutlet weak var identifierLabel: NSTextField!
|
||||
@IBOutlet weak var actionTypeLabel: NSTextField!
|
||||
override func prepare(
|
||||
forAction actionIdentifier: String, itemIdentifiers: [NSFileProviderItemIdentifier]
|
||||
) {
|
||||
Logger.actionViewController.info("Preparing for action: \(actionIdentifier)")
|
||||
let shareViewController = ShareViewController()
|
||||
addChild(shareViewController)
|
||||
view.addSubview(shareViewController.view)
|
||||
|
||||
identifierLabel?.stringValue = actionIdentifier
|
||||
actionTypeLabel?.stringValue = "Custom action"
|
||||
NSLayoutConstraint.activate([
|
||||
view.leadingAnchor.constraint(equalTo: shareViewController.view.leadingAnchor),
|
||||
view.trailingAnchor.constraint(equalTo: shareViewController.view.trailingAnchor),
|
||||
view.topAnchor.constraint(equalTo: shareViewController.view.topAnchor),
|
||||
view.bottomAnchor.constraint(equalTo: shareViewController.view.bottomAnchor)
|
||||
])
|
||||
}
|
||||
|
||||
override func prepare(forError error: Error) {
|
||||
identifierLabel?.stringValue = error.localizedDescription
|
||||
actionTypeLabel?.stringValue = "Authenticate"
|
||||
Logger.actionViewController.info("Preparing for error: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
override public func loadView() {
|
||||
self.view = NSView()
|
||||
}
|
||||
|
||||
@IBAction func doneButtonTapped(_ sender: Any) {
|
||||
// Perform the action and call the completion block. If an unrecoverable error occurs you must still call the completion block with an error. Use the error code FPUIExtensionErrorCode.failed to signal the failure.
|
||||
extensionContext.completeRequest()
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner"/>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
</objects>
|
||||
</document>
|
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// ShareViewController.swift
|
||||
// FileProviderUIExt
|
||||
//
|
||||
// Created by Claudio Cambra on 21/2/24.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
class ShareViewController: NSViewController {
|
||||
@IBOutlet weak var identifierLabel: NSTextField!
|
||||
@IBOutlet weak var actionTypeLabel: NSTextField!
|
||||
|
||||
public override var nibName: NSNib.Name? {
|
||||
return NSNib.Name(self.className)
|
||||
}
|
||||
|
||||
var actionViewController: DocumentActionViewController! {
|
||||
return parent as? DocumentActionViewController
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ShareViewController" customModule="FileProviderUIExt" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="actionTypeLabel" destination="slV-H6-zJ3" id="1JN-bb-FG4"/>
|
||||
<outlet property="identifierLabel" destination="gX0-nE-MrU" id="Ltd-Ad-QXu"/>
|
||||
<outlet property="view" destination="Jw6-da-U8j" id="5Ek-F1-w7C"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<view misplaced="YES" id="Jw6-da-U8j">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="40"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9kj-aB-aJh">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="40"/>
|
||||
<subviews>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="slV-H6-zJ3">
|
||||
<rect key="frame" x="-2" y="24" width="37" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="Uuo-1j-to8">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gX0-nE-MrU">
|
||||
<rect key="frame" x="-2" y="0.0" width="37" height="16"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="1GC-Gr-x29">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<visibilityPriorities>
|
||||
<integer value="1000"/>
|
||||
<integer value="1000"/>
|
||||
</visibilityPriorities>
|
||||
<customSpacing>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
<real value="3.4028234663852886e+38"/>
|
||||
</customSpacing>
|
||||
</stackView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="9kj-aB-aJh" secondAttribute="trailing" id="Oyj-Ql-C3b"/>
|
||||
<constraint firstItem="9kj-aB-aJh" firstAttribute="leading" secondItem="Jw6-da-U8j" secondAttribute="leading" id="ThU-hb-3bS"/>
|
||||
<constraint firstItem="9kj-aB-aJh" firstAttribute="top" secondItem="Jw6-da-U8j" secondAttribute="top" id="dEr-yV-R3d"/>
|
||||
<constraint firstAttribute="bottom" secondItem="9kj-aB-aJh" secondAttribute="bottom" id="fEe-1A-sur"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-319" y="262"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
|
@ -24,6 +24,8 @@
|
|||
536EFBF7295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFBF6295CF58100F4CB13 /* FileProviderSocketLineProcessor.swift */; };
|
||||
536EFC36295E3C1100F4CB13 /* NextcloudAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */; };
|
||||
5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */; };
|
||||
537630912B85F4980026BFAB /* ShareViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 537630902B85F4980026BFAB /* ShareViewController.xib */; };
|
||||
537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537630922B85F4B00026BFAB /* ShareViewController.swift */; };
|
||||
538E396A27F4765000FA63D5 /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */; };
|
||||
538E396D27F4765000FA63D5 /* FileProviderExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396C27F4765000FA63D5 /* FileProviderExtension.swift */; };
|
||||
538E396F27F4765000FA63D5 /* FileProviderItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 538E396E27F4765000FA63D5 /* FileProviderItem.swift */; };
|
||||
|
@ -41,7 +43,6 @@
|
|||
53903D37295618A400D0B308 /* LineProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 53903D36295618A400D0B308 /* LineProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
539158AC27BE71A900816F56 /* FinderSyncSocketLineProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 539158AB27BE71A900816F56 /* FinderSyncSocketLineProcessor.m */; };
|
||||
53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B979802B84C81F002DA742 /* DocumentActionViewController.swift */; };
|
||||
53B9798A2B84CB0F002DA742 /* MainInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53B979892B84CB0F002DA742 /* MainInterface.xib */; };
|
||||
53D056312970594F00988392 /* LocalFilesUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D056302970594F00988392 /* LocalFilesUtils.swift */; };
|
||||
53D666612B70C9A70042C03D /* FileProviderConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D666602B70C9A70042C03D /* FileProviderConfig.swift */; };
|
||||
53ED472029C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */; };
|
||||
|
@ -162,6 +163,8 @@
|
|||
536EFC35295E3C1100F4CB13 /* NextcloudAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextcloudAccount.swift; sourceTree = "<group>"; };
|
||||
5376307C2B85E2ED0026BFAB /* Logger+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Logger+Extensions.swift"; sourceTree = "<group>"; };
|
||||
5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = FileProviderUIExt.entitlements; sourceTree = "<group>"; };
|
||||
537630902B85F4980026BFAB /* ShareViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareViewController.xib; sourceTree = "<group>"; };
|
||||
537630922B85F4B00026BFAB /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
|
||||
538E396727F4765000FA63D5 /* FileProviderExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderExt.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
538E396927F4765000FA63D5 /* UniformTypeIdentifiers.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniformTypeIdentifiers.framework; path = System/Library/Frameworks/UniformTypeIdentifiers.framework; sourceTree = SDKROOT; };
|
||||
538E396C27F4765000FA63D5 /* FileProviderExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderExtension.swift; sourceTree = "<group>"; };
|
||||
|
@ -180,7 +183,6 @@
|
|||
53B9797E2B84C81F002DA742 /* FileProviderUIExt.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = FileProviderUIExt.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
53B979802B84C81F002DA742 /* DocumentActionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentActionViewController.swift; sourceTree = "<group>"; };
|
||||
53B979852B84C81F002DA742 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
53B979892B84CB0F002DA742 /* MainInterface.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainInterface.xib; sourceTree = "<group>"; };
|
||||
53D056302970594F00988392 /* LocalFilesUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalFilesUtils.swift; sourceTree = "<group>"; };
|
||||
53D666602B70C9A70042C03D /* FileProviderConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderConfig.swift; sourceTree = "<group>"; };
|
||||
53ED471F29C5E64200795DB1 /* FileProviderEnumerator+SyncEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FileProviderEnumerator+SyncEngine.swift"; sourceTree = "<group>"; };
|
||||
|
@ -333,9 +335,10 @@
|
|||
53B9797F2B84C81F002DA742 /* FileProviderUIExt */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
53B979892B84CB0F002DA742 /* MainInterface.xib */,
|
||||
5376307B2B85E2E00026BFAB /* Extensions */,
|
||||
53B979802B84C81F002DA742 /* DocumentActionViewController.swift */,
|
||||
537630922B85F4B00026BFAB /* ShareViewController.swift */,
|
||||
537630902B85F4980026BFAB /* ShareViewController.xib */,
|
||||
5376307E2B85E5650026BFAB /* FileProviderUIExt.entitlements */,
|
||||
53B979852B84C81F002DA742 /* Info.plist */,
|
||||
);
|
||||
|
@ -613,7 +616,7 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
53B9798A2B84CB0F002DA742 /* MainInterface.xib in Resources */,
|
||||
537630912B85F4980026BFAB /* ShareViewController.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -697,6 +700,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
537630932B85F4B00026BFAB /* ShareViewController.swift in Sources */,
|
||||
53B979812B84C81F002DA742 /* DocumentActionViewController.swift in Sources */,
|
||||
5376307D2B85E2ED0026BFAB /* Logger+Extensions.swift in Sources */,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue