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,
}
/// Handles the requests of the `PolicyCheckView`.
/// Handles the requests from `PolicyCheckView`.
#[derive(AsAny, Default)]
pub struct PolicyCheckState {
action: Option<Action>,
@@ -74,7 +74,7 @@ pub struct PolicyCheckState {
policy_numbers: HashMap<u64, PolicyCode>,
progress_bar: Entity,
progress_count: f64,
theme: String
theme_name: String
}
#[cfg(not(feature = "light"))]
@@ -593,20 +593,20 @@ impl State for PolicyCheckState {
self.set_entry(entity, ctx);
}
Action::ToggleTheme(_entity) => {
if self.theme == "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}
if self.theme_name == "light" {
let theme = dark_theme();
self.theme_name = "dark".to_string();
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
@@ -632,8 +632,8 @@ impl State for PolicyCheckState {
}
}
/// Create a menu popup
fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
/// Create a menu popup
fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
Container::new()
.style("container_menu")
.width(280.0)
@@ -718,10 +718,10 @@ impl State for PolicyCheckState {
.build(ctx),
)
.build(ctx)
}
}
/// Create a progress popup with update status of an onging data import
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
/// Create a progress popup with update status of an onging data import
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
Popup::new()
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
.target(target)
@@ -768,4 +768,4 @@ impl State for PolicyCheckState {
.build(ctx)
)
.build(ctx)
}
}