mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
Ryan found the home screen cluttered: a large Keyboard setup checklist sat at
the top even when setup was nearly done, real features were filed under
Experiments, and every setting shared one long scroll. This prototype keeps
every setting and its behaviour, and changes only layout and copy.
Home now fits one screen: the Hex header, one status line ("Hex is ready", or
"Finish setup · 1 step ›"), the Dictate bar, four rows (Dictation, Keyboard,
Privacy, Experiments), then Keyboard settings ↗ and Run setup again.
- Replaced: KeyboardSetupCard with SetupStatusRow plus SetupSheet, a sheet
sized to its content. It has the same four checks, the Full Access check
field and Open Settings. Full Access that hasn't been confirmed reads "Not
confirmed yet" with a dotted circle, not as a failure. The keyboard's Open
Hex setup link opens the sheet.
- Removed: ExperimentsCard, split into pages (SettingsPages.swift):
Dictation has style, language, translate, clean up, Apple Intelligence
clean-up, custom vocabulary, keep mic warm and iPhone microphone. Keyboard
has full keyboard, then layout, autocorrect and key pop-ups only while it
is on, haptics, and the test field that was on home. Privacy has
"Everything stays on this iPhone" and Learn how I type. Experiments has
Emoji, with Clear emoji history while it's on, plus Record typing logs and
its viewer.
- Emoji used to show only while the full keyboard was on. It now shows
either way and reads "Needs the full keyboard" while it's off, because it
no longer sits under that switch.
- Haptics and Learn how I type stay visible with the full keyboard off,
because the dictation bar uses them too (KeyboardViewController).
- Copy is cut to one line per row. "Insert in" is now a Menu in the app's
muted style instead of the system picker, with the same choices and writes.
- Removed the practice field's autofocus for hosted-keyboard scenes. It was
dead code, because HEXMobileApp sends those scenes to
HostedKeyboardConversationStage.
- New --snap-state scenes: settings-home, setup-sheet, and
settings-<page>[-on][-end]. These write the page's switches (Emoji
included) to the App Group, so each render is deterministic.
Verified: the build passes on an iPhone 18 Pro simulator (iOS 27.2) on the
Mac Studio, rebased onto origin/dev with the emoji panel.
129 lines
4.2 KiB
Swift
129 lines
4.2 KiB
Swift
import SwiftUI
|
||
|
||
/// The custom vocabulary list shown under its switch in Settings › Dictation.
|
||
struct CustomVocabularyEditor: View {
|
||
private let settings = CustomVocabularySettings()
|
||
|
||
@State private var terms: [String] = []
|
||
@State private var draft = ""
|
||
@State private var notice: String?
|
||
|
||
private var isAtLimit: Bool {
|
||
terms.count >= CustomVocabularySettings.maxTermCount
|
||
}
|
||
|
||
var body: some View {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
ForEach(terms, id: \.self) { term in
|
||
HStack(spacing: 10) {
|
||
Text(term)
|
||
.font(.system(size: 14))
|
||
.foregroundStyle(HexTheme.textBase)
|
||
.lineLimit(1)
|
||
|
||
Spacer(minLength: 8)
|
||
|
||
Button {
|
||
remove(term)
|
||
} label: {
|
||
Image(systemName: "xmark")
|
||
.font(.system(size: 11, weight: .semibold))
|
||
.foregroundStyle(HexTheme.textMuted)
|
||
.frame(width: 26, height: 26)
|
||
.background(HexTheme.layer02, in: Circle())
|
||
}
|
||
.buttonStyle(.plain)
|
||
.accessibilityLabel("Remove \(term)")
|
||
}
|
||
.padding(.leading, 12)
|
||
.padding(.trailing, 6)
|
||
.frame(minHeight: 36)
|
||
.background(
|
||
HexTheme.layer01,
|
||
in: RoundedRectangle(
|
||
cornerRadius: HexTheme.controlRadius,
|
||
style: .continuous
|
||
)
|
||
)
|
||
}
|
||
|
||
TextField("Add a word or phrase", text: $draft)
|
||
.font(.system(size: 14))
|
||
.foregroundStyle(HexTheme.textBase)
|
||
.textInputAutocapitalization(.never)
|
||
.autocorrectionDisabled()
|
||
.submitLabel(.done)
|
||
.onSubmit(add)
|
||
.onChange(of: draft) { _, _ in
|
||
notice = nil
|
||
}
|
||
.disabled(isAtLimit)
|
||
.padding(.horizontal, 12)
|
||
.frame(minHeight: 38)
|
||
.background(
|
||
HexTheme.layer01,
|
||
in: RoundedRectangle(
|
||
cornerRadius: HexTheme.controlRadius,
|
||
style: .continuous
|
||
)
|
||
)
|
||
.opacity(isAtLimit ? 0.5 : 1)
|
||
|
||
if isAtLimit {
|
||
Text("Up to 100 terms")
|
||
.font(.system(size: 12))
|
||
.foregroundStyle(HexTheme.textMuted)
|
||
}
|
||
|
||
if let notice {
|
||
Text(notice)
|
||
.font(.system(size: 12))
|
||
.foregroundStyle(HexTheme.textMuted)
|
||
.fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
|
||
Text("Fixes spelling, not words Hex mishears")
|
||
.font(.system(size: 12))
|
||
.foregroundStyle(HexTheme.textMuted)
|
||
.fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
.onAppear {
|
||
terms = settings.terms
|
||
}
|
||
}
|
||
|
||
private func add() {
|
||
guard !isAtLimit else { return }
|
||
let candidate = draft.trimmingCharacters(in: .whitespacesAndNewlines)
|
||
guard !candidate.isEmpty else { return }
|
||
|
||
guard candidate.count <= CustomVocabularySettings.maxTermLength else {
|
||
notice = "Too long"
|
||
return
|
||
}
|
||
let key = VocabularySpelling.normalizedKey(candidate)
|
||
guard key.count >= 2 else {
|
||
notice = "Needs at least two letters or digits"
|
||
return
|
||
}
|
||
let isDuplicate = terms.contains {
|
||
VocabularySpelling.normalizedKey($0) == key
|
||
}
|
||
guard !isDuplicate else {
|
||
notice = "Already in the list"
|
||
return
|
||
}
|
||
|
||
let updated = CustomVocabularySettings.sanitize(terms + [candidate])
|
||
terms = updated
|
||
settings.terms = updated
|
||
draft = ""
|
||
notice = nil
|
||
}
|
||
|
||
private func remove(_ term: String) {
|
||
terms.removeAll { $0 == term }
|
||
settings.terms = terms
|
||
notice = nil
|
||
}
|
||
}
|