tauri_plugin_system_components/
lib.rs1use tauri::{
11 plugin::{Builder, TauriPlugin},
12 Manager, Runtime,
13};
14
15pub use models::*;
16
17#[cfg(desktop)]
18mod desktop;
19#[cfg(mobile)]
20mod mobile;
21
22mod commands;
23mod error;
24mod models;
25
26pub use error::{Error, Result};
27
28#[cfg(desktop)]
29use desktop::SystemComponents;
30#[cfg(mobile)]
31use mobile::SystemComponents;
32
33pub trait SystemComponentsExt<R: Runtime> {
35 fn system_components(&self) -> &SystemComponents<R>;
36}
37
38impl<R: Runtime, T: Manager<R>> crate::SystemComponentsExt<R> for T {
39 fn system_components(&self) -> &SystemComponents<R> {
40 self.state::<SystemComponents<R>>().inner()
41 }
42}
43
44pub fn init<R: Runtime>() -> TauriPlugin<R> {
50 Builder::new("system-components")
51 .invoke_handler(tauri::generate_handler![
52 commands::configure_tab_bar,
53 commands::remove_tab_bar,
54 commands::show_tab_bar,
55 commands::hide_tab_bar,
56 commands::select_tab,
57 commands::set_badge,
58 commands::get_tab_bar_insets,
59 commands::present_sheet,
60 commands::dismiss_sheet,
61 commands::create_component,
62 commands::update_component,
63 commands::update_components,
64 commands::remove_component,
65 commands::is_glass_supported,
66 commands::set_window_glass,
67 commands::clear_window_glass,
68 ])
69 .setup(|app, api| {
70 #[cfg(mobile)]
71 let system_components = mobile::init(app, api)?;
72 #[cfg(desktop)]
73 let system_components = desktop::init(app, api)?;
74 app.manage(system_components);
75 Ok(())
76 })
77 .build()
78}