|
1
|
use tauri::{ |
|
2
|
plugin::{Builder, TauriPlugin}, |
|
3
|
Manager, Runtime, |
|
4
|
}; |
|
5
|
|
|
6
|
pub use models::*; |
|
7
|
|
|
8
|
#[cfg(desktop)] |
|
9
|
mod desktop; |
|
10
|
#[cfg(mobile)] |
|
11
|
mod mobile; |
|
12
|
|
|
13
|
mod commands; |
|
14
|
mod error; |
|
15
|
mod models; |
|
16
|
|
|
17
|
pub use error::{Error, Result}; |
|
18
|
|
|
19
|
#[cfg(desktop)] |
|
20
|
use desktop::TauriPluginIosWindow; |
|
21
|
#[cfg(mobile)] |
|
22
|
use mobile::TauriPluginIosWindow; |
|
23
|
|
|
24
|
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the tauri-plugin-ios-window APIs. |
|
25
|
pub trait TauriPluginIosWindowExt<R: Runtime> { |
|
26
|
fn tauri_plugin_ios_window(&self) -> &TauriPluginIosWindow<R>; |
|
27
|
} |
|
28
|
|
|
29
|
impl<R: Runtime, T: Manager<R>> crate::TauriPluginIosWindowExt<R> for T { |
|
30
|
fn tauri_plugin_ios_window(&self) -> &TauriPluginIosWindow<R> { |
|
31
|
self.state::<TauriPluginIosWindow<R>>().inner() |
|
32
|
} |
|
33
|
} |
|
34
|
|
|
35
|
/// Initializes the plugin. |
|
36
|
pub fn init<R: Runtime>() -> TauriPlugin<R> { |
|
37
|
Builder::new("ios-window") |
|
38
|
.invoke_handler(tauri::generate_handler![commands::open, commands::close]) |
|
39
|
.setup(|app, api| { |
|
40
|
#[cfg(mobile)] |
|
41
|
let tauri_plugin_ios_window = mobile::init(app, api)?; |
|
42
|
#[cfg(desktop)] |
|
43
|
let tauri_plugin_ios_window = desktop::init(app, api)?; |
|
44
|
app.manage(tauri_plugin_ios_window); |
|
45
|
Ok(()) |
|
46
|
}) |
|
47
|
.build() |
|
48
|
} |