#![cfg(mobile)]
use tauri::{
plugin::{Builder, TauriPlugin},
Manager, Runtime,
};
pub use models::*;
mod commands;
mod error;
mod mobile;
mod models;
pub use error::{Error, Result};
use mobile::Healthkit;
pub trait HealthkitExt<R: Runtime> {
fn healthkit(&self) -> &Healthkit<R>;
}
impl<R: Runtime, T: Manager<R>> crate::HealthkitExt<R> for T {
fn healthkit(&self) -> &Healthkit<R> {
self.state::<Healthkit<R>>().inner()
}
}
pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("healthkit")
.invoke_handler(tauri::generate_handler![
commands::request_permissions,
commands::check_permissions,
commands::get_status,
commands::open_settings,
commands::open_play_store,
commands::get_step,
commands::get_sleep,
commands::get_weight,
])
.setup(|app, api| {
let healthkit = mobile::init(app, api)?;
app.manage(healthkit);
Ok(())
})
.build()
}