Remove when_else
Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
parent
393be3cedf
commit
7c19650a40
3 changed files with 20 additions and 32 deletions
|
@ -319,10 +319,12 @@ impl Render for FeedbackModal {
|
||||||
"Characters: {}",
|
"Characters: {}",
|
||||||
characters_remaining
|
characters_remaining
|
||||||
))
|
))
|
||||||
.when_else(
|
.color(
|
||||||
valid_character_count,
|
if valid_character_count {
|
||||||
|this| this.color(Color::Success),
|
Color::Success
|
||||||
|this| this.color(Color::Error)
|
} else {
|
||||||
|
Color::Error
|
||||||
|
}
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -349,11 +351,13 @@ impl Render for FeedbackModal {
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
// TODO: replicate this logic when clicking outside the modal
|
// TODO: replicate this logic when clicking outside the modal
|
||||||
// TODO: Will require somehow overriding the modal dismal default behavior
|
// TODO: Will require somehow overriding the modal dismal default behavior
|
||||||
.when_else(
|
.map(|this| {
|
||||||
has_feedback,
|
if has_feedback {
|
||||||
|this| this.on_click(dismiss_prompt),
|
this.on_click(dismiss_prompt)
|
||||||
|this| this.on_click(dismiss)
|
} else {
|
||||||
)
|
this.on_click(dismiss)
|
||||||
|
}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("send_feedback", submit_button_text)
|
Button::new("send_feedback", submit_button_text)
|
||||||
|
|
|
@ -69,24 +69,6 @@ pub trait IntoElement: Sized {
|
||||||
self.map(|this| if condition { then(this) } else { this })
|
self.map(|this| if condition { then(this) } else { this })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn when_else(
|
|
||||||
self,
|
|
||||||
condition: bool,
|
|
||||||
then: impl FnOnce(Self) -> Self,
|
|
||||||
otherwise: impl FnOnce(Self) -> Self,
|
|
||||||
) -> Self
|
|
||||||
where
|
|
||||||
Self: Sized,
|
|
||||||
{
|
|
||||||
self.map(|this| {
|
|
||||||
if condition {
|
|
||||||
then(this)
|
|
||||||
} else {
|
|
||||||
otherwise(this)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self
|
fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
|
|
|
@ -98,11 +98,13 @@ impl RenderOnce for Key {
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.py_0()
|
.py_0()
|
||||||
.when_else(
|
.map(|this| {
|
||||||
single_char,
|
if single_char {
|
||||||
|el| el.w(rems(14. / 16.)).flex().flex_none().justify_center(),
|
this.w(rems(14. / 16.)).flex().flex_none().justify_center()
|
||||||
|el| el.px_0p5(),
|
} else {
|
||||||
)
|
this.px_0p5()
|
||||||
|
}
|
||||||
|
})
|
||||||
.h(rems(14. / 16.))
|
.h(rems(14. / 16.))
|
||||||
.text_ui()
|
.text_ui()
|
||||||
.line_height(relative(1.))
|
.line_height(relative(1.))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue