policycheck_view: brake up bigger widget definitions into sub-groups
* improve maintainability - make sub-entities grouped into sub-widgets - reference this sub-widgets from inside their parents Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -38,11 +38,10 @@ impl Template for PolicyCheckView {
|
||||
|
||||
let policy_check_menu_button = Button::new()
|
||||
.id(ID_POLICY_CHECK_MENU_BUTTON)
|
||||
.margin((0.0, 0.0, 12.0, 12.0))
|
||||
.icon(material_icons_font::MD_MENU)
|
||||
.class("menu_button")
|
||||
.attach(Grid::column(2))
|
||||
.margin((8.0, 0.0, 2.0, 0.0))
|
||||
.margin((0., 0., 0., 0.))
|
||||
//.text("Menu Button")
|
||||
//.min_size(8.0, 8.0)
|
||||
.min_size(16.0, 16.0)
|
||||
@@ -78,6 +77,26 @@ impl Template for PolicyCheckView {
|
||||
.enabled(true)
|
||||
.build(ctx);
|
||||
|
||||
let _policy_check_numeric_box = NumericBox::new()
|
||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.h_align("start")
|
||||
.width(100.0)
|
||||
//.min(<usize>1000000000)
|
||||
//.max(<usize>9999999999)
|
||||
.val(0)
|
||||
.min_width(95.0)
|
||||
.margin((0.0, 0.0, 0.0, 16.0))
|
||||
// WIP code @kivimango
|
||||
// .on_activate(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::ParseEntry(entity));
|
||||
// })
|
||||
// .on_changed(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::InputTextChanged(entity));
|
||||
//})
|
||||
.build(ctx);
|
||||
|
||||
// let policy_check_menu_container = Container::new()
|
||||
// .id(ID_POLICY_CHECK_MENU_CONTAINER)
|
||||
// .class(CLASS_MENU)
|
||||
@@ -104,9 +123,214 @@ impl Template for PolicyCheckView {
|
||||
// The menu implemented as an overlay
|
||||
//ctx.append_child_to_overlay(policy_check_menu_button).unwrap();
|
||||
|
||||
let policy_check_header = Container::new()
|
||||
// Header Bar
|
||||
//.border_color("transparent")
|
||||
.class(CLASS_TOP_BAR)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.child(
|
||||
Grid::new()
|
||||
.child(
|
||||
TextBlock::new()
|
||||
//.class(CLASS_HEADER)
|
||||
.class("h1")
|
||||
//.class(".myheader")
|
||||
.id(ID_POLICY_CHECK_HEADER)
|
||||
//.font_size(24)
|
||||
//.font("Roboto Medium")
|
||||
.v_align("center")
|
||||
.h_align("left")
|
||||
.margin((32.0, 32.0, 32.0, 32.0))
|
||||
.text("Validierung Versicherungsnummer")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(policy_check_menu_button)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form_row_0 = Stack::new()
|
||||
// 1st row
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.orientation("horizontal")
|
||||
//.v_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_POLICY_NUMBER)
|
||||
//.class(CLASS_TEXT_BLOCK)
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(0))
|
||||
.margin((0., 0., 16., 0.))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.min_width(250.)
|
||||
.min_height(45.)
|
||||
//.size(250., 45.)
|
||||
.text("Versicherungsnummer:")
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBox::new()
|
||||
.attach(Grid::row(0))
|
||||
.attach(Grid::column(2))
|
||||
.id(ID_POLICY_CHECK_POLICY_NUMBER)
|
||||
.h_align("start")
|
||||
.width(100.0)
|
||||
.min_width(95.0)
|
||||
.margin((0., 0., 0., 0.))
|
||||
.lost_focus_on_activation(false)
|
||||
.water_mark("10-stellig")
|
||||
.text("")
|
||||
.on_activate(move |ctx, entity| {
|
||||
// Entity is entered/activated via Mouse/Keyboard
|
||||
println!("activation finished!");
|
||||
ctx.get_mut::<PolicyCheckState>(id)
|
||||
.action(Action::ParseEntry(entity));
|
||||
})
|
||||
.on_changed(move |ctx, entity| {
|
||||
// Element value has changed
|
||||
ctx.get_mut::<PolicyCheckState>(id)
|
||||
.action(Action::InputTextChanged(entity));
|
||||
ctx.get_mut::<PolicyCheckState>(id)
|
||||
.action(Action::SetVisibility(entity));
|
||||
//ctx.get_widget(policy_check_label_policy_number).set("visible");
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::SetVisility(entity));
|
||||
})
|
||||
// .on_mouse_down | .on_mouse_move | .on_mouse_up (move |ctx, entity| {
|
||||
// state(id, states).action(Action::AddItem);
|
||||
// })
|
||||
// .on_click(move |states, _| {
|
||||
// state(id, states).action(Action::AddItem);
|
||||
// true
|
||||
// })
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_form_row_1 = Stack::new()
|
||||
// 2nd row
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(0))
|
||||
.orientation("horizontal")
|
||||
//.v_align("center")
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_LABEL_RESULT)
|
||||
.class(CLASS_TEXT_BLOCK)
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.margin((0., 0., 16., 0.))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.min_width(250.0)
|
||||
.text("Ergebnis:")
|
||||
.visibility(Visibility::Visible)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
TextBlock::new()
|
||||
.id(ID_POLICY_CHECK_RESULT)
|
||||
//.id("policy_check_result")
|
||||
.h_align("start")
|
||||
.attach(Grid::row(1))
|
||||
.attach(Grid::column(2))
|
||||
.text("")
|
||||
.width(250.)
|
||||
//.margin((4., 0., 0., 0.))
|
||||
//.lost_focus_on_activation(false)
|
||||
// .on_activate(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::ParseEntry(entity));
|
||||
// })
|
||||
// .on_changed(move |ctx, entity| {
|
||||
// ctx.get_mut::<PolicyCheckState>(id)
|
||||
// .action(Action::InputTextChanged(entity));
|
||||
// })
|
||||
.build(ctx)
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
//let policy_check_policy_number = Stack::new()
|
||||
// build(ctx);
|
||||
|
||||
let policy_check_form = Container::new()
|
||||
//.class(CLASS_POLICY_CHECK_FORM)
|
||||
.attach(Grid::row(2))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.margin((16., 26., 26., 16.))
|
||||
.child(
|
||||
Grid::new()
|
||||
.id(ID_POLICY_CHECK_FORM)
|
||||
.columns(
|
||||
Columns::new()
|
||||
// Labels
|
||||
.add("220.")
|
||||
// Seperator
|
||||
.add("16.")
|
||||
// Values
|
||||
.add("100.")
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
Rows::new()
|
||||
.add("96.")
|
||||
.add("96.")
|
||||
.build(),
|
||||
)
|
||||
.child(policy_check_form_row_0)
|
||||
.child(policy_check_form_row_1)
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
let policy_check_footer = Container::new()
|
||||
// Bottom bar
|
||||
.class(CLASS_BOTTOM_BAR)
|
||||
.attach(Grid::row(4))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::column_span(3))
|
||||
.v_align("end")
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_customer")
|
||||
.margin((9., 16., 16., 9.))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(1))
|
||||
.h_align("start")
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("resources/images/hiedemann_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
)
|
||||
.child(
|
||||
Grid::new()
|
||||
.element("logo_vendor")
|
||||
.margin((9.0, 16.0, 16.0, 9.0))
|
||||
.attach(Grid::column(0))
|
||||
.attach(Grid::row(5))
|
||||
.h_align("end")
|
||||
.v_align("center")
|
||||
.child(
|
||||
ImageWidget::new()
|
||||
.image("resources/images/networkx_logo.png")
|
||||
.build(ctx),
|
||||
)
|
||||
.build(ctx),
|
||||
//ctx.append_child_to_overlay(policycheck_menu_text_block).unwrap()
|
||||
)
|
||||
.build(ctx);
|
||||
|
||||
// Starter page: check for valid policy number
|
||||
self.name("PolicyCheckView")
|
||||
// initialize struct consuming the derived default macro
|
||||
// initialize struct (derived default macro)
|
||||
.policy_check(PolicyCheck::default())
|
||||
.child(
|
||||
Grid::new()
|
||||
@@ -114,9 +338,10 @@ impl Template for PolicyCheckView {
|
||||
//.background("#fafafa")
|
||||
.columns(
|
||||
Columns::new()
|
||||
.add(84.0)
|
||||
.add(150.)
|
||||
.add("*")
|
||||
//.add(50.)
|
||||
.add("*")
|
||||
.add(50.0)
|
||||
.build(),
|
||||
)
|
||||
.rows(
|
||||
@@ -158,6 +383,7 @@ impl Template for PolicyCheckView {
|
||||
.child(policy_check_menu_button)
|
||||
.build(ctx),
|
||||
)
|
||||
|
||||
.child(
|
||||
Container::new()
|
||||
.class("separator")
|
||||
|
||||
Reference in New Issue
Block a user