feat(theme): TextInput::Search style

This commit is contained in:
Michael Aaron Murphy 2023-01-25 04:12:56 +01:00 committed by Michael Murphy
parent 9a095e4d94
commit 4b7509e1c3

View file

@ -829,42 +829,73 @@ impl text::StyleSheet for Theme {
} }
} }
#[derive(Copy, Clone, Default)]
pub enum TextInput {
#[default]
Default,
Search,
}
/* /*
* TODO: Text Input * TODO: Text Input
*/ */
impl text_input::StyleSheet for Theme { impl text_input::StyleSheet for Theme {
type Style = (); type Style = TextInput;
fn active(&self, _style: &Self::Style) -> text_input::Appearance { fn active(&self, style: &Self::Style) -> text_input::Appearance {
let palette = self.extended_palette(); let palette = self.extended_palette();
text_input::Appearance { match style {
background: palette.background.base.color.into(), TextInput::Default => text_input::Appearance {
border_radius: 2.0, background: palette.background.base.color.into(),
border_width: 1.0, border_radius: 2.0,
border_color: palette.background.strong.color, border_width: 1.0,
border_color: palette.background.strong.color,
},
TextInput::Search => text_input::Appearance {
background: Background::Color(Color::TRANSPARENT),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
} }
} }
fn hovered(&self, _style: &Self::Style) -> text_input::Appearance { fn hovered(&self, style: &Self::Style) -> text_input::Appearance {
let palette = self.extended_palette(); let palette = self.extended_palette();
text_input::Appearance { match style {
background: palette.background.base.color.into(), TextInput::Default => text_input::Appearance {
border_radius: 2.0, background: palette.background.base.color.into(),
border_width: 1.0, border_radius: 2.0,
border_color: palette.background.base.text, border_width: 1.0,
border_color: palette.background.base.text,
},
TextInput::Search => text_input::Appearance {
background: Background::Color(Color::TRANSPARENT),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
} }
} }
fn focused(&self, _style: &Self::Style) -> text_input::Appearance { fn focused(&self, style: &Self::Style) -> text_input::Appearance {
let palette = self.extended_palette(); let palette = self.extended_palette();
text_input::Appearance { match style {
background: palette.background.base.color.into(), TextInput::Default => text_input::Appearance {
border_radius: 2.0, background: palette.background.base.color.into(),
border_width: 1.0, border_radius: 2.0,
border_color: palette.primary.strong.color, border_width: 1.0,
border_color: palette.primary.strong.color,
},
TextInput::Search => text_input::Appearance {
background: Background::Color(Color::TRANSPARENT),
border_radius: 0.0,
border_width: 0.0,
border_color: Color::TRANSPARENT,
},
} }
} }