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::prelude::*;
|
||||||
use orbtk::theme::DEFAULT_THEME_CSS;
|
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 {
|
fn get_theme() -> ThemeValue {
|
||||||
|
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||||
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||||
.extension_css(WIDGET_EXT)
|
.extension_css(WIDGET_EXT)
|
||||||
.build()
|
.build()
|
||||||
@@ -11,10 +14,12 @@ fn get_theme() -> ThemeValue {
|
|||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
enum Action {
|
enum Action {
|
||||||
//ClearText,
|
ClearText,
|
||||||
EntryActivated(Entity),
|
EntryActivated(Entity),
|
||||||
EntryChanged(Entity),
|
EntryChanged(Entity),
|
||||||
//ValueChanged(Entity),
|
//ValueChanged(Entity),
|
||||||
|
ValueOk,
|
||||||
|
ValueNone,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(AsAny)]
|
#[derive(AsAny)]
|
||||||
@@ -38,13 +43,25 @@ impl State for MainViewState {
|
|||||||
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
fn update(&mut self, _: &mut Registry, ctx: &mut Context<'_>) {
|
||||||
if let Some(action) = self.action {
|
if let Some(action) = self.action {
|
||||||
match action {
|
match action {
|
||||||
// Action::ClearText => {
|
Action::ClearText => {
|
||||||
// ctx.widget().set("policynumber", String16::from(""));
|
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) => {
|
Action::EntryActivated(entity) => {
|
||||||
let mut widget = ctx.get_widget(entity);
|
let mut text_box = TextBox::get(ctx.get_widget(entity));
|
||||||
let text = widget.get_mut::<String16>("text");
|
let text = text_box.text_mut();
|
||||||
println!("submitting {}", text);
|
//let mut widget = ctx.get_widget(entity);
|
||||||
|
//let text = widget.get_mut::<String16>("text");
|
||||||
|
println!("got value policynumber: {}", text);
|
||||||
//text.clear();
|
//text.clear();
|
||||||
}
|
}
|
||||||
Action::EntryChanged(entity) => {
|
Action::EntryChanged(entity) => {
|
||||||
@@ -86,33 +103,31 @@ impl Template for MainView {
|
|||||||
//.result("Anzahl Versicherungsnummern: 0")
|
//.result("Anzahl Versicherungsnummern: 0")
|
||||||
//.result("Policyholders count: 0").sum_policynumbers(0)
|
//.result("Policyholders count: 0").sum_policynumbers(0)
|
||||||
//.sum_policynumbers(0)
|
//.sum_policynumbers(0)
|
||||||
Grid::new()
|
Grid::new()
|
||||||
|
.background("#fafafa")
|
||||||
//.width(200.0)
|
//.width(200.0)
|
||||||
//.height(360.0)
|
//.height(360.0)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::new()
|
Columns::new()
|
||||||
.add(200.0)
|
.add(150.0)
|
||||||
.add("*")
|
.add("*")
|
||||||
//.add(120.0)
|
//.add(120.0)
|
||||||
.add(200.0)
|
|
||||||
//.add("auto")
|
//.add("auto")
|
||||||
|
.add(150.0)
|
||||||
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::new()
|
Rows::new()
|
||||||
//.add("auto")
|
|
||||||
//.add(150.0)
|
|
||||||
//.add(200.0)
|
|
||||||
.add("*")
|
.add("*")
|
||||||
.add("*")
|
.add("*")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.element("policholder_check")
|
.element("policyholder_check")
|
||||||
.background("fafafa")
|
.margin((4.0, 24.0, 24.0, 4.0))
|
||||||
.margin((4.0, 24.0, 4.0, 4.0))
|
.min_width(180.0)
|
||||||
.min_width(80.0)
|
.min_height(80.0)
|
||||||
.min_height(180.0)
|
|
||||||
.attach(Grid::column(1))
|
.attach(Grid::column(1))
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
.child(
|
.child(
|
||||||
@@ -124,11 +139,22 @@ impl Template for MainView {
|
|||||||
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
.child(create_header(ctx, "Validierung Versicherungsnummer"))
|
||||||
.child(
|
.child(
|
||||||
TextBox::new()
|
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...")
|
.water_mark("Versicherungs-Nr...")
|
||||||
//.text("Number policyholder", id)
|
//.text("Number policyholder", id)
|
||||||
.text(("policynumber", id))
|
.text(("policynumber", id))
|
||||||
.font_size(24.0)
|
.font_size(24.0)
|
||||||
|
.h_align("stretch")
|
||||||
.on_activate(move |states, entity| {
|
.on_activate(move |states, entity| {
|
||||||
state(id, states).action(Action::EntryActivated(entity));
|
state(id, states).action(Action::EntryActivated(entity));
|
||||||
})
|
})
|
||||||
@@ -154,14 +180,13 @@ impl Template for MainView {
|
|||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.element("logo_customer")
|
.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::column(0))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
|
.v_align("end")
|
||||||
.child(
|
.child(
|
||||||
ImageWidget::new()
|
ImageWidget::new()
|
||||||
.image("../resources/images/hiedemann_logo.png")
|
.image("./resources/images/hiedemann_logo.png")
|
||||||
//.h_align("center")
|
|
||||||
//.v_align("bottom")
|
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -169,16 +194,13 @@ impl Template for MainView {
|
|||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.element("logo_vendor")
|
.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::column(2))
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
//.v_align("bottom")
|
.v_align("end")
|
||||||
.child(
|
.child(
|
||||||
ImageWidget::new()
|
ImageWidget::new()
|
||||||
//.image("../resources/images/networkx_logo.jpg")
|
.image("./resources/images/networkx_logo.png")
|
||||||
.image("../resources/images/networkx_logo.png")
|
|
||||||
//.h_align("center")
|
|
||||||
//.v_align("bottom")
|
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
@@ -193,14 +215,14 @@ fn main() {
|
|||||||
.window(|ctx| {
|
.window(|ctx| {
|
||||||
Window::new()
|
Window::new()
|
||||||
//.title("OrbTk - Policyholder checker example")
|
//.title("OrbTk - Policyholder checker example")
|
||||||
|
.name("MainWindow")
|
||||||
.title("AdvoTracker - Versicherungsnummern")
|
.title("AdvoTracker - Versicherungsnummern")
|
||||||
.position((-500.0, -100.0))
|
.position((-500.0, -100.0))
|
||||||
.size(480.0, 360.0)
|
.size(480.0, 260.0)
|
||||||
.min_width(80.0)
|
.min_width(460.0)
|
||||||
.min_height(180.0)
|
.min_height(180.0)
|
||||||
.resizeable(true)
|
.resizeable(true)
|
||||||
//.theme(get_theme())
|
.theme(get_theme())
|
||||||
.background("#fafafa")
|
|
||||||
.child(MainView::new().build(ctx))
|
.child(MainView::new().build(ctx))
|
||||||
.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