forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCPToolRowView.swift
More file actions
38 lines (34 loc) · 1.24 KB
/
MCPToolRowView.swift
File metadata and controls
38 lines (34 loc) · 1.24 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
import SwiftUI
import GitHubCopilotService
/// Individual tool row
struct MCPToolRow: View {
let tool: MCPTool
let isServerEnabled: Bool
@Binding var isToolEnabled: Bool
let onToolToggleChanged: (Bool) -> Void
var body: some View {
HStack(alignment: .center) {
Toggle(isOn: Binding(
get: { isToolEnabled },
set: { onToolToggleChanged($0) }
)) {
VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .center, spacing: 8) {
Text(tool.name).fontWeight(.medium)
if let description = tool.description {
Text(description)
.font(.system(size: 11))
.foregroundColor(.secondary)
.lineLimit(1)
}
}
Divider().padding(.vertical, 4)
}
}
}
.padding(.leading, 32)
.padding(.vertical, 0)
.onChange(of: tool._status) { isToolEnabled = $0 == .enabled }
.onChange(of: isServerEnabled) { if !$0 { isToolEnabled = false } }
}
}