stylesheets: use explicit theme name

* Cargo.toml: add feature
* policy_state.rs: add handling of feature for choosen theme
* advotracker_dark.ron: advotrackers dark theme
* advotracker_light.ron: advotrackers light theme

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-07-24 12:08:46 +02:00
parent 046812e04f
commit 33da48b1b1
5 changed files with 238 additions and 44 deletions

View File

@@ -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"

View File

@@ -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,
}
)

View File

@@ -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",
},
),
}
)

View File

@@ -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",
},
),
}
)

View File

@@ -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::<PolicyDataList>(PROP_POLICY_DATA_LIST).len();