feat(setup): bootstrap Android plugin and web UI
This initial commit adds a multi-part scaffold for Wechselbild, including a web UI and an Android plugin. It introduces frontend assets and a package.json-based dev setup, plus plugin scaffolding for Android with Kotlin sources and Cargo.toml for the Tauri plugin. - Adds Android wallpaper plugin with Kotlin sources and manifest - Includes web UI scaffold with index.html and package.json - Adds Tauri plugin scaffold with Cargo.toml and build config
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export type WallpaperState = {
|
||||
imageCount: number;
|
||||
enabled: boolean;
|
||||
shuffle: boolean;
|
||||
lockScreenOnly: boolean;
|
||||
currentIndex: number;
|
||||
imageUrls: string[];
|
||||
};
|
||||
|
||||
const demoState: WallpaperState = {
|
||||
imageCount: 3,
|
||||
enabled: true,
|
||||
shuffle: true,
|
||||
lockScreenOnly: true,
|
||||
currentIndex: 0,
|
||||
imageUrls: ["/wallpapers/alpine.png", "/wallpapers/waterfall.png", "/wallpapers/coast.png"],
|
||||
};
|
||||
|
||||
const inTauri = () => "__TAURI_INTERNALS__" in window;
|
||||
|
||||
export async function getState(): Promise<WallpaperState> {
|
||||
return inTauri() ? invoke<WallpaperState>("plugin:wallpaper|get_state") : demoState;
|
||||
}
|
||||
|
||||
export async function selectImages(): Promise<WallpaperState> {
|
||||
if (!inTauri()) return demoState;
|
||||
return invoke<WallpaperState>("plugin:wallpaper|select_images");
|
||||
}
|
||||
|
||||
export async function setSetting(name: "enabled" | "shuffle" | "lockScreenOnly", value: boolean) {
|
||||
if (!inTauri()) return { ...demoState, [name]: value };
|
||||
return invoke<WallpaperState>("plugin:wallpaper|set_setting", { name, value });
|
||||
}
|
||||
|
||||
export async function nextWallpaper(): Promise<WallpaperState> {
|
||||
if (!inTauri()) {
|
||||
demoState.currentIndex = (demoState.currentIndex + 1) % demoState.imageUrls.length;
|
||||
return { ...demoState };
|
||||
}
|
||||
return invoke<WallpaperState>("plugin:wallpaper|next_wallpaper");
|
||||
}
|
||||
Reference in New Issue
Block a user