Add input handling on iOS
This commit is contained in:
parent
255e5d7ff4
commit
5d2fb53510
|
@ -189,6 +189,10 @@ class BrowserWebViewController: UIViewController {
|
||||||
} else {
|
} else {
|
||||||
self.renderFallback(response: response)
|
self.renderFallback(response: response)
|
||||||
}
|
}
|
||||||
|
} else if response.status.isInput {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.showInputPrompt(response: response)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.showError(message: "Unknown error: \(response.header)")
|
self.showError(message: "Unknown error: \(response.header)")
|
||||||
|
@ -208,6 +212,20 @@ class BrowserWebViewController: UIViewController {
|
||||||
errorMessageLabel.text = message
|
errorMessageLabel.text = message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func showInputPrompt(response: GeminiResponse) {
|
||||||
|
let alert = UIAlertController(title: "Input Requested", message: response.meta, preferredStyle: .alert)
|
||||||
|
alert.addTextField { field in
|
||||||
|
field.isSecureTextEntry = response.status == .sensitiveInput
|
||||||
|
}
|
||||||
|
alert.addAction(UIAlertAction(title: "Submit", style: .default, handler: { _ in
|
||||||
|
guard var components = URLComponents(url: self.navigator.currentURL, resolvingAgainstBaseURL: false) else { return }
|
||||||
|
components.query = alert.textFields!.first!.text
|
||||||
|
self.navigator.changeURL(components.url!)
|
||||||
|
}))
|
||||||
|
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
private func renderDocument(_ doc: Document) {
|
private func renderDocument(_ doc: Document) {
|
||||||
self.document = doc
|
self.document = doc
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue