tauri_plugin_material_you/
lib.rs1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Runtime,
4};
5
6pub use models::*;
7
8#[cfg(target_os = "android")]
9mod commands;
10#[cfg(target_os = "android")]
11mod mobile;
12
13mod error;
14mod models;
15
16pub use error::{Error, Result};
17
18#[cfg(target_os = "android")]
19use mobile::MaterialYou;
20
21#[cfg(target_os = "android")]
23pub trait MaterialYouExt<R: Runtime> {
24 fn material_you(&self) -> &MaterialYou<R>;
25}
26
27#[cfg(target_os = "android")]
28impl<R: Runtime, T: tauri::Manager<R>> MaterialYouExt<R> for T {
29 fn material_you(&self) -> &MaterialYou<R> {
30 self.state::<MaterialYou<R>>().inner()
31 }
32}
33
34pub fn init<R: Runtime>() -> TauriPlugin<R> {
36 let builder = Builder::new("material-you");
37
38 #[cfg(target_os = "android")]
39 let builder = builder
40 .invoke_handler(tauri::generate_handler![commands::get_material_you_colours])
41 .setup(|app, api| {
42 let material_you = mobile::init(api, app)?;
43 app.manage(material_you);
44 Ok(())
45 });
46
47 #[cfg(not(target_os = "android"))]
48 let builder = builder.setup(|_, _| Ok(()));
49
50 builder.build()
51}