Unified · Split
| @@ -319,10 +319,12 @@ impl Render for FeedbackModal { · 318 unmodified lines | ||
| 319 | 319 | "Characters: {}", |
| 320 | 320 | characters_remaining |
| 321 | 321 | )) |
| 322 | − .when_else( | |
| 323 | − valid_character_count, | |
| 324 | − |this| this.color(Color::Success), | |
| 325 | − |this| this.color(Color::Error) | |
| 322 | + .color( | |
| 323 | + if valid_character_count { | |
| 324 | + Color::Success | |
| 325 | + } else { | |
| 326 | + Color::Error | |
| 327 | + } | |
| 326 | 328 | ) |
| 327 | 329 | ), |
| 328 | 330 | ) |
| @@ -349,11 +351,13 @@ impl Render for FeedbackModal { · 20 unmodified lines | ||
| 349 | 351 | .color(Color::Muted) |
| 350 | 352 | // TODO: replicate this logic when clicking outside the modal |
| 351 | 353 | // TODO: Will require somehow overriding the modal dismal default behavior |
| 352 | − .when_else( | |
| 353 | − has_feedback, | |
| 354 | − |this| this.on_click(dismiss_prompt), | |
| 355 | − |this| this.on_click(dismiss) | |
| 356 | − ) | |
| 354 | + .map(|this| { | |
| 355 | + if has_feedback { | |
| 356 | + this.on_click(dismiss_prompt) | |
| 357 | + } else { | |
| 358 | + this.on_click(dismiss) | |
| 359 | + } | |
| 360 | + }) | |
| 357 | 361 | ) |
| 358 | 362 | .child( |
| 359 | 363 | Button::new("send_feedback", submit_button_text) |
| @@ -69,24 +69,6 @@ pub trait IntoElement: Sized { · 68 unmodified lines | ||
| 69 | 69 | self.map(|this| if condition { then(this) } else { this }) |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | − fn when_else( | |
| 73 | − self, | |
| 74 | − condition: bool, | |
| 75 | − then: impl FnOnce(Self) -> Self, | |
| 76 | − otherwise: impl FnOnce(Self) -> Self, | |
| 77 | − ) -> Self | |
| 78 | − where | |
| 79 | − Self: Sized, | |
| 80 | − { | |
| 81 | − self.map(|this| { | |
| 82 | − if condition { | |
| 83 | − then(this) | |
| 84 | − } else { | |
| 85 | − otherwise(this) | |
| 86 | − } | |
| 87 | − }) | |
| 88 | − } | |
| 89 | − | |
| 90 | 72 | fn when_some<T>(self, option: Option<T>, then: impl FnOnce(Self, T) -> Self) -> Self |
| 91 | 73 | where |
| 92 | 74 | Self: Sized, |
| @@ -98,11 +98,13 @@ impl RenderOnce for Key { · 97 unmodified lines | ||
| 98 | 98 | |
| 99 | 99 | div() |
| 100 | 100 | .py_0() |
| 101 | − .when_else( | |
| 102 | − single_char, | |
| 103 | − |el| el.w(rems(14. / 16.)).flex().flex_none().justify_center(), | |
| 104 | − |el| el.px_0p5(), | |
| 105 | − ) | |
| 101 | + .map(|this| { | |
| 102 | + if single_char { | |
| 103 | + this.w(rems(14. / 16.)).flex().flex_none().justify_center() | |
| 104 | + } else { | |
| 105 | + this.px_0p5() | |
| 106 | + } | |
| 107 | + }) | |
| 106 | 108 | .h(rems(14. / 16.)) |
| 107 | 109 | .text_ui() |
| 108 | 110 | .line_height(relative(1.)) |