-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathToolRowView.swift
More file actions
43 lines (39 loc) · 1.36 KB
/
ToolRowView.swift
File metadata and controls
43 lines (39 loc) · 1.36 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
import SwiftUI
import ConversationServiceProvider
/// Individual tool row
struct ToolRow: View {
let toolName: String
let toolDescription: String?
let toolStatus: ToolStatus
let isServerEnabled: Bool
@Binding var isToolEnabled: Bool
var isInteractionAllowed: Bool = true
let onToolToggleChanged: (Bool) -> Void
var body: some View {
HStack(alignment: .center) {
Toggle(isOn: Binding(
get: { isToolEnabled },
set: { newValue in
isToolEnabled = newValue
onToolToggleChanged(newValue)
}
)) {
VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .center, spacing: 8) {
Text(toolName).fontWeight(.medium)
if let description = toolDescription {
Text(description)
.font(.system(size: 11))
.foregroundColor(.secondary)
.lineLimit(1)
.help(description)
}
}
Divider().padding(.vertical, 4)
}
}
.disabled(!isInteractionAllowed)
}
.padding(.vertical, 0)
}
}