inset_services/live_text.rs
1//! Flutter counterpart: `services/live_text.dart`.
2
3use inset_foundation::App;
4
5/// Utility methods for interacting with the system's Live Text.
6///
7/// For example, the Live Text input feature of iOS turns the keyboard into a camera view for
8/// directly inserting text obtained through OCR into the active field.
9///
10/// See also:
11/// * <https://developer.apple.com/documentation/uikit/uiresponder/3778577-capturetextfromcamera>
12/// * <https://support.apple.com/guide/iphone/use-live-text-iphcf0b71b0e/ios>
13pub struct LiveText;
14
15impl LiveText {
16 /// Returns true if the Live Text input feature is available on the current device.
17 pub fn is_live_text_input_available(_app: &App) -> bool {
18 false
19 }
20
21 /// Start Live Text input.
22 ///
23 /// If any `TextInputConnection` is currently active, calling this method will tell the text field
24 /// to start Live Text input. If the current device doesn't support Live Text input,
25 /// nothing will happen.
26 pub fn start_live_text_input(_app: &App) {}
27}
28
29#[cfg(test)]
30mod tests {
31 use inset_foundation::AppCell;
32
33 use super::*;
34
35 #[test]
36 fn unsupported_defaults() {
37 let cell = AppCell::new();
38 let app = cell.borrow_mut();
39 assert!(!LiveText::is_live_text_input_available(&app));
40 LiveText::start_live_text_input(&app);
41 }
42}