diff --git a/advotracker/Cargo.toml b/advotracker/Cargo.toml index 3e7ecb1..a1d534b 100644 --- a/advotracker/Cargo.toml +++ b/advotracker/Cargo.toml @@ -38,7 +38,8 @@ viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cach [features] # no features by default default = [] -testing = ["orbtk/debug"] +debug = ["orbtk/debug"] +light = [] [package.metadata.bundle] name = "advotracker" diff --git a/advotracker/resources/stylesheets/advotracker.ron b/advotracker/resources/stylesheets/advotracker.ron deleted file mode 100644 index 6c7e54b..0000000 --- a/advotracker/resources/stylesheets/advotracker.ron +++ /dev/null @@ -1,42 +0,0 @@ -Theme ( - styles: { - "base": ( - properties: { - "font_size": "$FONT_SIZE_12", - "font_family": "$MEDIUM_FONT", - } - ), - "button": ( - base: "base", - properties: { - "background": "$BLACK", - }, - states: { - "pressed": { - "background": "$WHITE", - } - } - ), - "menu": ( - base: "base", - properties: { - "font_size": "$FONT_SIZE_10", - "font_family": "$MEDIUM_FONT", - "background": "$BLACK", - }, - states: { - "pressed": { - "background": "$WHITE", - } - } - ) - } - resource: { - "BLACK": "#000000", - "WHITE": "#ffffff", - "MEDIUM_FONT": "Roboto Medium", - "FONT_SIZE_10": 10, - "FONT_SIZE_12": 12, - "FONT_SIZE_16": 16, - } -) \ No newline at end of file diff --git a/advotracker/resources/stylesheets/advotracker_dark.ron b/advotracker/resources/stylesheets/advotracker_dark.ron new file mode 100644 index 0000000..ae38121 --- /dev/null +++ b/advotracker/resources/stylesheets/advotracker_dark.ron @@ -0,0 +1,113 @@ +Theme ( + styles: { + "button_menu": ( + base: "menu", + properties: { + "background": "transparent", + //"background": "$GOLDEN_DREAM", + //"background": "$LINK_WATER", + //"border_brush": "$LINK_WATER", + //"border_brush": "$GOLDEN_DREAM", + "border_radius": 0, + "border_width": 0, + //"foreground": "$BRIGHT_GRAY", + //"icon_brush": "$BRIGHT_GRAY", + "font_size": "$ICON_SIZE_16", + "h_align": "left", + //"height": 14, + "margin": (0, 4, 0, 0), + //"padding": (8, 0, 8, 0), + }, + ), + "container_menu": ( + properties: { + "border_radius": 0, + "border_width": 1, + "background": "$BRIGHT_GRAY", + "border_brush": "$LINK_WATER", + //"border_brush": "$GOLDEN_DREAM", + "padding": 4, + }, + ), + "container_progress": ( + properties: { + "border_radius": 3, + "border_width": 1, + "background": "$BRIGHT_GRAY", + "border_brush": "$LINK_WATER", + //"border_brush": "$GOLDEN_DREAM", + "padding": 14, + "h_align": "end" + }, + ), + "container_form": ( + base: "container", + properties: { + "background": "$BRIGHT_GRAY", + "border_brush": "$LINK_WATER", + "border_radius": 3, + "border_width": 1, + "padding": 14, + "v_align": "top", + }, + ), + "header_bar": ( + base: "header", + properties: { + "foreground": "$LINK_WATER", + }, + ), + "menu": ( + //base: "base", + properties: { + "font_size": 16, + "font_family": "$MEDIUM_FONT", + "background": "$BLACK", + "opacity": 1, + }, + states: { + "pressed": { + "background": "$WHITE", + }, + }, + ), + "popup_progress": ( + base: "popup", + properties: { + //"h_align": "center", + "width": 300, + "heigth": 120, + }, + ), + "stack_menu": ( + properties: { + //"background": "transparent", + "spacing": 2, + "orientation": "vertical", + "h_align": "left", + }, + ), + "stack_progress": ( + properties: { + //"background": "transparent", + "spacing": 8, + "margin": (16, 16, 16, 16), + }, + ), + "textblock": ( + //base: "base", + properties: { + "font_size": "$ICON_SIZE_12", + }, + ), + "textblock_progress": ( + base: "textblock", + properties: { + //"background": "transparent", + //"font_size": 12, + "h_align": "center", + "v_align": "center", + }, + ), + } +) \ No newline at end of file diff --git a/advotracker/resources/stylesheets/advotracker_light.ron b/advotracker/resources/stylesheets/advotracker_light.ron new file mode 100644 index 0000000..0fe5c91 --- /dev/null +++ b/advotracker/resources/stylesheets/advotracker_light.ron @@ -0,0 +1,100 @@ +Theme ( + styles: { + "button_menu": ( + base: "menu", + properties: { + "background": "transparent", + "border_radius": 0, + "border_width": 0, + "font_size": "$ICON_SIZE_16", + "h_align": "left", + "margin": (0, 4, 0, 0), + }, + ), + "container_menu": ( + properties: { + "border_radius": 0, + "border_width": 1, + "background": "$BRIGHT_GRAY", + "border_brush": "$LINK_WATER", + "padding": 4, + }, + ), + "container_progress": ( + properties: { + "border_radius": 3, + "border_width": 1, + "background": "$BRIGHT_GRAY", + "border_brush": "$LINK_WATER", + "padding": 14, + "h_align": "end", + }, + ), + "container_form": ( + base: "container", + properties: { + "background": "$GRAY_NURSE", + "border_brush": "$LINK_WATER", + "border_radius": 3, + "border_width": 1, + "padding": 14, + "v_align": "top", + }, + ), + "header_bar": ( + base: "header", + properties: { + "background": "$GRAY_NURSE", + "foreground": "$BRIGHT_GRAY", + }, + ), + "menu": ( + //base: "base", + properties: { + "font_size": 16, + "font_family": "$MEDIUM_FONT", + "background": "$GRAY_NURSE", + "opacity": 1, + "foreground": "$BRIGHT_GRAY", + }, + states: { + "pressed": { + "background": "$WHITE", + }, + }, + ), + "popup_progress": ( + base: "popup", + properties: { + "width": 300, + "heigth": 120, + }, + ), + "stack_menu": ( + properties: { + "spacing": 2, + "orientation": "vertical", + "h_align": "left", + }, + ), + "stack_progress": ( + properties: { + "spacing": 8, + "margin": (16, 16, 16, 16), + }, + ), + "textblock": ( + //base: "base", + properties: { + "font_size": "$ICON_SIZE_12", + }, + ), + "textblock_progress": ( + base: "textblock", + properties: { + "h_align": "center", + "v_align": "center", + }, + ), + } +) \ No newline at end of file diff --git a/advotracker/src/callbacks/policycheck_state.rs b/advotracker/src/callbacks/policycheck_state.rs index ca76689..f5e2f3a 100644 --- a/advotracker/src/callbacks/policycheck_state.rs +++ b/advotracker/src/callbacks/policycheck_state.rs @@ -4,9 +4,16 @@ use locales::t; use orbtk::{ prelude::*, shell::WindowRequest, - theme::{COLORS_RON, DARK_THEME_RON, FONTS_RON}, + theme::{COLORS_RON, FONTS_RON}, theming::config::ThemeConfig, }; + +#[cfg(not(feature = "light"))] +use orbtk::theme::DARK_THEME_RON; + +#[cfg(feature = "light")] +use orbtk::theme::LIGHT_THEME_RON; + use serde::Deserialize; use std::{env, process}; use std::collections::HashMap; @@ -70,8 +77,12 @@ pub struct PolicyCheckState { theme: String } +#[cfg(not(feature = "light"))] static DARK_EXT: &'static str = include_str!("../../resources/stylesheets/advotracker_dark.ron"); +#[cfg(feature = "light")] +static LIGHT_EXT: &'static str = include_str!("../../resources/stylesheets/advotracker_light.ron"); + impl GlobalState for PolicyCheckState {} /// method definitions, that react on any given state change inside the view @@ -403,6 +414,7 @@ impl PolicyCheckState { /// Set and activate the theme attributes. + #[cfg(not(feature = "light"))] pub fn theme() -> Theme { Theme::from_config( // sourcing: crates/theme/assets/dark/dark.ron @@ -413,6 +425,16 @@ impl PolicyCheckState { ) } + #[cfg(feature = "light")] + pub fn theme() -> Theme { + Theme::from_config( + ThemeConfig::from(LIGHT_THEME_RON) + .extend(ThemeConfig::from(LIGHT_EXT)) + .extend(ThemeConfig::from(COLORS_RON)) + .extend(ThemeConfig::from(FONTS_RON)), + ) + } + /// Update count of elements in the policy data list. fn _update_data_count(&self, ctx: &mut Context<'_>) { let data_list_count = ctx.widget().get::(PROP_POLICY_DATA_LIST).len();