diff --git a/gui/src/installer/view.rs b/gui/src/installer/view.rs index 67820c71..606d5f69 100644 --- a/gui/src/installer/view.rs +++ b/gui/src/installer/view.rs @@ -329,29 +329,34 @@ pub fn define_descriptor<'a>( progress, "Create the wallet", Column::new() - .push(collapse::Collapse::new( - || { - Button::new( - Row::new() - .align_items(Alignment::Center) - .spacing(10) - .push(text("Advanced settings").small().bold()) - .push(icon::collapse_icon()), - ) - .style(theme::Button::Transparent) - }, - || { - Button::new( - Row::new() - .align_items(Alignment::Center) - .spacing(10) - .push(text("Advanced settings").small().bold()) - .push(icon::collapsed_icon()), - ) - .style(theme::Button::Transparent) - }, - move || define_descriptor_advanced_settings(network, network_valid, use_taproot), - )) + .push( + collapse::Collapse::new( + || { + Button::new( + Row::new() + .align_items(Alignment::Center) + .spacing(10) + .push(text("Advanced settings").small().bold()) + .push(icon::collapse_icon()), + ) + .style(theme::Button::Transparent) + }, + || { + Button::new( + Row::new() + .align_items(Alignment::Center) + .spacing(10) + .push(text("Advanced settings").small().bold()) + .push(icon::collapsed_icon()), + ) + .style(theme::Button::Transparent) + }, + move || { + define_descriptor_advanced_settings(network, network_valid, use_taproot) + }, + ) + .collapsed(!network_valid), + ) .push( Column::new() .width(Length::Fill) @@ -379,7 +384,7 @@ pub fn define_descriptor<'a>( )) .width(Length::Fixed(200.0)), ) - .push(if !valid { + .push(if !valid || !network_valid { button::primary(None, "Next").width(Length::Fixed(200.0)) } else { button::primary(None, "Next") diff --git a/gui/ui/src/component/collapse.rs b/gui/ui/src/component/collapse.rs index 9fff5036..23b2577d 100644 --- a/gui/ui/src/component/collapse.rs +++ b/gui/ui/src/component/collapse.rs @@ -10,6 +10,7 @@ pub struct Collapse<'a, M, H, F, C> { after: F, content: C, phantom: PhantomData<&'a M>, + state: bool, } impl<'a, Message, T, H, F, C, Theme, Renderer> Collapse<'a, Message, H, F, C> @@ -28,8 +29,14 @@ where after, content, phantom: PhantomData, + state: false, } } + + pub fn collapsed(mut self, state: bool) -> Self { + self.state = state; + self + } } #[derive(Debug, Clone, Copy)] @@ -51,18 +58,18 @@ where type State = bool; type Event = Event; - fn update(&mut self, state: &mut Self::State, event: Event) -> Option { + fn update(&mut self, _state: &mut Self::State, event: Event) -> Option { match event { Event::Internal(e) => Some(e.into()), Event::Collapse(s) => { - *state = s; + self.state = s; None } } } - fn view(&self, state: &Self::State) -> Element { - if *state { + fn view(&self, _state: &Self::State) -> Element { + if self.state { column![ (self.after)().on_press(Event::Collapse(false)), (self.content)().map(Event::Internal)