hex/ios/HEXShared/FullKeyboard/View/FullKeyboardView+Settings.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

72 lines
3 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import UIKit
/// The keyboard's key layout settings (Settings › Keyboard and Settings › Experiments),
/// applied on every sync: where the Hex key sits, the number row, and whether the Duo unfolded
/// draws one keyboard. Switches that only change typing behaviour stay in
/// `FullKeyboardView.syncSettings`.
@MainActor
extension FullKeyboardView {
/// Settings › Keyboard › Hex key: Right (the strip's trailing end) or Left (its leading
/// end), kept in `HexKeyPlacement.current` too for typing logs.
func syncHexPlacement() {
let placement = hexPlacementOverride ?? FullKeyboardSettings().hexKeyPlacement
HexKeyPlacement.current = placement
guard engine.hexPlacement != placement else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.hexPlacement = placement
setNeedsLayout()
}
/// Settings › Keyboard › Number row: the keyboard grows by the row, so the host is asked
/// for the new height. Settings › Keyboard › Key flicks (iPad) is read here too.
func syncNumberRow() {
let flicks = FullKeyboardSettings().keyFlicks
if KeyboardFlicks.isEnabled != flicks {
KeyboardFlicks.isEnabled = flicks
plane.setNeedsDisplay()
}
let shows = FullKeyboardSettings().numberRow
guard engine.showsNumberRow != shows else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.showsNumberRow = shows
setNeedsLayout()
onPreferredHeightChange?()
}
/// Settings › Experiments › Join the keyboard when unfolded: the Duo unfolded upright draws
/// one keyboard rather than the split one. The rows keep their heights, so the host is asked
/// for nothing.
func syncJoinsUnfoldedKeyboard() {
let joins = FullKeyboardSettings().joinsKeyboardWhenUnfolded
guard engine.joinsUnfoldedKeyboard != joins else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.joinsUnfoldedKeyboard = joins
setNeedsLayout()
}
/// Settings › Experiments › Dvorak punctuation keys: English's Dvorak letters gain comma,
/// period and semicolon keys. No row changes height, so the host is asked for nothing.
func syncDvorakPunctuation() {
let on = FullKeyboardSettings().dvorakPunctuation
guard engine.dvorakPunctuation != on else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.dvorakPunctuation = on
setNeedsLayout()
}
/// Settings › Experiments › Comma and period keys: a comma and a period join the space bar
/// on an iPhone's letters page in a text field. No row changes height, so the host is asked
/// for nothing.
func syncCommaPeriodKeys() {
let on = FullKeyboardSettings().commaPeriodKeys
guard engine.commaPeriodKeys != on else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.commaPeriodKeys = on
setNeedsLayout()
}
}