use iced::{
application, color,
widget::{container, text, text_input},
Background, Color,
};
use once_cell::sync::Lazy;
static GANDALF_COLOR_NONE: Lazy<Color> = Lazy::new(|| color!(0x000000, 0.));
static GANDALF_COLOR_BG: Lazy<Color> = Lazy::new(|| color!(0x292831, 0.8));
static GANDALF_COLOR_TEXT: Lazy<Color> = Lazy::new(|| color!(0x4a7a96, 1.));
static GANDALF_COLOR_PLACEHOLDER: Lazy<Color> = Lazy::new(|| color!(0x333f58, 1.));
static GANDALF_COLOR_PROMPT: Lazy<Color> = Lazy::new(|| color!(0xfbbbad, 1.));
static GANDALF_COLOR_SELECTED: Lazy<Color> = Lazy::new(|| color!(0xee8695, 1.));
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub enum GTheme {
#[default]
Light,
}
/// The style of an application.
#[derive(Default)]
pub enum Application {
/// The default style.
#[default]
Default,
}
impl application::StyleSheet for GTheme {
type Style = Application;
fn appearance(&self, style: &Self::Style) -> application::Appearance {
match style {
Application::Default => application::Appearance {
background_color: *GANDALF_COLOR_BG,
text_color: *GANDALF_COLOR_TEXT,
},
}
}
}
/// The style of a container.
#[derive(Default)]
pub enum Container {
#[default]
Transparent,
}
impl container::StyleSheet for GTheme {
type Style = Container;
fn appearance(&self, style: &Self::Style) -> container::Appearance {
match style {
Container::Transparent => Default::default(),
}
}
}
/// The style of text.
#[derive(Clone, Copy, Default)]
pub enum Text {
#[default]
Default,
Selected,
}
impl text::StyleSheet for GTheme {
type Style = Text;
fn appearance(&self, style: Self::Style) -> text::Appearance {
match style {
Text::Default => text::Appearance {
color: Some(*GANDALF_COLOR_TEXT),
},
Text::Selected => text::Appearance {
color: Some(*GANDALF_COLOR_SELECTED),
},
}
}
}
/// The style of a text input.
#[derive(Default)]
pub enum TextInput {
#[default]
Default,
}
impl text_input::StyleSheet for GTheme {
type Style = TextInput;
fn active(&self, _style: &Self::Style) -> text_input::Appearance {
text_input::Appearance {
background: Background::Color(*GANDALF_COLOR_NONE),
border_radius: 0.,
border_width: 0.,
border_color: *GANDALF_COLOR_NONE,
}
}
fn hovered(&self, _style: &Self::Style) -> text_input::Appearance {
text_input::Appearance {
background: Background::Color(*GANDALF_COLOR_NONE),
border_radius: 0.,
border_width: 0.,
border_color: *GANDALF_COLOR_NONE,
}
}
fn focused(&self, _style: &Self::Style) -> text_input::Appearance {
text_input::Appearance {
background: Background::Color(*GANDALF_COLOR_NONE),
border_radius: 0.,
border_width: 0.,
border_color: *GANDALF_COLOR_NONE,
}
}
fn placeholder_color(&self, _style: &Self::Style) -> Color {
*GANDALF_COLOR_PLACEHOLDER
}
fn value_color(&self, _style: &Self::Style) -> Color {
*GANDALF_COLOR_PROMPT
}
fn selection_color(&self, _style: &Self::Style) -> Color {
*GANDALF_COLOR_NONE
}
}