mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
A tester on build 117 (iPhone 14 Pro, iOS 27.2.1, Spotlight) marked the top of Hex's keyboard: a greyer rounded panel sitting inside iOS's panel, with a seam under the band iOS adds above a third-party keyboard. Ryan: the space is fine as long as it is the same colour. Cause: since #2256 a thin material sat under the whole keyboard, always. It compresses whatever is behind it: on an iPhone 17 Pro (iOS 27.2, dark mode) Hex's area read 36 where the glass is 31 (Notes), 45 where it is 54 (a light page), and stayed neutral grey where the glass takes a wallpaper's tint (Spotlight: 37,38,38 under a band of 32,37,39 in the tester's screenshot). No tint can match glass that follows its background, so Hex was a panel of another colour inside iOS's panel, with its own corners. The material was there for one reason: iOS can leave Apple's keyboard under a third-party one, and Hex's keys are translucent. What the extension can observe turned out to mark that case exactly. iOS makes a new input view controller each time the keyboard comes up, tells the one before it disappeared, and frees it. In a field that takes focus as its screen appears and has an input accessory view, opened with Hex, it doesn't: switching to Apple's keyboard gives Hex no viewWillDisappear and keeps its controller and remote view; Apple's keyboard is added beside it, and switching back makes a second Hex on top without taking Apple's away. Opened with Apple's keyboard, the same field hides and frees Hex as usual and nothing is left behind, and so do a field focused by a tap, Safari and Spotlight (iOS 27.0 and 27.2 simulators, a keyboard extension logging its own lifecycle). Changed: - KeyboardsOnScreen (new, pure): Hex's keyboards on screen in this process, in order, each with its field (UIKit's documentIdentifier). A keyboard is over another when an earlier one was never told to disappear and is still in the same field; a field UIKit hasn't named counts as the same one. - KeyboardViewController keeps one for the process (viewWillAppear, viewWillDisappear, deinit, and the field in textDidChange) and shows its backdrop only while its keyboard is over another. Otherwise the backdrop is hidden and Hex draws nothing behind its keys: its background is iOS's glass, the colour of iOS's band and of the globe row, on any background. - KeyboardBackdropView is unchanged in what it draws (the ultra-thin material, shaded in dark mode, the panel's corners). Replaced: the always-on material from #2256. Its protection is kept for the case it was for; in that case Hex still shows the material's slightly different tone until the keyboard is next dismissed. Verified: - xcodebuild test on an iPhone 17 Pro simulator (iOS 27.2), Mac Studio: 693 tests, 3 skipped (AppleSpeechClipTests and the two TypingReplayTests, which need local files), 0 failures. KeyboardLayoutTests has the on-screen rule (dismiss and reopen, the kept keyboard, another field, an unnamed field, a keyboard appearing again) beside the material's and outline's cases. - iOS 27.0 and 27.2 simulators with this build: the accessory field opened with Hex is clear; after Hex, Apple's keyboard, Hex it is covered and shows no key shapes (light and dark); reopened it is clear again. Opened with Apple's keyboard, a tap-focused field, Safari, another app after Safari and Spotlight stay clear after switching, with nothing showing through. Hex's area equals the glass beside it exactly (0 of 255) over a white app, light and dark web pages and Spotlight, light and dark. - The strip over real glass, light and dark: suggestions, the correction chip, the Full Access hint, the emoji panel and emoji search (live), and recording, transcribing and Undo dictation in the snapshot stage. - Apple's keys overlaid on Hex's (iPhone 17 Pro, iOS 27.2 simulator), with and without iOS's band: every key edge on Apple's pixel, as before. - Ryan's iPhone 17 Pro (iOS 27.2): Spotlight over his wallpaper, Notes, a Safari form and DuckDuckGo. The step at Hex's top edge went from 8, 5 to the background's own texture (0 in Notes), and at its bottom edge from 6, 5, 8, 9 to 1, 0, 0, 0. Switching to Apple's keyboard and back in each, and dismissing and refocusing DuckDuckGo's field, stayed clear with no trace of another keyboard. Not verified: the leftover-keys case on a real iPhone (no field there reproduces it, so the cover engaging on a device is untested), a keyboard process iOS restarts between the two keyboards (the new process can't know of the earlier keyboard), Paste and Paste dictation over glass (they need Full Access on the simulator), iOS 26 and earlier, an iPad, a Duo.
57 lines
2.9 KiB
Swift
57 lines
2.9 KiB
Swift
import Foundation
|
|
|
|
/// Hex's keyboards that iOS has on screen at once. It should be one.
|
|
///
|
|
/// iOS makes a new input view controller each time the keyboard comes up, tells the one before
|
|
/// that it disappeared, and frees it. In one case it doesn't (iOS 27.0 and 27.2 simulators,
|
|
/// every time): a field that takes focus as its screen appears and has an input accessory
|
|
/// view, opened with Hex. There, switching to Apple's keyboard never tells Hex it disappeared
|
|
/// and keeps its remote view in the app's view tree; Apple's keyboard is added beside it, and
|
|
/// switching back puts a second Hex on top without taking Apple's away (a
|
|
/// `UIKeyboardAutomatic` between two remote views in `_UIKBCompatInputView`). Hex's keys are
|
|
/// translucent on iOS's glass, so Apple's keys showed through a row above its own (TestFlight
|
|
/// build 56, iPhone 17, iOS 27.0.1). Opened with Apple's keyboard, the same field hides and
|
|
/// frees Hex as usual, and nothing is left behind.
|
|
///
|
|
/// A keyboard can't see the app's views, but it can see this: an earlier Hex keyboard that
|
|
/// was never told to disappear, still on screen in the same field. That is exactly when
|
|
/// Apple's keys may be under the new one, and the only time Hex draws its backdrop
|
|
/// (`KeyboardBackdropView`). Otherwise Hex draws nothing behind its keys and is iOS's glass.
|
|
nonisolated struct KeyboardsOnScreen: Equatable, Sendable {
|
|
private struct Entry: Equatable, Sendable {
|
|
let keyboard: Int
|
|
/// The field the keyboard is in, nil until UIKit names it.
|
|
var field: UUID?
|
|
}
|
|
|
|
/// In the order they appeared.
|
|
private var entries: [Entry] = []
|
|
|
|
var count: Int { entries.count }
|
|
|
|
/// `keyboard` came on screen in `field`, after every keyboard already there.
|
|
mutating func appeared(_ keyboard: Int, in field: UUID?) {
|
|
entries.removeAll { $0.keyboard == keyboard }
|
|
entries.append(Entry(keyboard: keyboard, field: field))
|
|
}
|
|
|
|
/// UIKit named `keyboard`'s field, or it moved to another. Nothing for a keyboard off screen.
|
|
mutating func moved(_ keyboard: Int, to field: UUID?) {
|
|
guard let index = entries.firstIndex(where: { $0.keyboard == keyboard }) else { return }
|
|
entries[index].field = field
|
|
}
|
|
|
|
/// iOS said `keyboard` disappeared, or freed it.
|
|
mutating func disappeared(_ keyboard: Int) {
|
|
entries.removeAll { $0.keyboard == keyboard }
|
|
}
|
|
|
|
/// Whether an earlier keyboard is still on screen in `keyboard`'s field: iOS kept it, and
|
|
/// with it whatever it showed in between. A field UIKit hasn't named counts as the same
|
|
/// one, so the doubt covers.
|
|
func isOverAnother(_ keyboard: Int) -> Bool {
|
|
guard let index = entries.firstIndex(where: { $0.keyboard == keyboard }) else { return false }
|
|
let field = entries[index].field
|
|
return entries[..<index].contains { $0.field == nil || field == nil || $0.field == field }
|
|
}
|
|
}
|