mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
A field that asks for a number pad (.numberPad, .asciiCapableNumberPad, .decimalPad; in Safari inputmode="numeric" and "decimal") now gets Hex's own pad instead of its 123 page, drawn on Apple's: 1-9, a blank corner, 0 and delete, the phone letters under 2-9, Apple's columns to the point (402 pt iPhone 4.67/126.33/6/126.67/6/126.33/6; SE 4.5 + 3 x 117.5 with 6 pt gaps; turned 137.33 pt keys centred; Duo folded on the letters' edges with 7 pt gaps; Duo unfolded upright in the split's right half, as Apple's), the decimal pad's separator by region, no keycap on delete or the separator, no pop-up and no holds on a press. Measured as a black box on the iOS 26.5 and 27.2 simulators (iPhone 17 Pro, SE, Duo). Hex keeps its strip above the pad (Hex key, Paste, Code from Messages), so the pad fills the letter keys' band and the keyboard keeps its height between fields; Apple's pad has no bar. On a Home-button iPhone Hex's globe takes the blank corner. Removed: the number pad hand-off (handOffNumericPadIfNeeded, handsOffNumberPad, KeyboardFieldRoute.handOff). Where iOS asked Hex for a globe (Home-button iPhones, the Duo) a number field used to switch to the next keyboard by itself; there is now a pad of Hex's own, so nothing switches. The globe and Code from Messages stay the ways to Apple's keyboard. iPads are unchanged (iOS shows its own number popover there). Phone pads and secure fields never reach a third-party keyboard. The pad is a field kind of its own that takes no words: no suggestions, autocorrect, swipe, Learn how I type or Adaptive touch. The strip's Hex key is now built by one helper (stripHexKey) shared with the key rows. Verified: iOS suite on the Studio, 975 tests, 0 failures, 4 skipped; code-shape.py --check passes; screenshots beside Apple's in a native host and Safari on iPhone 17 Pro (27.2, 26.5), SE, Duo folded and unfolded, light and dark, and a recorded phone number.
38 lines
1.7 KiB
Swift
38 lines
1.7 KiB
Swift
import CoreGraphics
|
|
|
|
/// The kind of text field, as far as the key rows care.
|
|
nonisolated enum KeyboardFieldKind: Equatable, Sendable {
|
|
case text
|
|
/// Adds `.` and `/` right of space.
|
|
case url
|
|
/// Adds `@` and `.` right of space, matching Apple's iOS 26 email layout.
|
|
case email
|
|
/// A `.webSearch` field (Safari's address bar): text, with Apple's `.` right of space.
|
|
case webSearch
|
|
/// A number pad field (`.numberPad`, `.asciiCapableNumberPad`): Hex's own pad on an iPhone
|
|
/// (`KeyboardNumberPad`), the 123 page on an iPad.
|
|
case numberPad
|
|
/// A `.decimalPad` field: the number pad with the region's decimal separator.
|
|
case decimalPad
|
|
}
|
|
|
|
nonisolated extension KeyboardFieldKind {
|
|
/// Fields typed in words, where autocorrect, swipe, suggestions, smart punctuation, emoji
|
|
/// and Learn how I type work as the field's traits allow: text, and web search, whose only
|
|
/// difference is its `.` key. URL and email fields type addresses.
|
|
var takesWords: Bool { self == .text || self == .webSearch }
|
|
|
|
var isNumberPad: Bool { self == .numberPad || self == .decimalPad }
|
|
|
|
/// The keys right of the space bar, each `width` wide: Apple's `.` and `/` in a URL field,
|
|
/// `@` and `.` in an email field, and `.` in a web search field.
|
|
func keysRightOfSpace(width: CGFloat) -> [(KeyKind, CGFloat, String)] {
|
|
switch self {
|
|
case .text: []
|
|
case .url: [(.character("."), width, "."), (.character("/"), width, "/")]
|
|
case .email: [(.character("@"), width, "@"), (.character("."), width, ".")]
|
|
case .webSearch: [(.character("."), width, ".")]
|
|
case .numberPad, .decimalPad: []
|
|
}
|
|
}
|
|
}
|