forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatWindowView.swift
More file actions
47 lines (41 loc) · 1.44 KB
/
ChatWindowView.swift
File metadata and controls
47 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import ActiveApplicationMonitor
import AppKit
import SwiftUI
private let r: Double = 8
@MainActor
final class ChatWindowViewModel: ObservableObject {
@Published var chat: ChatProvider?
@Published var colorScheme: ColorScheme
@Published var isPanelDisplayed = false
@Published var chatPanelInASeparateWindow = false
public init(chat: ChatProvider? = nil, colorScheme: ColorScheme = .dark) {
self.chat = chat
self.colorScheme = colorScheme
}
}
struct ChatWindowView: View {
@ObservedObject var viewModel: ChatWindowViewModel
var body: some View {
Group {
if let chat = viewModel.chat {
ChatPanel(chat: chat)
.background {
Button(action: {
viewModel.isPanelDisplayed = false
if let app = ActiveApplicationMonitor.previousActiveApplication,
app.isXcode
{
app.activate()
}
}) {
EmptyView()
}
.keyboardShortcut("M", modifiers: [.command])
}
}
}
.opacity(viewModel.isPanelDisplayed ? 1 : 0)
.frame(minWidth: Style.panelWidth, minHeight: Style.panelHeight)
.preferredColorScheme(viewModel.colorScheme)
}
}