-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathChatModePicker.swift
More file actions
63 lines (58 loc) · 2.16 KB
/
ChatModePicker.swift
File metadata and controls
63 lines (58 loc) · 2.16 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import SwiftUI
import Persist
import ConversationServiceProvider
public extension Notification.Name {
static let gitHubCopilotChatModeDidChange = Notification
.Name("com.github.CopilotForXcode.ChatModeDidChange")
}
public struct ChatModePicker: View {
@Binding var chatMode: String
@Environment(\.colorScheme) var colorScheme
var onScopeChange: (PromptTemplateScope) -> Void
public init(chatMode: Binding<String>, onScopeChange: @escaping (PromptTemplateScope) -> Void = { _ in }) {
self._chatMode = chatMode
self.onScopeChange = onScopeChange
}
public var body: some View {
HStack(spacing: -1) {
ModeButton(
title: "Ask",
isSelected: chatMode == "Ask",
activeBackground: colorScheme == .dark ? Color.white.opacity(0.25) : Color.white,
activeTextColor: Color.primary,
inactiveTextColor: Color.primary.opacity(0.5),
action: {
chatMode = "Ask"
AppState.shared.setSelectedChatMode("Ask")
onScopeChange(.chatPanel)
NotificationCenter.default.post(
name: .gitHubCopilotChatModeDidChange,
object: nil
)
}
)
ModeButton(
title: "Agent",
isSelected: chatMode == "Agent",
activeBackground: Color.blue,
activeTextColor: Color.white,
inactiveTextColor: Color.primary.opacity(0.5),
action: {
chatMode = "Agent"
AppState.shared.setSelectedChatMode("Agent")
onScopeChange(.agentPanel)
NotificationCenter.default.post(
name: .gitHubCopilotChatModeDidChange,
object: nil
)
}
)
}
.padding(1)
.frame(height: 20, alignment: .topLeading)
.background(.primary.opacity(0.1))
.cornerRadius(5)
.padding(4)
.help("Set Mode")
}
}