callbacks/policycheck_state: update theme, popup

* popup handling update
* handling of themes

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-08-22 19:02:18 +02:00
parent 3697bc567a
commit 70e2e7f1e5

View File

@@ -59,7 +59,7 @@ struct Environment {
rust_log: String, rust_log: String,
} }
/// Handles the requests of the `PolicyCheckView`. /// Handles the requests from `PolicyCheckView`.
#[derive(AsAny, Default)] #[derive(AsAny, Default)]
pub struct PolicyCheckState { pub struct PolicyCheckState {
action: Option<Action>, action: Option<Action>,
@@ -74,7 +74,7 @@ pub struct PolicyCheckState {
policy_numbers: HashMap<u64, PolicyCode>, policy_numbers: HashMap<u64, PolicyCode>,
progress_bar: Entity, progress_bar: Entity,
progress_count: f64, progress_count: f64,
theme: String theme_name: String
} }
#[cfg(not(feature = "light"))] #[cfg(not(feature = "light"))]
@@ -593,20 +593,20 @@ impl State for PolicyCheckState {
self.set_entry(entity, ctx); self.set_entry(entity, ctx);
} }
Action::ToggleTheme(_entity) => { Action::ToggleTheme(_entity) => {
if self.theme == "light" { if self.theme_name == "light" {
self.theme = "dark_theme".to_string();
} else {
self.theme = "light_theme".to_string();
}
//match &self.theme {
// light => { self.theme = "dark_theme".to_string(); }
// dark => { self.theme = "light_theme".to_string(); }
// _ => { debug!(target: "advotracker", "theme not supported!"); }
// }
println!{"Switch theme to {:?}", self.theme}
let theme = dark_theme(); let theme = dark_theme();
self.theme_name = "dark".to_string();
ctx.switch_theme(theme); ctx.switch_theme(theme);
} }
if self.theme_name == "dark" {
let theme = light_theme();
self.theme_name = "light".to_string();
ctx.switch_theme(theme);
};
println!{"Switch theme to {:?}", self.theme_name};
}
} }
} }
// Reset action // Reset action