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:
+42
-13
@@ -1,7 +1,7 @@
|
||||
use serde::de::DeserializeOwned;
|
||||
use tauri::{
|
||||
plugin::{PluginApi, PluginHandle},
|
||||
AppHandle, Runtime,
|
||||
plugin::{PluginApi, PluginHandle},
|
||||
AppHandle, Runtime,
|
||||
};
|
||||
|
||||
use crate::models::*;
|
||||
@@ -11,22 +11,51 @@ tauri::ios_plugin_binding!(init_plugin_wallpaper);
|
||||
|
||||
// initializes the Kotlin or Swift plugin classes
|
||||
pub fn init<R: Runtime, C: DeserializeOwned>(
|
||||
_app: &AppHandle<R>,
|
||||
api: PluginApi<R, C>,
|
||||
_app: &AppHandle<R>,
|
||||
api: PluginApi<R, C>,
|
||||
) -> crate::Result<Wallpaper<R>> {
|
||||
#[cfg(target_os = "android")]
|
||||
let handle = api.register_android_plugin("de.wechselbild.wallpaper", "WallpaperPlugin")?;
|
||||
#[cfg(target_os = "ios")]
|
||||
let handle = api.register_ios_plugin(init_plugin_wallpaper)?;
|
||||
Ok(Wallpaper(handle))
|
||||
#[cfg(target_os = "android")]
|
||||
let handle = api.register_android_plugin("de.wechselbild.wallpaper", "WallpaperPlugin")?;
|
||||
#[cfg(target_os = "ios")]
|
||||
let handle = api.register_ios_plugin(init_plugin_wallpaper)?;
|
||||
Ok(Wallpaper(handle))
|
||||
}
|
||||
|
||||
/// Access to the wallpaper APIs.
|
||||
pub struct Wallpaper<R: Runtime>(PluginHandle<R>);
|
||||
|
||||
impl<R: Runtime> Wallpaper<R> {
|
||||
pub fn get_state(&self) -> crate::Result<WallpaperState> { self.0.run_mobile_plugin("getState", ()).map_err(Into::into) }
|
||||
pub fn select_images(&self) -> crate::Result<WallpaperState> { self.0.run_mobile_plugin("selectImages", ()).map_err(Into::into) }
|
||||
pub fn set_setting(&self, payload: SettingRequest) -> crate::Result<WallpaperState> { self.0.run_mobile_plugin("setSetting", payload).map_err(Into::into) }
|
||||
pub fn next_wallpaper(&self) -> crate::Result<WallpaperState> { self.0.run_mobile_plugin("nextWallpaper", ()).map_err(Into::into) }
|
||||
pub fn get_state(&self) -> crate::Result<WallpaperState> {
|
||||
self.0.run_mobile_plugin("getState", ()).map_err(Into::into)
|
||||
}
|
||||
pub fn get_gallery(&self, payload: GalleryRequest) -> crate::Result<GalleryPage> {
|
||||
self.0
|
||||
.run_mobile_plugin("getGallery", payload)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
pub fn select_images(&self) -> crate::Result<WallpaperState> {
|
||||
self.0
|
||||
.run_mobile_plugin("selectImages", ())
|
||||
.map_err(Into::into)
|
||||
}
|
||||
pub fn delete_image(&self, payload: DeleteImageRequest) -> crate::Result<WallpaperState> {
|
||||
self.0
|
||||
.run_mobile_plugin("deleteImage", payload)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
pub fn set_image_crop(&self, payload: ImageCropRequest) -> crate::Result<GalleryImage> {
|
||||
self.0
|
||||
.run_mobile_plugin("setImageCrop", payload)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
pub fn set_setting(&self, payload: SettingRequest) -> crate::Result<WallpaperState> {
|
||||
self.0
|
||||
.run_mobile_plugin("setSetting", payload)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
pub fn next_wallpaper(&self) -> crate::Result<WallpaperState> {
|
||||
self.0
|
||||
.run_mobile_plugin("nextWallpaper", ())
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user