Introduce disabled state for TextInput
This commit is contained in:
parent
ca828f03f5
commit
f10e936f00
17 changed files with 410 additions and 254 deletions
|
|
@ -33,6 +33,9 @@ pub trait StyleSheet {
|
|||
/// Produces the [`Color`] of the value of a text input.
|
||||
fn value_color(&self, style: &Self::Style) -> Color;
|
||||
|
||||
/// Produces the [`Color`] of the value of a disabled text input.
|
||||
fn disabled_color(&self, style: &Self::Style) -> Color;
|
||||
|
||||
/// Produces the [`Color`] of the selection of a text input.
|
||||
fn selection_color(&self, style: &Self::Style) -> Color;
|
||||
|
||||
|
|
@ -40,4 +43,7 @@ pub trait StyleSheet {
|
|||
fn hovered(&self, style: &Self::Style) -> Appearance {
|
||||
self.focused(style)
|
||||
}
|
||||
|
||||
/// Produces the style of a disabled text input.
|
||||
fn disabled(&self, style: &Self::Style) -> Appearance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1093,4 +1093,30 @@ impl text_input::StyleSheet for Theme {
|
|||
|
||||
palette.primary.weak.color
|
||||
}
|
||||
|
||||
fn disabled(&self, style: &Self::Style) -> text_input::Appearance {
|
||||
if let TextInput::Custom(custom) = style {
|
||||
return custom.disabled(self);
|
||||
}
|
||||
|
||||
let palette = self.extended_palette();
|
||||
|
||||
text_input::Appearance {
|
||||
background: palette.background.base.color.into(),
|
||||
border_radius: 2.0,
|
||||
border_width: 1.0,
|
||||
border_color: palette.background.weak.color,
|
||||
icon_color: palette.background.weak.color,
|
||||
}
|
||||
}
|
||||
|
||||
fn disabled_color(&self, style: &Self::Style) -> Color {
|
||||
if let TextInput::Custom(custom) = style {
|
||||
return custom.value_color(self);
|
||||
}
|
||||
|
||||
let palette = self.extended_palette();
|
||||
|
||||
palette.secondary.strong.color
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue