I have IpFetcher::Unregistered
view where I fill form and at submit
button press calling message Message::Register
that will change my view from IpFetcher::Unregistered
to IpFetcher::Registered
. But I want to be able to see and change form’s field even at this view change (want it to look same). So even if Registered
I’m still able to update
the values and click submit
button again. I’m doing it by cloning ref mut register_form
from one view to another at update
(message call). If it is once I would be able to clone it, but in next stages I want to do some loop stuffs, and cloning it whole time is not a good approach I think….
fn update(&mut self, message: Message) -> Command<Message> {
match message {
........
Message::Register => {
if let IpFetcher::Unregistered { ref mut register_form, .. } = self {
*self = IpFetcher::Registered { register_form_registered: register_form.clone() };
}
Command::none()
}
}
fn view(&self) -> Element<Message> {
let content = match self {
IpFetcher::Unregistered { register_form } =>
column![register_form.view()] // <<<<< HERE I have submit button button("Register").on_press(Message::Register)
.max_width(800)
.spacing(20)
.align_items(Alignment::End),
IpFetcher::Registered { register_form_registered } => {
column![
register_form_registered.view(),
button("Start Fetching!").on_press(Message::Search)]
.max_width(800)
.spacing(20)
.align_items(Alignment::End)
}
I tried to change it to Option<RegisterForm>
and pass the value, but this didn’t work well..
User25356 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.