fix installer pick_list warning

This commit is contained in:
edouard 2023-03-28 14:10:31 +02:00
parent 30054d2755
commit d108a0f48d
3 changed files with 51 additions and 22 deletions

View File

@ -157,15 +157,20 @@ pub fn define_descriptor<'a>(
pick_list(&NETWORKS[..], Some(Network::from(network)), |net| {
Message::Network(net.into())
})
.style(theme::PickList::Simple)
.style(if network_valid {
theme::PickList::Simple
} else {
theme::PickList::Invalid
})
.padding(10),
))
.push_maybe(if network_valid {
None
} else {
Some(card::warning(
"A data directory already exists for this network".to_string(),
))
Some(
text("A data directory already exists for this network")
.style(color::legacy::ALERT),
)
})
.padding(50);
@ -363,14 +368,20 @@ pub fn import_descriptor<'a>(
pick_list(&NETWORKS[..], Some(Network::from(network)), |net| {
Message::Network(net.into())
})
.style(if network_valid {
theme::PickList::Simple
} else {
theme::PickList::Invalid
})
.padding(10),
))
.push_maybe(if network_valid {
None
} else {
Some(card::warning(
"A data directory already exists for this network".to_string(),
))
Some(
text("A data directory already exists for this network")
.style(color::legacy::ALERT),
)
});
let col_descriptor = Column::new()
.push(text("Descriptor:").bold())
@ -619,14 +630,20 @@ pub fn participate_xpub<'a>(
pick_list(&NETWORKS[..], Some(Network::from(network)), |net| {
Message::Network(net.into())
})
.style(if network_valid {
theme::PickList::Simple
} else {
theme::PickList::Invalid
})
.padding(10),
))
.push_maybe(if network_valid {
None
} else {
Some(card::warning(
"A data directory already exists for this network".to_string(),
))
Some(
text("A data directory already exists for this network")
.style(color::legacy::ALERT),
)
});
layout(

View File

@ -18,8 +18,8 @@ pub fn warning<'a, T: 'a>(message: String) -> Container<'a, T> {
Row::new()
.spacing(20)
.align_items(iced::Alignment::Center)
.push(icon::warning_octagon_icon().style(color::legacy::WARNING))
.push(text(message).style(color::legacy::WARNING)),
.push(icon::warning_octagon_icon())
.push(text(message)),
)
.padding(15)
.style(theme::Container::Card(theme::Card::Warning))

View File

@ -50,7 +50,7 @@ impl iced::overlay::menu::StyleSheet for Theme {
background: color::LIGHT_GREY.into(),
border_width: 1.0,
border_radius: 0.0,
border_color: color::GREEN,
border_color: color::LIGHT_GREY,
selected_text_color: color::BLACK,
selected_background: color::GREEN.into(),
}
@ -422,19 +422,31 @@ impl scrollable::StyleSheet for Theme {
pub enum PickList {
#[default]
Simple,
Invalid,
}
impl pick_list::StyleSheet for Theme {
type Style = PickList;
fn active(&self, _style: &Self::Style) -> pick_list::Appearance {
pick_list::Appearance {
placeholder_color: color::legacy::FOREGROUND,
handle_color: color::legacy::FOREGROUND,
background: color::legacy::FOREGROUND.into(),
border_width: 1.0,
border_color: color::legacy::BORDER_GREY,
border_radius: 10.0,
text_color: iced::Color::BLACK,
fn active(&self, style: &Self::Style) -> pick_list::Appearance {
match style {
PickList::Simple => pick_list::Appearance {
placeholder_color: color::legacy::FOREGROUND,
handle_color: color::legacy::FOREGROUND,
background: color::legacy::FOREGROUND.into(),
border_width: 1.0,
border_color: color::legacy::BORDER_GREY,
border_radius: 10.0,
text_color: iced::Color::BLACK,
},
PickList::Invalid => pick_list::Appearance {
placeholder_color: color::legacy::FOREGROUND,
handle_color: color::legacy::FOREGROUND,
background: color::legacy::FOREGROUND.into(),
border_width: 1.0,
border_color: color::legacy::ALERT,
border_radius: 10.0,
text_color: iced::Color::BLACK,
},
}
}