summaryrefslogtreecommitdiffstats
path: root/examples/styling
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 01:11:35 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-06-07 01:11:35 +0200
commitce53d3933c860cd958636cce415ac97c04aee746 (patch)
treef52e2719af65c21ed0d1acc6764ac44e1bba9d65 /examples/styling
parent835877fc636d71c1faaa4826cbfde8e09b3c82ba (diff)
downloadiced-ce53d3933c860cd958636cce415ac97c04aee746.tar.gz
iced-ce53d3933c860cd958636cce415ac97c04aee746.tar.bz2
iced-ce53d3933c860cd958636cce415ac97c04aee746.zip
Implement theme styling for `TextInput`
Diffstat (limited to 'examples/styling')
-rw-r--r--examples/styling/src/main.rs63
1 files changed, 3 insertions, 60 deletions
diff --git a/examples/styling/src/main.rs b/examples/styling/src/main.rs
index 8cd17a6c..e2a4b492 100644
--- a/examples/styling/src/main.rs
+++ b/examples/styling/src/main.rs
@@ -77,8 +77,7 @@ impl Sandbox for Styling {
Message::InputChanged,
)
.padding(10)
- .size(20)
- .style(self.theme);
+ .size(20);
let button = Button::new(&mut self.button, Text::new("Submit"))
.padding(10)
@@ -157,7 +156,7 @@ impl Sandbox for Styling {
}
mod style {
- use iced::{scrollable, text_input};
+ use iced::scrollable;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Theme {
@@ -175,15 +174,6 @@ mod style {
}
}
- impl<'a> From<Theme> for Box<dyn text_input::StyleSheet + 'a> {
- fn from(theme: Theme) -> Self {
- match theme {
- Theme::Light => Default::default(),
- Theme::Dark => dark::TextInput.into(),
- }
- }
- }
-
impl<'a> From<Theme> for Box<dyn scrollable::StyleSheet + 'a> {
fn from(theme: Theme) -> Self {
match theme {
@@ -194,7 +184,7 @@ mod style {
}
mod dark {
- use iced::{scrollable, text_input, Color};
+ use iced::{scrollable, Color};
const SURFACE: Color = Color::from_rgb(
0x40 as f32 / 255.0,
@@ -202,12 +192,6 @@ mod style {
0x4B as f32 / 255.0,
);
- const ACCENT: Color = Color::from_rgb(
- 0x6F as f32 / 255.0,
- 0xFF as f32 / 255.0,
- 0xE9 as f32 / 255.0,
- );
-
const ACTIVE: Color = Color::from_rgb(
0x72 as f32 / 255.0,
0x89 as f32 / 255.0,
@@ -220,47 +204,6 @@ mod style {
0xC4 as f32 / 255.0,
);
- pub struct TextInput;
-
- impl text_input::StyleSheet for TextInput {
- fn active(&self) -> text_input::Style {
- text_input::Style {
- background: SURFACE.into(),
- border_radius: 2.0,
- border_width: 0.0,
- border_color: Color::TRANSPARENT,
- }
- }
-
- fn focused(&self) -> text_input::Style {
- text_input::Style {
- border_width: 1.0,
- border_color: ACCENT,
- ..self.active()
- }
- }
-
- fn hovered(&self) -> text_input::Style {
- text_input::Style {
- border_width: 1.0,
- border_color: Color { a: 0.3, ..ACCENT },
- ..self.focused()
- }
- }
-
- fn placeholder_color(&self) -> Color {
- Color::from_rgb(0.4, 0.4, 0.4)
- }
-
- fn value_color(&self) -> Color {
- Color::WHITE
- }
-
- fn selection_color(&self) -> Color {
- ACTIVE
- }
- }
-
pub struct Scrollable;
impl scrollable::StyleSheet for Scrollable {