hex/ios/HEXShared/FullKeyboard/FullKeyboardSettings.swift
Ryan Vogel 8c7d01672e
iOS: add a Key pop-ups switch to the full keyboard (#2027)
A tester asked to turn off the enlarged letter that pops up over a pressed key. Experiments › Full keyboard › Key pop-ups (on by default) now controls it; off, the pressed key darkens in place as with iOS's Character Preview off. Typing logs record the setting as key_popups.

Verified HEXMobileTests on the iPhone 18 Pro simulator and simulator renders of a held key with the setting on and off.
2026-11-20 11:47:18 +00:00

47 lines
1.7 KiB
Swift

import Foundation
/// The full keyboard's switches in the shared App Group.
///
/// Without Full Access the keyboard cannot read the App Group, so `isEnabled` reads
/// `false` there and the keyboard keeps today's setup card.
@MainActor
struct FullKeyboardSettings {
static let launchArgument = "--experiment-full-keyboard"
private enum Key {
static let fullKeyboard = "experiments.fullKeyboard"
static let autocorrect = "settings.keyboardAutocorrect"
static let keyPopups = "settings.keyboardKeyPopups"
}
private let defaults: UserDefaults?
init(defaults: UserDefaults? = UserDefaults(suiteName: KeyboardBridge.appGroup)) {
self.defaults = defaults
}
/// Experiment: Hex shows a full QWERTY keyboard instead of the dictation bar. Off by default.
var isEnabled: Bool {
get { defaults?.bool(forKey: Key.fullKeyboard) ?? false }
nonmutating set { defaults?.set(newValue, forKey: Key.fullKeyboard) }
}
/// Cautious autocorrect on space. On by default.
var autocorrect: Bool {
get { defaults?.object(forKey: Key.autocorrect) as? Bool ?? true }
nonmutating set { defaults?.set(newValue, forKey: Key.autocorrect) }
}
/// The enlarged letter that pops up over a pressed key. On by default.
var keyPopups: Bool {
get { defaults?.object(forKey: Key.keyPopups) as? Bool ?? true }
nonmutating set { defaults?.set(newValue, forKey: Key.keyPopups) }
}
/// Simulator scenes pass `--experiment-full-keyboard` to turn the experiment on.
func applyLaunchArguments(_ arguments: [String] = ProcessInfo.processInfo.arguments) {
if arguments.contains(Self.launchArgument) {
isEnabled = true
}
}
}