1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5
6pub use models::*;
7
8#[cfg(desktop)]
9mod desktop;
10#[cfg(mobile)]
11mod mobile;
12
13mod commands;
14mod error;
15mod models;
16
17pub use error::{Error, Result};
18
19#[cfg(desktop)]
20use desktop::Ntb;
21#[cfg(mobile)]
22use mobile::Ntb;
23
24pub trait NtbExt<R: Runtime> {
26 fn ntb(&self) -> &Ntb<R>;
27}
28
29impl<R: Runtime, T: Manager<R>> crate::NtbExt<R> for T {
30 fn ntb(&self) -> &Ntb<R> {
31 self.state::<Ntb<R>>().inner()
32 }
33}
34
35pub fn init<R: Runtime>() -> TauriPlugin<R> {
37 Builder::new("ntb")
38 .invoke_handler(tauri::generate_handler![
39 commands::minimize,
40 commands::toggle_maximize,
41 commands::close,
42 commands::drag,
43 commands::move_by,
44 commands::get_drag_behavior,
45 commands::is_maximized,
46 commands::get_window_controls,
47 commands::get_window_control_image,
48 commands::get_title_bar_css,
49 commands::double_click_title_bar,
50 commands::right_click_title_bar,
51 commands::middle_click_title_bar,
52 commands::show_snap_overlay,
53 commands::hide_snap_overlay,
54 ])
55 .setup(|app, api| {
56 #[cfg(mobile)]
57 let ntb = mobile::init(app, api)?;
58 #[cfg(desktop)]
59 let ntb = desktop::init(app, api)?;
60 app.manage(ntb);
61 Ok(())
62 })
63 .build()
64}