Implement theme styling for Radio
This commit is contained in:
parent
d988d813d7
commit
28d09bfff1
10 changed files with 86 additions and 157 deletions
|
|
@ -69,15 +69,12 @@ impl Sandbox for ScrollableDemo {
|
|||
let choose_theme = style::Theme::ALL.iter().fold(
|
||||
Column::new().spacing(10).push(Text::new("Choose a theme:")),
|
||||
|column, option| {
|
||||
column.push(
|
||||
Radio::new(
|
||||
*option,
|
||||
format!("{:?}", option),
|
||||
Some(*theme),
|
||||
Message::ThemeChanged,
|
||||
)
|
||||
.style(*theme),
|
||||
)
|
||||
column.push(Radio::new(
|
||||
*option,
|
||||
format!("{:?}", option),
|
||||
Some(*theme),
|
||||
Message::ThemeChanged,
|
||||
))
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use iced::{container, radio, rule, scrollable};
|
||||
use iced::{container, rule, scrollable};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Theme {
|
||||
|
|
@ -25,15 +25,6 @@ impl<'a> From<Theme> for Box<dyn container::StyleSheet + 'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Theme> for Box<dyn radio::StyleSheet + 'a> {
|
||||
fn from(theme: Theme) -> Self {
|
||||
match theme {
|
||||
Theme::Light => Default::default(),
|
||||
Theme::Dark => dark::Radio.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Theme> for Box<dyn scrollable::StyleSheet + 'a> {
|
||||
fn from(theme: Theme) -> Self {
|
||||
match theme {
|
||||
|
|
@ -53,7 +44,7 @@ impl From<Theme> for Box<dyn rule::StyleSheet> {
|
|||
}
|
||||
|
||||
mod dark {
|
||||
use iced::{container, radio, rule, scrollable, Color};
|
||||
use iced::{container, rule, scrollable, Color};
|
||||
|
||||
const BACKGROUND: Color = Color::from_rgb(
|
||||
0x36 as f32 / 255.0,
|
||||
|
|
@ -73,12 +64,6 @@ mod dark {
|
|||
0xE9 as f32 / 255.0,
|
||||
);
|
||||
|
||||
const ACTIVE: Color = Color::from_rgb(
|
||||
0x72 as f32 / 255.0,
|
||||
0x89 as f32 / 255.0,
|
||||
0xDA as f32 / 255.0,
|
||||
);
|
||||
|
||||
const SCROLLBAR: Color = Color::from_rgb(
|
||||
0x2E as f32 / 255.0,
|
||||
0x33 as f32 / 255.0,
|
||||
|
|
@ -107,27 +92,6 @@ mod dark {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct Radio;
|
||||
|
||||
impl radio::StyleSheet for Radio {
|
||||
fn active(&self) -> radio::Style {
|
||||
radio::Style {
|
||||
background: SURFACE.into(),
|
||||
dot_color: ACTIVE,
|
||||
border_width: 1.0,
|
||||
border_color: ACTIVE,
|
||||
text_color: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self) -> radio::Style {
|
||||
radio::Style {
|
||||
background: Color { a: 0.5, ..SURFACE }.into(),
|
||||
..self.active()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Scrollable;
|
||||
|
||||
impl scrollable::StyleSheet for Scrollable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue