mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* iOS keyboard: Apple's key flicks on the docked iPad, and no Number row switch there TestFlight build 147 (iPad Air 11-inch): "On ipad number row is not visible - broken, and flick for symbol is not working either." Settings › Keyboard showed Number row on an iPad, where it does nothing (the iPad keeps Apple's rows), and Hex's keys had none of Apple's key flicks. Docked iPad letter keys now carry Apple's flick characters (iPad mini, iPadOS 26.5 and 27.2, black box): 1 to 0 over row 1, @ # $ & * ( ) ' " over row 2, % - + = / ; : over row 3 in English and German, AZERTY's own in French, and the #+= page's characters over the 123 page's symbols. Pulling a key down slides its character into place as Apple's does; let go past half way (17 pt) and it goes in as a typed character, short of it or pulled back, the letter. The pull keeps its key and never starts a swipe; rollover commits it; Reduce Motion swaps without the slide. Apple's Enable Key Flicks can't be read by an extension, so Settings › Keyboard has Key flicks (on by default), shown on an iPad in place of Number row, which is hidden there. Typing logs: ui flick and insert src flick. Verified: iOS suite on the Studio, 976 tests, 0 failures, 4 skipped; code-shape.py --check passes; iPad mini (26.5, 27.2), Air 11-inch and Pro 13-inch simulators beside Apple's, a pull typing 3 and a short one E, and "Room 415" recorded with flicks. * iOS keyboard: key flicks' drawing and test sit away from the number pad's What: moves drawFlickKey below pixelAligned in KeyboardKeyPlaneView.swift, and testDockedIPadKeysCarryApplesKeyFlicks into KeyboardLayoutTests beside the accent menu tests. Pure moves, no change in code or assertions. Why: #2541 (Hex's number pad) adds its own drawing function and test at the very spots these were added, so the two pull requests conflicted whichever landed second. Apart, both merge into dev in either order. Verified: merges with origin/dev, #2541 and #2542 without conflicts. * iOS keyboard: the key flicks hint string sits beside "Key flicks" in the catalog What: moves "Pull a key down to type the character above its letter" from its alphabetical place to right after "Key flicks". Same key and translation. Why: #2542 adds "Passwords" at that exact alphabetical place, so the two conflicted. Verified: the catalog parses; merges with origin/dev, #2541 and #2542 without conflicts.
76 lines
4.1 KiB
Swift
76 lines
4.1 KiB
Swift
import CoreGraphics
|
||
|
||
/// Apple's key flicks on the docked iPad keyboard (Settings › General › Keyboard › Enable Key
|
||
/// Flicks): every letter key carries a small grey character above its letter, and pulling the
|
||
/// key down types it. Read on Apple's iPad mini keyboard (iPadOS 27.2 simulator, black box,
|
||
/// 2026-11-23), the rows Hex draws on every docked iPad (`KeyboardPadRows.swift`):
|
||
///
|
||
/// - English and German: 1 to 0 over row 1, @ # $ & * ( ) ' " over row 2, % - + = / ; : over
|
||
/// row 3; French (AZERTY): 1 to 0, @ # & " $ ( ! ) - *, and % _ + = / ;.
|
||
/// - The 123 page: the #+= page's character over each symbol (€ over @, § over %), not on the
|
||
/// digits.
|
||
/// - The two-symbol keys after the letters keep their own pair and flick nothing.
|
||
///
|
||
/// Drawn about 12.5 pt high in a grey a little above the key's middle top, the letter set
|
||
/// lower; while pulled, the character slides down to the middle and darkens as the letter
|
||
/// fades (none of it moves at 8 pt, about half way at 16 pt, all the way by 30 pt). A
|
||
/// keyboard extension can't read Apple's switch (the Custom Keyboard guide: no access to the
|
||
/// general keyboard settings), so Hex has its own (Settings › Keyboard › Key flicks).
|
||
nonisolated enum KeyboardFlicks {
|
||
/// Settings › Keyboard › Key flicks, set by the keyboard view from the App Group.
|
||
nonisolated(unsafe) static var isEnabled = true
|
||
|
||
/// No change below this pull (pt).
|
||
static let start: CGFloat = 8
|
||
/// Pull (pt) from `start` to the character in place.
|
||
static let travel: CGFloat = 18
|
||
/// Let go at or past this share of the way and the character goes in; short of it (or
|
||
/// pulled back up), the letter.
|
||
static let commitProgress: CGFloat = 0.5
|
||
|
||
/// How far a pull of `dy` points down has brought the character, 0 to 1.
|
||
static func progress(pull dy: CGFloat) -> CGFloat {
|
||
min(1, max(0, (dy - start) / travel))
|
||
}
|
||
|
||
private static let digits = "1234567890".map(String.init)
|
||
private static let englishMiddle = ["@", "#", "$", "&", "*", "(", ")", "'", "\""]
|
||
private static let englishBottom = ["%", "-", "+", "=", "/", ";", ":"]
|
||
private static let frenchMiddle = ["@", "#", "&", "\"", "$", "(", "!", ")", "-", "*"]
|
||
private static let frenchBottom = ["%", "_", "+", "=", "/", ";"]
|
||
/// The 123 page's symbols and the #+= page's character Apple puts over each.
|
||
private static let numbersPage: [String: String] = [
|
||
"@": "€", "#": "£", "$": "¥", "&": "_", "*": "^", "(": "[", ")": "]", "'": "{", "\"": "}",
|
||
"%": "§", "-": "|", "+": "~", "=": "…", "/": "\\", ";": "<", ":": ">",
|
||
]
|
||
|
||
/// Each key's flick on the letters and 123 pages. Measured for English, German and French;
|
||
/// every other language gets the digits over a ten-letter row 1 (Apple's own for them
|
||
/// unmeasured), and rows 2 and 3 only where they have English's nine and seven letters.
|
||
static func add(to keys: inout [KeyboardKey], layer: KeyboardLayer, language: KeyboardLanguage) {
|
||
switch layer {
|
||
case .symbols:
|
||
return
|
||
case .numbers:
|
||
for i in keys.indices where keys[i].shifted == nil && keys[i].row > 0 {
|
||
if let c = keys[i].character { keys[i].flick = numbersPage[c] }
|
||
}
|
||
case .letters:
|
||
let measured = language == .english || language == .german
|
||
let rows: [[String]] = language.isFrench
|
||
? [digits, frenchMiddle, frenchBottom]
|
||
: [digits, measured ? englishMiddle : [], measured ? englishBottom : []]
|
||
for row in 0..<3 {
|
||
let letters = keys.indices
|
||
.filter { keys[$0].row == row && keys[$0].shifted == nil && keys[$0].character?.first?.isLetter == true }
|
||
.sorted { keys[$0].frame.minX < keys[$1].frame.minX }
|
||
let flicks = rows[row]
|
||
if row == 0, letters.count != 10 { continue }
|
||
if row > 0, !language.isFrench, letters.count != flicks.count { continue }
|
||
for (n, i) in letters.enumerated() where n < flicks.count {
|
||
keys[i].flick = flicks[n]
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|