feat(wallpaper): extend commands with gallery, delete image, and crop
The plugin now exposes gallery retrieval, image deletion and image crop across Android, desktop and mobile. The Rust core and Android bridge are wired to handle these commands, updating state as needed. - Add gallery, delete_image, and set_image_crop commands - across Android, desktop and mobile. - Update permissions, defaults, and schema to enable new commands.
This commit is contained in:
+25
-17
@@ -1,6 +1,6 @@
|
||||
use tauri::{
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Manager, Runtime,
|
||||
plugin::{Builder, TauriPlugin},
|
||||
Manager, Runtime,
|
||||
};
|
||||
|
||||
pub use models::*;
|
||||
@@ -23,26 +23,34 @@ use mobile::Wallpaper;
|
||||
|
||||
/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the wallpaper APIs.
|
||||
pub trait WallpaperExt<R: Runtime> {
|
||||
fn wallpaper(&self) -> &Wallpaper<R>;
|
||||
fn wallpaper(&self) -> &Wallpaper<R>;
|
||||
}
|
||||
|
||||
impl<R: Runtime, T: Manager<R>> crate::WallpaperExt<R> for T {
|
||||
fn wallpaper(&self) -> &Wallpaper<R> {
|
||||
self.state::<Wallpaper<R>>().inner()
|
||||
}
|
||||
fn wallpaper(&self) -> &Wallpaper<R> {
|
||||
self.state::<Wallpaper<R>>().inner()
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("wallpaper")
|
||||
.invoke_handler(tauri::generate_handler![commands::get_state, commands::select_images, commands::set_setting, commands::next_wallpaper])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let wallpaper = mobile::init(app, api)?;
|
||||
#[cfg(desktop)]
|
||||
let wallpaper = desktop::init(app, api)?;
|
||||
app.manage(wallpaper);
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
Builder::new("wallpaper")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::get_state,
|
||||
commands::get_gallery,
|
||||
commands::select_images,
|
||||
commands::delete_image,
|
||||
commands::set_image_crop,
|
||||
commands::set_setting,
|
||||
commands::next_wallpaper
|
||||
])
|
||||
.setup(|app, api| {
|
||||
#[cfg(mobile)]
|
||||
let wallpaper = mobile::init(app, api)?;
|
||||
#[cfg(desktop)]
|
||||
let wallpaper = desktop::init(app, api)?;
|
||||
app.manage(wallpaper);
|
||||
Ok(())
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user