…lines 1–6 unchanged (6 lines)
7// switches to the Search tab. This lets us show the keyboard *before*
8// SwiftUI’s searchable view finishes its expansion animation.
9//
10struct KeyboardHackField: UIViewRepresentable {
11 @Binding var shouldShow: Bool
12
13 // Capture Backspace/Enter on the hidden field and forward to JS.
14 class KeyboardHackTextField: UITextField {
15 var onKeyPress: ((String) -> Void)?
16
17 override func deleteBackward() {
18 super.deleteBackward()
19 onKeyPress?("backspace")
20 text = ""
21 }
22
23 override func insertText(_ text: String) {
24 super.insertText(text)
25 if text == "\n" {
26 onKeyPress?("enter")
27 }
28 self.text = ""
29 }
30 }
31
32 class Coordinator {
33 let textField = KeyboardHackTextField()
34 }
35
36 func makeCoordinator() -> Coordinator {
37 Coordinator()
38 }
39
40 func makeUIView(context: Context) -> UIView {
41 let container = UIView(frame: .zero)
42 let tf = context.coordinator.textField
43 tf.isHidden = true
44 tf.keyboardType = .default
45 tf.onKeyPress = { key in
46 LiquidTabsPlugin.shared?.notifyKeyboardHackKey(key: key)
47 }
48 container.addSubview(tf)
49 return container
50 }
51
52 func updateUIView(_ uiView: UIView, context: Context) {
53 let tf = context.coordinator.textField
…lines 54–484 unchanged (431 lines)