oficina / meet Public

Clone
git clone https://amadan.net/oficina/meet

Plain git — no account needed to clone.

Download

Download this file

1#if os(macOS)
2 import AppKit
3 import SwiftUI
4
5 @MainActor final class MacChatWindow: NSObject, ObservableObject, NSWindowDelegate {
6 @Published private(set) var isOpen = false
7 let draft = ChatDraft()
8 private var window: NSWindow?
9
10 func open(call: Call) {
11 if let window {
12 window.makeKeyAndOrderFront(nil)
13 return
14 }
15 let window = NSWindow(
16 contentRect: NSRect(x: 0, y: 0, width: 380, height: 520),
17 styleMask: [.titled, .closable, .miniaturizable, .resizable],
18 backing: .buffered, defer: false)
19 window.title = "Chat — \(call.title)"
20 window.minSize = NSSize(width: 300, height: 300)
21 window.isReleasedWhenClosed = false
22 window.contentView = NSHostingView(
23 rootView: ChatView(call: call, draft: draft)
24 .padding(20).tint(CallsAppearance.accent))
25 window.delegate = self
26 self.window = window
27 isOpen = true
28 window.center()
29 window.makeKeyAndOrderFront(nil)
30 }
31
32 func close() { window?.close() }
33
34 func windowWillClose(_ notification: Notification) {
35 window = nil
36 isOpen = false
37 }
38 }
39#endif
40