mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-22 21:23:02 +01:00
Testers said many apps give Hex no Enter/Send key. The full keyboard always had a Return key, but some of its types didn't match Apple's. The dictation bar's Return was always a plain ↵, even in send, go and search fields, and it ignored enablesReturnKeyAutomatically. So in those fields the bar never looked like it could send. What changed - New ReturnKeyStyle (HEXShared/FullKeyboard/ReturnKeyStyle.swift): the symbol, the blue action style and the accessibility label for each UIReturnKeyType, as observed on Apple's iOS 27.2 keyboard (black box: simulator screenshots and axe describe-ui in a throwaway host app, one field per type). send ↑, go/join/route →, search/google/yahoo magnifier, done ✓ and emergency call (phone) are blue; return ↵, next and continue › are plain keys. - Full keyboard: uses ReturnKeyStyle. Fixes: next showed ↵ (now ›), continue was a blue → (now a plain ›), and emergency call drew the text "SOS" (now a blue phone symbol, like Apple's). The unused text-label path (returnLabel) is removed. - Off return key (enablesReturnKeyAutomatically and an empty field) now looks like Apple's: the glyph at 10% of the label colour, on a grey key (191,192,197; white 0.39 on dark) for the acting types, instead of the darker muted grey. - Dictation bar: its Return key uses the same style (blue send/go/search, disabled while the host asks and the field is empty) and still inserts "\n". Its accessibility label comes from ReturnKeyStyle; "SOS" becomes "Emergency call". - New zh-Hans strings: Return, Send, Go, Join, Route, Search, Next, Emergency call (Done and Continue already existed). Why some apps had no Enter/send: on the full keyboard, Return is present for every text keyboard type. Number pads hand off to Apple's keypad, which has no Return either. Apps such as Messages use the default return type and send from their own button, and Apple's keyboard also shows ↵ there. The gap was the dictation bar's Return, which was always a grey ↵. Verified (Mac Studio, iPhone 17 Pro sim, iOS 27.2) - Apple vs Hex screenshots for every UIReturnKeyType, light and dark, plus empty fields with enablesReturnKeyAutomatically: the full keyboard matches. - Dictation bar, live in a host app: send, go, search, next and emergency call styles shown. Send is grey and ignores taps in an empty field, turns blue after "," is typed, turns grey again after delete, and a tap reaches the host (textFieldShouldReturn counted once). - Generic iOS build (CODE_SIGNING_ALLOWED=NO) succeeded; xcodebuild test: 581 tests, 0 failures, 1 skipped.
43 lines
2.2 KiB
Swift
43 lines
2.2 KiB
Swift
import UIKit
|
||
|
||
/// The return key for the field's `returnKeyType`, as Apple's keyboard draws it (iOS 27.2, seen
|
||
/// in fields of every type: screenshots and the accessibility tree): a symbol on the blue key
|
||
/// for the types that act (send ↑, go, join and route →, search 🔍, done ✓, emergency call
|
||
/// 📞) and on a plain key for return ↵, next and continue ›. Both the full keyboard and the
|
||
/// dictation bar draw it.
|
||
nonisolated struct ReturnKeyStyle: Equatable, Sendable {
|
||
let symbol: String
|
||
let isAction: Bool
|
||
let accessibilityLabel: String
|
||
|
||
init(_ type: UIReturnKeyType?) {
|
||
switch type ?? .default {
|
||
case .send:
|
||
(symbol, isAction, accessibilityLabel) = ("arrow.up", true, String(localized: "Send"))
|
||
case .go:
|
||
(symbol, isAction, accessibilityLabel) = ("arrow.right", true, String(localized: "Go"))
|
||
case .join:
|
||
(symbol, isAction, accessibilityLabel) = ("arrow.right", true, String(localized: "Join"))
|
||
case .route:
|
||
(symbol, isAction, accessibilityLabel) = ("arrow.right", true, String(localized: "Route"))
|
||
case .google, .yahoo, .search:
|
||
(symbol, isAction, accessibilityLabel) = ("magnifyingglass", true, String(localized: "Search"))
|
||
case .done:
|
||
(symbol, isAction, accessibilityLabel) = ("checkmark", true, String(localized: "Done"))
|
||
case .emergencyCall:
|
||
(symbol, isAction, accessibilityLabel) = ("phone", true, String(localized: "Emergency call"))
|
||
case .next:
|
||
(symbol, isAction, accessibilityLabel) = ("chevron.right", false, String(localized: "Next"))
|
||
case .continue:
|
||
(symbol, isAction, accessibilityLabel) = ("chevron.right", false, String(localized: "Continue"))
|
||
default:
|
||
(symbol, isAction, accessibilityLabel) = ("return", false, String(localized: "Return"))
|
||
}
|
||
}
|
||
|
||
/// Off while the field is empty when it asks for that (`enablesReturnKeyAutomatically`):
|
||
/// Apple's key turns grey with a faint glyph and a tap does nothing.
|
||
static func isEnabled(automatically: Bool?, hasText: Bool) -> Bool {
|
||
!(automatically == true && !hasText)
|
||
}
|
||
}
|