// The shell stays thin: the app is the bundled web build, local-first via its // own IndexedDB replica. The Rust side covers what the webview cannot: a LAN // sync socket and nearby-device discovery (p2p), plus on-device document // conversion in standalone mode (convert). mod convert; mod device; mod p2p; // WKWebView's scroll view adjusts its content insets by the safe areas by // default, which shrinks the page's layout viewport by the status-bar and // home-indicator heights while env(safe-area-inset-*) still reports them: // fixed elements stop ~90pt above the screen bottom and dialogs centre in the // shrunken box. Opt out; the page owns the safe areas through env(). #[cfg(target_os = "ios")] fn extend_viewport_under_system_bars(app: &tauri::App) { use objc2::msg_send; use objc2::runtime::AnyObject; use tauri::Manager; if let Some(webview) = app.get_webview_window("main") { let _ = webview.with_webview(|platform| unsafe { let wk = platform.inner() as *mut AnyObject; let scroll_view: *mut AnyObject = msg_send![&*wk, scrollView]; // UIScrollViewContentInsetAdjustmentBehavior.never let _: () = msg_send![&*scroll_view, setContentInsetAdjustmentBehavior: 2isize]; }); } } // Mobile Safari zooms the page when a field smaller than 16px takes focus. That // is expected on the web, but a native app should never zoom on focus, so pin // the webview scroll view's zoom scale to 1. This lets the inputs keep the same // compact size as the rest of the UI without the jarring focus zoom, and does // not disable the slide viewer's own in-page pinch (that runs on a CSS // transform, not the scroll view's zoom). A user who wants everything larger // bumps the interface size in Settings (the --ui-scale preference) rather than // pinch-zooming the page. #[cfg(target_os = "ios")] fn disable_input_focus_zoom(app: &tauri::App) { use objc2::msg_send; use objc2::runtime::AnyObject; use tauri::Manager; if let Some(webview) = app.get_webview_window("main") { let _ = webview.with_webview(|platform| unsafe { let wk = platform.inner() as *mut AnyObject; let scroll_view: *mut AnyObject = msg_send![&*wk, scrollView]; let _: () = msg_send![&*scroll_view, setMinimumZoomScale: 1.0f64]; let _: () = msg_send![&*scroll_view, setMaximumZoomScale: 1.0f64]; }); } } #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_websocket::init()) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_fs::init()) .manage(p2p::P2pState::default()) .invoke_handler(tauri::generate_handler![ p2p::p2p_peers, p2p::p2p_info, p2p::p2p_send, convert::convert_to_pdf, convert::converter_status ]) .setup(|app| { let handle = app.handle().clone(); tauri::async_runtime::spawn(p2p::start(handle)); #[cfg(target_os = "ios")] { extend_viewport_under_system_bars(app); disable_input_focus_zoom(app); } Ok(()) }) .build(tauri::generate_context!()) .expect("error while building the tauri application") .run(|_app, event| { // Tell peers we're leaving so they drop us immediately. if let tauri::RunEvent::Exit = event { p2p::deannounce_mdns(); } }); }