mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Fix cant close qr if opened manually
This commit is contained in:
1 parent
b5d1233778
commit
8ebebbda15
1 file changed
+21
-19
@@ -151,26 +151,28 @@ class ShareViewController: NSViewController, ShareExtensionDelegate{
|
||||
|
||||
|
||||
private func openQrCodeView() {
|
||||
let contentView = QrCodeView {
|
||||
self.closeQrCodeView()
|
||||
}
|
||||
|
||||
let hostingView = NSHostingView(rootView: contentView)
|
||||
|
||||
let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: qrCodeViewSize.width, height: qrCodeViewSize.height),
|
||||
styleMask: [.titled, .closable, .utilityWindow],
|
||||
backing: .buffered,
|
||||
defer: false)
|
||||
|
||||
panel.title = "SwiftUI Sheet"
|
||||
panel.contentView = hostingView
|
||||
|
||||
self.qrCodeSheetView = panel
|
||||
|
||||
if let mainWindow = NSApp.mainWindow {
|
||||
if qrCodeSheetView != nil {
|
||||
let contentView = QrCodeView {
|
||||
self.closeQrCodeView()
|
||||
}
|
||||
|
||||
self.sheetAttachedWindow = mainWindow
|
||||
mainWindow.beginSheet(panel) { _ in }
|
||||
let hostingView = NSHostingView(rootView: contentView)
|
||||
|
||||
let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: qrCodeViewSize.width, height: qrCodeViewSize.height),
|
||||
styleMask: [.titled, .closable, .utilityWindow],
|
||||
backing: .buffered,
|
||||
defer: false)
|
||||
|
||||
panel.title = "SwiftUI Sheet"
|
||||
panel.contentView = hostingView
|
||||
|
||||
self.qrCodeSheetView = panel
|
||||
|
||||
if let mainWindow = NSApp.mainWindow {
|
||||
|
||||
self.sheetAttachedWindow = mainWindow
|
||||
mainWindow.beginSheet(panel) { _ in }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user