tauri_plugin_theme not working
Closed this issue · 2 comments
I am quite new to rust and Tauri in general and I am not sure if I am using this plugin right. I just want to be able to dynamically change the app's theme, alongside the React theme as well. I keep getting this error and I am not sure why:
error: symbol
_EMBED_INFO_PLISTis already defined --> src/main.rs:13:17 | 13 | let mut ctx = tauri::generate_context!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro
$crate::embed_info_plist_byteswhich comes from the expansion of the macro
tauri::generate_context (in Nightly builds, run with -Z macro-backtrace for more info)
Here is what my main.rs file looks like:
`// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::Manager;
use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial};
use tauri_plugin_theme::ThemePlugin;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
fn main() {
let mut ctx = tauri::generate_context!();
tauri::Builder::default()
.plugin(ThemePlugin::init(ctx.config_mut()))
.invoke_handler(tauri::generate_handler![greet])
.setup(|app| {
let window = app.get_window("main").unwrap();
#[cfg(target_os = "macos")]
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None)
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
#[cfg(target_os = "windows")]
apply_blur(&window, Some((18, 18, 18, 125)))
.expect("Unsupported platform! 'apply_blur' is only supported on Windows");
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
`
I am using tauri_plugin_theme version "0.2.0" since I am still on tauri version= "1.5". Any assistance would be nice since I think it is a neat feature to dynamically change the whole app's theme and not just the React part only.
You are using multiple tauri::generate_context!()
Try fix it:
- .run(tauri::generate_context!())
+ .run(ctx)
.expect("error while running tauri application");
You are right!! my bad. Thank you for helping. Amazing plug-in btw