Fix cant close qr if opened manually

This commit is contained in:
Leon Böttger committed 2025-03-16 15:18:14 +01:00
1 parent b5d1233778
commit 8ebebbda15
1 file changed
+16 -14
+16 -14
View File
@@ -151,26 +151,28 @@ class ShareViewController: NSViewController, ShareExtensionDelegate{
private func openQrCodeView() { private func openQrCodeView() {
let contentView = QrCodeView { if qrCodeSheetView != nil {
self.closeQrCodeView() let contentView = QrCodeView {
} self.closeQrCodeView()
}
let hostingView = NSHostingView(rootView: contentView) let hostingView = NSHostingView(rootView: contentView)
let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: qrCodeViewSize.width, height: qrCodeViewSize.height), let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: qrCodeViewSize.width, height: qrCodeViewSize.height),
styleMask: [.titled, .closable, .utilityWindow], styleMask: [.titled, .closable, .utilityWindow],
backing: .buffered, backing: .buffered,
defer: false) defer: false)
panel.title = "SwiftUI Sheet" panel.title = "SwiftUI Sheet"
panel.contentView = hostingView panel.contentView = hostingView
self.qrCodeSheetView = panel self.qrCodeSheetView = panel
if let mainWindow = NSApp.mainWindow { if let mainWindow = NSApp.mainWindow {
self.sheetAttachedWindow = mainWindow self.sheetAttachedWindow = mainWindow
mainWindow.beginSheet(panel) { _ in } mainWindow.beginSheet(panel) { _ in }
}
} }
} }