use std::path::PathBuf; use tauri::{command, AppHandle, Runtime, State}; use crate::models::*; use crate::DirectoryCallbackState; use crate::NativeBridgeExt; use crate::Result; #[command] pub(crate) async fn auth_with_safari( app: AppHandle, payload: AuthRequest, ) -> Result { app.native_bridge().auth_with_safari(payload) } #[command] pub(crate) async fn auth_with_custom_tab( app: AppHandle, payload: AuthRequest, ) -> Result { app.native_bridge().auth_with_custom_tab(payload) } #[command] pub(crate) async fn copy_uri_to_path( app: AppHandle, payload: CopyURIRequest, ) -> Result { app.native_bridge().copy_uri_to_path(payload) } #[command] pub(crate) async fn use_background_audio( app: AppHandle, payload: UseBackgroundAudioRequest, ) -> Result<()> { app.native_bridge().use_background_audio(payload) } #[command] pub(crate) async fn install_package( app: AppHandle, payload: InstallPackageRequest, ) -> Result { app.native_bridge().install_package(payload) } #[command] pub(crate) async fn set_system_ui_visibility( app: AppHandle, payload: SetSystemUIVisibilityRequest, ) -> Result { app.native_bridge().set_system_ui_visibility(payload) } #[command] pub(crate) async fn get_status_bar_height( app: AppHandle, ) -> Result { app.native_bridge().get_status_bar_height() } #[command] pub(crate) async fn get_sys_fonts_list( app: AppHandle, ) -> Result { app.native_bridge().get_sys_fonts_list() } #[command] pub(crate) async fn intercept_keys( app: AppHandle, payload: InterceptKeysRequest, ) -> Result<()> { app.native_bridge().intercept_keys(payload) } #[command] pub(crate) async fn lock_screen_orientation( app: AppHandle, payload: LockScreenOrientationRequest, ) -> Result<()> { app.native_bridge().lock_screen_orientation(payload) } #[command] pub(crate) async fn iap_is_available( app: AppHandle, ) -> Result { app.native_bridge().iap_is_available() } #[command] pub(crate) async fn iap_initialize( app: AppHandle, payload: IAPInitializeRequest, ) -> Result { app.native_bridge().iap_initialize(payload) } #[command] pub(crate) async fn iap_fetch_products( app: AppHandle, payload: IAPFetchProductsRequest, ) -> Result { app.native_bridge().iap_fetch_products(payload) } #[command] pub(crate) async fn iap_purchase_product( app: AppHandle, payload: IAPPurchaseProductRequest, ) -> Result { app.native_bridge().iap_purchase_product(payload) } #[command] pub(crate) async fn iap_restore_purchases( app: AppHandle, ) -> Result { app.native_bridge().iap_restore_purchases() } #[command] pub(crate) async fn get_system_color_scheme( app: AppHandle, ) -> Result { app.native_bridge().get_system_color_scheme() } #[command] pub(crate) async fn get_safe_area_insets( app: AppHandle, ) -> Result { app.native_bridge().get_safe_area_insets() } #[command] pub(crate) async fn get_screen_brightness( app: AppHandle, ) -> Result { app.native_bridge().get_screen_brightness() } #[command] pub(crate) async fn set_screen_brightness( app: AppHandle, payload: SetScreenBrightnessRequest, ) -> Result { app.native_bridge().set_screen_brightness(payload) } #[command] pub(crate) async fn get_external_sdcard_path( app: AppHandle, ) -> Result { app.native_bridge().get_external_sdcard_path() } #[command] pub(crate) async fn open_external_url( app: AppHandle, payload: OpenExternalUrlRequest, ) -> Result { app.native_bridge().open_external_url(payload) } #[command] pub(crate) async fn select_directory( app: AppHandle, callback_state: State<'_, DirectoryCallbackState>, ) -> Result { let result = app.native_bridge().select_directory()?; if let Some(dir_path) = &result.path { let path = PathBuf::from(dir_path); if let Ok(callback_guard) = callback_state.callback.lock() { if let Some(callback) = callback_guard.as_ref() { callback(&app, &path); } } } Ok(result) } #[command] pub(crate) async fn get_storefront_region_code( app: AppHandle, ) -> Result { app.native_bridge().get_storefront_region_code() } #[command] pub(crate) async fn request_manage_storage_permission( app: AppHandle, ) -> Result { app.native_bridge().request_manage_storage_permission() }