hex/ios/HEXShared/FullKeyboard/Engine/FullKeyboardEngine+Flicks.swift
Ryan Vogel e427414528
iOS keyboard: Apple's key flicks on the docked iPad (#2549)
* 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.
2026-11-24 17:48:58 -05:00

43 lines
2 KiB
Swift

import CoreGraphics
/// Key flicks on a docked iPad (`KeyboardFlicks`): a key pulled down types the character
/// over its letter.
@MainActor
extension FullKeyboardEngine {
/// A move of a key that flicks: once the finger has gone down more than across, the touch
/// keeps its key (no slide to the key below, no swipe) and its pull is tracked. False for
/// every other touch, which moves as before.
func moveFlick(_ touch: inout ActiveTouch, id: Int, to point: CGPoint) -> Bool {
guard KeyboardFlicks.isEnabled, layout.metrics.pad?.isDocked == true, !touch.committed,
touch.key.flick != nil, activeAccentMenu == nil else { return false }
let dy = point.y - touch.startPoint.y
let dx = abs(point.x - touch.startPoint.x)
if touch.flick == nil {
guard dy > 4, dy > dx else { return false }
}
let progress = KeyboardFlicks.progress(pull: dy)
guard progress != touch.flick else {
touches[id] = touch
return true
}
touch.flick = progress
touches[id] = touch
onChange?()
return true
}
/// Letting go of a pulled key: past half way, its character goes in as a typed one (as a
/// slide from 123 does: a mark after a word corrects it, a digit is just a digit). False
/// otherwise, and the letter goes in.
func commitFlick(_ touch: ActiveTouch) -> Bool {
guard let progress = touch.flick, progress >= KeyboardFlicks.commitProgress, let character = touch.key.flick else { return false }
typingLog?.ui("flick", [TypingLogField("key", .string(touch.key.label)), TypingLogField("chosen", .string(character))])
if dropsSuggestionSpace(before: character) || !correctWord(endingWith: character) {
insert(character, source: "flick")
}
if layerState.layer == .letters { shift.didType() }
refreshAutoCapitalization()
logState("typed")
return true
}
}