improv(text_input): Switch icon when toggling visibility of secure input

This commit is contained in:
Jason Hansen 2024-08-09 12:36:31 -06:00 committed by GitHub
parent 4c04792481
commit 84afe7b50a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -111,7 +111,7 @@ where
.into(),
)
}
/// Creates a new search [`TextInput`].
/// Creates a new secure [`TextInput`].
///
/// [`TextInput`]: widget::TextInput
pub fn secure_input<'a, Message>(
@ -139,13 +139,17 @@ where
}
if let Some(msg) = on_visible_toggle {
input.trailing_icon(
crate::widget::icon::from_name("document-properties-symbolic")
.size(16)
.apply(crate::widget::button)
.style(crate::theme::Button::Icon)
.on_press(msg)
.padding([spacing, spacing, spacing, spacing])
.into(),
crate::widget::icon::from_name(if hidden {
"document-properties-symbolic"
} else {
"image-red-eye-symbolic"
})
.size(16)
.apply(crate::widget::button)
.style(crate::theme::Button::Icon)
.on_press(msg)
.padding([spacing, spacing, spacing, spacing])
.into(),
)
} else {
input