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:
+54
-5
@@ -1,10 +1,59 @@
|
||||
use tauri::{AppHandle, command, Runtime};
|
||||
use tauri::{command, AppHandle, Runtime};
|
||||
|
||||
use crate::models::*;
|
||||
use crate::Result;
|
||||
use crate::WallpaperExt;
|
||||
|
||||
#[command] pub(crate) async fn get_state<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> { app.wallpaper().get_state() }
|
||||
#[command] pub(crate) async fn select_images<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> { app.wallpaper().select_images() }
|
||||
#[command] pub(crate) async fn set_setting<R: Runtime>(app: AppHandle<R>, name: String, value: bool) -> Result<WallpaperState> { app.wallpaper().set_setting(SettingRequest { name, value }) }
|
||||
#[command] pub(crate) async fn next_wallpaper<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> { app.wallpaper().next_wallpaper() }
|
||||
#[command]
|
||||
pub(crate) async fn get_state<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
|
||||
app.wallpaper().get_state()
|
||||
}
|
||||
#[command]
|
||||
pub(crate) async fn get_gallery<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
offset: usize,
|
||||
limit: usize,
|
||||
) -> Result<GalleryPage> {
|
||||
app.wallpaper()
|
||||
.get_gallery(GalleryRequest { offset, limit })
|
||||
}
|
||||
#[command]
|
||||
pub(crate) async fn select_images<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
|
||||
app.wallpaper().select_images()
|
||||
}
|
||||
#[command]
|
||||
pub(crate) async fn delete_image<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
id: String,
|
||||
) -> Result<WallpaperState> {
|
||||
app.wallpaper().delete_image(DeleteImageRequest { id })
|
||||
}
|
||||
#[command]
|
||||
pub(crate) async fn set_image_crop<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
id: String,
|
||||
mode: String,
|
||||
zoom: f64,
|
||||
position_x: f64,
|
||||
position_y: f64,
|
||||
) -> Result<GalleryImage> {
|
||||
app.wallpaper().set_image_crop(ImageCropRequest {
|
||||
id,
|
||||
mode,
|
||||
zoom,
|
||||
position_x,
|
||||
position_y,
|
||||
})
|
||||
}
|
||||
#[command]
|
||||
pub(crate) async fn set_setting<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
name: String,
|
||||
value: bool,
|
||||
) -> Result<WallpaperState> {
|
||||
app.wallpaper().set_setting(SettingRequest { name, value })
|
||||
}
|
||||
#[command]
|
||||
pub(crate) async fn next_wallpaper<R: Runtime>(app: AppHandle<R>) -> Result<WallpaperState> {
|
||||
app.wallpaper().next_wallpaper()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user