frontend: example: introduce new 'policyholder_check'
* helper function to test validity of given policynumber - use a hashmap as a reference store with valid policynumbers - check the given policynumber against the reference Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
use orbtk::prelude::*;
|
||||
use orbtk::theme::DEFAULT_THEME_CSS;
|
||||
//use orbtk::theme::LIGHT_THEME_EXTENSION_CSS;
|
||||
|
||||
static WIDGET_EXT: &'static str = include_str!("../resources/stylesheets/policyholder-check.css");
|
||||
//#[cfg(feature = "light-theme")]
|
||||
static WIDGET_EXT: &'static str = include_str!("../resources/stylesheets/policyholder_check.css");
|
||||
|
||||
fn get_theme() -> ThemeValue {
|
||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||
.extension_css(WIDGET_EXT)
|
||||
.build()
|
||||
@@ -11,10 +14,12 @@ fn get_theme() -> ThemeValue {
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
enum Action {
|
||||
//ClearText,
|
||||
ClearText,
|
||||
EntryActivated(Entity),
|
||||
EntryChanged(Entity),
|
||||
//ValueChanged(Entity),
|
||||
ValueOk,
|
||||
ValueNone,
|
||||
}
|
||||
|
||||
#[derive(AsAny)]
|
||||
@@ -38,13 +43,25 @@ impl State for MainViewState {
|
||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||
if let Some(action) = self.action {
|
||||
match action {
|
||||
// Action::ClearText => {
|
||||
// ctx.widget().set("policynumber", String16::from(""));
|
||||
// }
|
||||
Action::ClearText => {
|
||||
ctx.widget().set("policynumber", String16::from(""));
|
||||
}
|
||||
Action::ValueOk => {
|
||||
//let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||
//let text = text_box.text_mut();
|
||||
//ctx.widget().set("policynumber", background("#4d4c4c"));
|
||||
}
|
||||
Action::ValueNone => {
|
||||
//let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||
//let text = text_box.text_mut();
|
||||
//ctx.widget().set("policynumber", background("#5b0f22"));
|
||||
}
|
||||
Action::EntryActivated(entity) => {
|
||||
let mut widget = ctx.get_widget(entity);
|
||||
let text = widget.get_mut::<String16>("text");
|
||||
println!("submitting {}", text);
|
||||
let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||
let text = text_box.text_mut();
|
||||
//let mut widget = ctx.get_widget(entity);
|
||||
//let text = widget.get_mut::<String16>("text");
|
||||
println!("got value policynumber: {}", text);
|
||||
//text.clear();
|
||||
}
|
||||
Action::EntryChanged(entity) => {
|
||||
@@ -87,32 +104,30 @@ impl Template for MainView {
|
||||
//.result("Policyholders count: 0").sum_policynumbers(0)
|
||||
//.sum_policynumbers(0)
|
||||
Grid::new()
|
||||
.background("#fafafa")
|
||||
//.width(200.0)
|
||||
//.height(360.0)
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(200.0)
|
||||
.add(150.0)
|
||||
.add("*")
|
||||
//.add(120.0)
|
||||
.add(200.0)
|
||||
//.add("auto")
|
||||
.add(150.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
//.add("auto")
|
||||
//.add(150.0)
|
||||
//.add(200.0)
|
||||
.add("*")
|
||||
.add("*")
|
||||
.build(),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("policholder_check")
|
||||
.background("fafafa")
|
||||
.margin((4.0, 24.0, 4.0, 4.0))
|
||||
.min_width(80.0)
|
||||
.min_height(180.0)
|
||||
.element("policyholder_check")
|
||||
.margin((4.0, 24.0, 24.0, 4.0))
|
||||
.min_width(180.0)
|
||||
.min_height(80.0)
|
||||
.attach(Grid::column(1))
|
||||
.attach(Grid::row(0))
|
||||
.child(
|
||||
@@ -124,11 +139,22 @@ impl Template for MainView {
|
||||
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
||||
.child(
|
||||
TextBox::new()
|
||||
.class("text_box")
|
||||
//.class("text_box")
|
||||
// overwriting the class defaults
|
||||
/* .background("transparent")
|
||||
.foreground("#9dafbf")
|
||||
.background("#fafafa")
|
||||
/* .foreground(colors::LINK_WATER_COLOR) */
|
||||
.border_brush("#5b0f22")
|
||||
.border_width(5)
|
||||
.border_radius(15) */
|
||||
//.name("policynumber")
|
||||
.focused(true)
|
||||
.water_mark("Versicherungs-Nr...")
|
||||
//.text("Number policyholder", id)
|
||||
.text(("policynumber", id))
|
||||
.font_size(24.0)
|
||||
.h_align("stretch")
|
||||
.on_activate(move |states, entity| {
|
||||
state(id, states).action(Action::EntryActivated(entity));
|
||||
})
|
||||
@@ -154,14 +180,13 @@ impl Template for MainView {
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_customer")
|
||||
.margin((4.0, 0.0, 0.0, 4.0))
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.v_align("end")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("../resources/images/hiedemann_logo.png")
|
||||
//.h_align("center")
|
||||
//.v_align("bottom")
|
||||
.image("./resources/images/hiedemann_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
@@ -169,16 +194,13 @@ impl Template for MainView {
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_vendor")
|
||||
.margin((4.0, 0.0, 0.0, 4.0))
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(2))
|
||||
.attach(Grid::row(1))
|
||||
//.v_align("bottom")
|
||||
.v_align("end")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
//.image("../resources/images/networkx_logo.jpg")
|
||||
.image("../resources/images/networkx_logo.png")
|
||||
//.h_align("center")
|
||||
//.v_align("bottom")
|
||||
.image("./resources/images/networkx_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
@@ -193,14 +215,14 @@ fn main() {
|
||||
.window(|ctx| {
|
||||
Window::new()
|
||||
//.title("OrbTk - Policyholder checker example")
|
||||
.name("MainWindow")
|
||||
.title("AdvoTracker - Versicherungsnummern")
|
||||
.position((-500.0, -100.0))
|
||||
.size(480.0, 360.0)
|
||||
.min_width(80.0)
|
||||
.size(480.0, 260.0)
|
||||
.min_width(460.0)
|
||||
.min_height(180.0)
|
||||
.resizeable(true)
|
||||
//.theme(get_theme())
|
||||
.background("#fafafa")
|
||||
.theme(get_theme())
|
||||
.child(MainView::new().build(ctx))
|
||||
.build(ctx)
|
||||
})
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 71 KiB |
Reference in New Issue
Block a user