Simplify guided reflection keyboard toolbar to dismiss-only icon
Remove Back/Next/Done buttons from keyboard toolbar to eliminate confusion with the bottom action bar. Toolbar now shows only a keyboard.chevron.compact.down dismiss icon. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// ChipSelectionView.swift
|
||||
// Reflect
|
||||
//
|
||||
// Reusable chip selection grid for guided reflection quick-pick answers.
|
||||
// Reusable chip grid for guided reflection — tapping a chip appends its text.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
@@ -11,8 +11,8 @@ struct ChipSelectionView: View {
|
||||
|
||||
let chips: QuestionChips
|
||||
let accentColor: Color
|
||||
@Binding var selectedChips: [String]
|
||||
@Binding var textAnswer: String
|
||||
var onInsert: ((String) -> Void)? = nil
|
||||
@State private var showMore = false
|
||||
|
||||
var body: some View {
|
||||
@@ -56,9 +56,8 @@ struct ChipSelectionView: View {
|
||||
}
|
||||
|
||||
private func chipButton(_ label: String) -> some View {
|
||||
let isSelected = selectedChips.contains(label)
|
||||
return Button {
|
||||
toggleChip(label)
|
||||
Button {
|
||||
appendChip(label)
|
||||
} label: {
|
||||
Text(label)
|
||||
.font(.subheadline)
|
||||
@@ -66,39 +65,27 @@ struct ChipSelectionView: View {
|
||||
.padding(.vertical, 8)
|
||||
.background(
|
||||
Capsule()
|
||||
.fill(isSelected ? accentColor.opacity(0.2) : Color(.systemGray6))
|
||||
.fill(Color(.systemGray6))
|
||||
)
|
||||
.overlay(
|
||||
Capsule()
|
||||
.stroke(isSelected ? accentColor : Color(.systemGray4), lineWidth: 1)
|
||||
.stroke(Color(.systemGray4), lineWidth: 1)
|
||||
)
|
||||
.foregroundColor(isSelected ? accentColor : .primary)
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
.accessibilityIdentifier(AccessibilityID.GuidedReflection.chip(label: label))
|
||||
}
|
||||
|
||||
// MARK: - Chip Toggle
|
||||
// MARK: - Append Chip Text
|
||||
|
||||
private func toggleChip(_ label: String) {
|
||||
if let index = selectedChips.firstIndex(of: label) {
|
||||
selectedChips.remove(at: index)
|
||||
// Remove from text answer
|
||||
let separator = ", "
|
||||
var parts = textAnswer
|
||||
.components(separatedBy: separator)
|
||||
.map { $0.trimmingCharacters(in: .whitespaces) }
|
||||
.filter { !$0.isEmpty }
|
||||
parts.removeAll { $0 == label }
|
||||
textAnswer = parts.joined(separator: separator)
|
||||
private func appendChip(_ label: String) {
|
||||
let trimmed = textAnswer.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if trimmed.isEmpty {
|
||||
textAnswer = label
|
||||
} else {
|
||||
selectedChips.append(label)
|
||||
// Append to text answer
|
||||
if textAnswer.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
textAnswer = label
|
||||
} else {
|
||||
textAnswer += ", \(label)"
|
||||
}
|
||||
textAnswer = trimmed + "\n" + label
|
||||
}
|
||||
onInsert?(label)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user