feat(workspace): 桌面工作区、主题与交互更新,发布 0.1.2
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
This commit was merged in pull request #13.
This commit is contained in:
1 parent
aa5255d1e4
commit
abc1868550
260 files changed
+43964
-5591
No files matched your search
+8
@@ -5,12 +5,14 @@ public final class CutdexNativePlugin: NSObject, FlutterPlugin {
|
||||
private let view: NSView
|
||||
private let messenger: FlutterBinaryMessenger
|
||||
private let menu: NativeContextMenuBridge
|
||||
private let filePicker: NativeFilePickerBridge
|
||||
private var drops: [String: NativeFileDropView] = [:]
|
||||
|
||||
private init(view: NSView, messenger: FlutterBinaryMessenger) {
|
||||
self.view = view
|
||||
self.messenger = messenger
|
||||
menu = NativeContextMenuBridge(view: view, messenger: messenger)
|
||||
filePicker = NativeFilePickerBridge(view: view)
|
||||
super.init()
|
||||
(view.window as? CutdexNativeWindow)?.configureNative(messenger: messenger)
|
||||
}
|
||||
@@ -23,9 +25,15 @@ public final class CutdexNativePlugin: NSObject, FlutterPlugin {
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
registrar.addMethodCallDelegate(instance, channel: FlutterMethodChannel(
|
||||
name: "cutdex_native/device_info", binaryMessenger: registrar.messenger))
|
||||
registrar.addMethodCallDelegate(instance, channel: FlutterMethodChannel(
|
||||
name: "cutdex_native/file_picker", binaryMessenger: registrar.messenger))
|
||||
}
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
if call.method == "pickFiles" {
|
||||
filePicker.pickFiles(arguments: call.arguments, result: result)
|
||||
return
|
||||
}
|
||||
if call.method == "getApplicationInfo" {
|
||||
result(["appVersion": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "unknown",
|
||||
"appBuild": Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "unknown"])
|
||||
|
||||
+2
-1
@@ -304,7 +304,8 @@ open class CutdexNativeWindow: NSWindow {
|
||||
target.mouseDown(with: event)
|
||||
return
|
||||
}
|
||||
if top >= 0, top < headerHeight, point.x >= 88 {
|
||||
// Matches the Flutter reservation for the native button group (x=0...68).
|
||||
if top >= 0, top < headerHeight, point.x >= 68 {
|
||||
if event.clickCount == 2 {
|
||||
switch UserDefaults.standard.string(forKey: "AppleActionOnDoubleClick") {
|
||||
case "Minimize": miniaturize(nil)
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
import Cocoa
|
||||
import FlutterMacOS
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
final class NativeFilePickerBridge {
|
||||
private weak var view: NSView?
|
||||
private var activePanel: NSOpenPanel?
|
||||
private let makePanel: () -> NSOpenPanel
|
||||
|
||||
init(view: NSView, makePanel: @escaping () -> NSOpenPanel = { NSOpenPanel() }) {
|
||||
self.view = view
|
||||
self.makePanel = makePanel
|
||||
}
|
||||
|
||||
func pickFiles(arguments: Any?, result: @escaping FlutterResult) {
|
||||
DispatchQueue.main.async { [self] in
|
||||
guard activePanel == nil else {
|
||||
return result(FlutterError(code: "picker_active",
|
||||
message: "A file selection is already open.", details: nil))
|
||||
}
|
||||
guard let window = view?.window else {
|
||||
return result(FlutterError(code: "window_unavailable",
|
||||
message: "The file picker requires a host window.", details: nil))
|
||||
}
|
||||
guard window.attachedSheet == nil else {
|
||||
return result(FlutterError(code: "picker_active",
|
||||
message: "The host window already has an open sheet.", details: nil))
|
||||
}
|
||||
guard let args = arguments as? [String: Any],
|
||||
let extensions = args["allowedExtensions"] as? [String] else {
|
||||
return result(FlutterError(code: "invalid_args",
|
||||
message: "File extensions are required.", details: nil))
|
||||
}
|
||||
let panel = makePanel()
|
||||
panel.canChooseFiles = true
|
||||
panel.canChooseDirectories = false
|
||||
panel.allowsMultipleSelection = true
|
||||
panel.canCreateDirectories = false
|
||||
let types = extensions.compactMap { UTType(filenameExtension: $0) }
|
||||
if !types.isEmpty {
|
||||
panel.allowedContentTypes = types
|
||||
panel.allowsOtherFileTypes = false
|
||||
}
|
||||
activePanel = panel
|
||||
// An owned, asynchronous sheet stays with the editor, including fullscreen,
|
||||
// without entering runModal's nested application event loop.
|
||||
panel.beginSheetModal(for: window) { [self, panel] response in
|
||||
DispatchQueue.main.async { [self, panel] in
|
||||
activePanel = nil
|
||||
result(response == .OK ? panel.urls.map { $0.path } : nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user