use iced::{ Background, Theme, border, theme::palette, widget::{button, container}, }; use crate::config::CORNER_RADIUS; pub fn rounded_container(theme: &Theme) -> container::Style { let palette = theme.extended_palette(); container::Style { background: Some(palette.background.base.color.into()), border: border::rounded(CORNER_RADIUS), ..container::Style::default() } } pub fn squared_container(theme: &Theme) -> container::Style { let palette = theme.extended_palette(); container::Style { background: Some(palette.background.base.color.into()), ..container::Style::default() } } fn styled(pair: palette::Pair) -> button::Style { button::Style { background: Some(Background::Color(pair.color)), text_color: pair.text, border: border::rounded(CORNER_RADIUS), ..button::Style::default() } } fn disabled(style: button::Style) -> button::Style { button::Style { background: style .background .map(|background| background.scale_alpha(0.5)), text_color: style.text_color.scale_alpha(0.5), ..style } } pub fn solid(theme: &Theme, status: button::Status) -> button::Style { let palette = theme.extended_palette(); let base = styled(palette.primary.strong); match status { button::Status::Active | button::Status::Pressed => base, button::Status::Hovered => button::Style { background: Some(Background::Color(palette.primary.base.color)), ..base }, button::Status::Disabled => disabled(base), } } pub fn transparent(theme: &Theme, status: button::Status) -> button::Style { let palette = theme.extended_palette(); let base = styled(palette.background.base); match status { button::Status::Active | button::Status::Pressed => base, button::Status::Hovered => button::Style { background: Some(Background::Color(palette.background.weak.color)), ..base }, button::Status::Disabled => disabled(base), } }