linter updates

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2021-11-12 15:48:17 +01:00
parent c1a4547261
commit c8f6a6d272
36 changed files with 1005 additions and 614 deletions

View File

@@ -8,7 +8,7 @@ static ID_CHECK_POLICY_NUMBER: &'static str = "ID_CHECK_POLICY_NUMBER";
static ID_PROGRESS_BAR: &'static str = "ID_PROGRESS_BAR";
enum Action {
ParsePolicyNumber
ParsePolicyNumber,
}
#[derive(Default, AsAny)]
@@ -16,15 +16,18 @@ struct MainViewState {
action: Option<Action>,
progress_bar: Entity,
text_box: Entity,
progress_counter: f64
//records: HashMap::<String, String>,
progress_counter: f64, //records: HashMap::<String, String>,
//record_counter: u64
}
impl State for MainViewState {
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
self.text_box = ctx.entity_of_child(ID_CHECK_POLICY_NUMBER).expect("Cannot get TextBox!");
self.progress_bar = ctx.entity_of_child(ID_PROGRESS_BAR).expect("Cannot get progress bar !");
self.text_box = ctx
.entity_of_child(ID_CHECK_POLICY_NUMBER)
.expect("Cannot get TextBox!");
self.progress_bar = ctx
.entity_of_child(ID_PROGRESS_BAR)
.expect("Cannot get progress bar !");
}
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
@@ -32,7 +35,10 @@ impl State for MainViewState {
if let Some(action) = &self.action {
match action {
Action::ParsePolicyNumber => {
let value_to_parse = ctx.get_widget(self.text_box).get::<String16>("text").clone();
let value_to_parse = ctx
.get_widget(self.text_box)
.get::<String16>("text")
.clone();
self.parse_policy_number(value_to_parse, ctx);
}
}
@@ -81,9 +87,7 @@ widget!(MainView<MainViewState>);
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self
.margin(32.0)
.child(
self.margin(32.0).child(
Stack::new()
.orientation("vertical")
.h_align("center")
@@ -95,16 +99,14 @@ impl Template for MainView {
.water_mark("Mut value and type <Return>")
.on_activate(move |states, _entity| {
// you have to fire a new event to be able to get in the update() with access to Context
states.get_mut::<MainViewState>(id).action(Action::ParsePolicyNumber);
states
.get_mut::<MainViewState>(id)
.action(Action::ParsePolicyNumber);
})
.build(ctx)
.build(ctx),
)
.child(
ProgressBar::new()
.id(ID_PROGRESS_BAR)
.build(ctx)
)
.build(ctx)
.child(ProgressBar::new().id(ID_PROGRESS_BAR).build(ctx))
.build(ctx),
)
}
}