summaryrefslogtreecommitdiffstats
path: root/style
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-05 15:53:59 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-03-05 15:53:59 +0100
commit704ec9cb5cdc1d44f2df2f15de700b0af330b1d7 (patch)
tree27aeef02032c47327e74c9b3e48e83e11cde7fb2 /style
parentd681aaa57e3106cf0ce90b74ade040ca7bb97832 (diff)
downloadiced-704ec9cb5cdc1d44f2df2f15de700b0af330b1d7.tar.gz
iced-704ec9cb5cdc1d44f2df2f15de700b0af330b1d7.tar.bz2
iced-704ec9cb5cdc1d44f2df2f15de700b0af330b1d7.zip
Simplify theming for `TextInput` widget
Diffstat (limited to 'style')
-rw-r--r--style/src/lib.rs1
-rw-r--r--style/src/text_input.rs45
-rw-r--r--style/src/theme.rs125
3 files changed, 0 insertions, 171 deletions
diff --git a/style/src/lib.rs b/style/src/lib.rs
index da3c0676..5906fa0e 100644
--- a/style/src/lib.rs
+++ b/style/src/lib.rs
@@ -27,7 +27,6 @@ pub mod rule;
pub mod slider;
pub mod svg;
pub mod text_editor;
-pub mod text_input;
pub mod theme;
pub mod toggler;
diff --git a/style/src/text_input.rs b/style/src/text_input.rs
deleted file mode 100644
index 8ba9957f..00000000
--- a/style/src/text_input.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-//! Change the appearance of a text input.
-use iced_core::{Background, Border, Color};
-
-/// The appearance of a text input.
-#[derive(Debug, Clone, Copy)]
-pub struct Appearance {
- /// The [`Background`] of the text input.
- pub background: Background,
- /// The [`Border`] of the text input.
- pub border: Border,
- /// The icon [`Color`] of the text input.
- pub icon_color: Color,
-}
-
-/// A set of rules that dictate the style of a text input.
-pub trait StyleSheet {
- /// The supported style of the [`StyleSheet`].
- type Style: Default;
-
- /// Produces the style of an active text input.
- fn active(&self, style: &Self::Style) -> Appearance;
-
- /// Produces the style of a focused text input.
- fn focused(&self, style: &Self::Style) -> Appearance;
-
- /// Produces the [`Color`] of the placeholder of a text input.
- fn placeholder_color(&self, style: &Self::Style) -> Color;
-
- /// 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;
-
- /// Produces the style of an hovered text input.
- 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;
-}
diff --git a/style/src/theme.rs b/style/src/theme.rs
index 6fee19ff..57dfe3c7 100644
--- a/style/src/theme.rs
+++ b/style/src/theme.rs
@@ -15,7 +15,6 @@ use crate::rule;
use crate::slider;
use crate::svg;
use crate::text_editor;
-use crate::text_input;
use crate::toggler;
use crate::core::{Background, Border, Color};
@@ -795,130 +794,6 @@ impl text::StyleSheet for Theme {}
/// The style of a text input.
#[derive(Default)]
-pub enum TextInput {
- /// The default style.
- #[default]
- Default,
- /// A custom style.
- Custom(Box<dyn text_input::StyleSheet<Style = Theme>>),
-}
-
-impl text_input::StyleSheet for Theme {
- type Style = TextInput;
-
- fn active(&self, style: &Self::Style) -> text_input::Appearance {
- if let TextInput::Custom(custom) = style {
- return custom.active(self);
- }
-
- let palette = self.extended_palette();
-
- text_input::Appearance {
- background: palette.background.base.color.into(),
- border: Border {
- radius: 2.0.into(),
- width: 1.0,
- color: palette.background.strong.color,
- },
- icon_color: palette.background.weak.text,
- }
- }
-
- fn hovered(&self, style: &Self::Style) -> text_input::Appearance {
- if let TextInput::Custom(custom) = style {
- return custom.hovered(self);
- }
-
- let palette = self.extended_palette();
-
- text_input::Appearance {
- background: palette.background.base.color.into(),
- border: Border {
- radius: 2.0.into(),
- width: 1.0,
- color: palette.background.base.text,
- },
- icon_color: palette.background.weak.text,
- }
- }
-
- fn focused(&self, style: &Self::Style) -> text_input::Appearance {
- if let TextInput::Custom(custom) = style {
- return custom.focused(self);
- }
-
- let palette = self.extended_palette();
-
- text_input::Appearance {
- background: palette.background.base.color.into(),
- border: Border {
- radius: 2.0.into(),
- width: 1.0,
- color: palette.primary.strong.color,
- },
- icon_color: palette.background.weak.text,
- }
- }
-
- fn placeholder_color(&self, style: &Self::Style) -> Color {
- if let TextInput::Custom(custom) = style {
- return custom.placeholder_color(self);
- }
-
- let palette = self.extended_palette();
-
- palette.background.strong.color
- }
-
- fn value_color(&self, style: &Self::Style) -> Color {
- if let TextInput::Custom(custom) = style {
- return custom.value_color(self);
- }
-
- let palette = self.extended_palette();
-
- palette.background.base.text
- }
-
- fn selection_color(&self, style: &Self::Style) -> Color {
- if let TextInput::Custom(custom) = style {
- return custom.selection_color(self);
- }
-
- let palette = self.extended_palette();
-
- 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.weak.color.into(),
- border: Border {
- radius: 2.0.into(),
- width: 1.0,
- color: palette.background.strong.color,
- },
- icon_color: palette.background.strong.color,
- }
- }
-
- fn disabled_color(&self, style: &Self::Style) -> Color {
- if let TextInput::Custom(custom) = style {
- return custom.disabled_color(self);
- }
-
- self.placeholder_color(style)
- }
-}
-
-/// The style of a text input.
-#[derive(Default)]
pub enum TextEditor {
/// The default style.
#[default]