forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatFeedbackReasonPicker.swift
More file actions
54 lines (50 loc) · 1.88 KB
/
Copy pathChatFeedbackReasonPicker.swift
File metadata and controls
54 lines (50 loc) · 1.88 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
import OmiTheme
import SwiftUI
/// One-click "what went wrong" row, shown under a bubble after a thumbs-down.
///
/// Deliberately an inline row rather than a modal sheet: the reason is a
/// nicety, not a toll. The thumbs-down is already recorded by the time this
/// appears, so a user who ignores it loses nothing — they keep reading, and the
/// report records that turn's reason as "not captured".
struct ChatFeedbackReasonPicker: View {
/// Which five chips to show — notification cards and chat answers use
/// distinct taxonomies (see `ChatFeedbackReason.chips(isProactiveNotification:)`).
let reasons: [ChatFeedbackReason]
/// The reason already chosen, if any. Highlights that chip.
let selected: ChatFeedbackReason?
let onSelect: (ChatFeedbackReason) -> Void
let onSkip: () -> Void
var body: some View {
HStack(spacing: OmiSpacing.xxs) {
Text("What went wrong?")
.scaledFont(size: OmiType.micro)
.foregroundColor(Ink.secondary)
ForEach(reasons) { reason in
Button(action: { onSelect(reason) }) {
Text(reason.label)
.scaledFont(size: OmiType.micro)
.foregroundColor(selected == reason ? Ink.primary : Ink.secondary)
.padding(.horizontal, OmiSpacing.xxs)
.padding(.vertical, 1)
.background(
RoundedRectangle(cornerRadius: 4)
.stroke(Ink.secondary.opacity(0.35), lineWidth: 1)
)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.help(reason.help)
.accessibilityLabel("Reason: \(reason.label)")
}
Button(action: onSkip) {
Image(systemName: "xmark")
.scaledFont(size: OmiType.micro)
.foregroundColor(Ink.secondary)
.contentShape(Rectangle())
}
.buttonStyle(.plain)
.help("Skip")
.accessibilityLabel("Skip reason")
}
}
}