Skip to content

Commit

Permalink
program can figure out lightest and darkest mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Redhawk18 committed Aug 13, 2023
1 parent 34138b3 commit 145c801
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/gui/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub type Element<'msg, Message> = iced::Element<'msg, Message, Renderer>;
#[derive(Clone)]
pub struct Theme {
colors: Colors,
is_light: bool,
}

impl Default for Theme {
Expand All @@ -29,6 +30,7 @@ impl Default for Theme {
secondary: Shades::new(pigment.secondary),
text: Shades::new(pigment.text),
},
is_light: shades::is_light(pigment.background),
}
}
}
Expand Down Expand Up @@ -216,7 +218,7 @@ impl text_input::StyleSheet for Theme {

fn placeholder_color(&self, style: &Self::Style) -> iced::Color {
match style {
TextInput::Primary => self.colors.text.light, //TODO lightest
TextInput::Primary => if self.is_light {self.colors.text.lightest} else {self.colors.text.darkest}
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/gui/theme/pigment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ impl Default for Pigment {
fn default() -> Pigment {
Pigment {
//day theme
accent: hex_to_color("#f8073b").unwrap(),
background: hex_to_color("#fafafa").unwrap(),
primary: hex_to_color("#f9682f").unwrap(),
secondary: hex_to_color("#fef2cd").unwrap(),
text: hex_to_color("#050505").unwrap(),
// accent: hex_to_color("#f8073b").unwrap(),
// background: hex_to_color("#fafafa").unwrap(),
// primary: hex_to_color("#f9682f").unwrap(),
// secondary: hex_to_color("#fef2cd").unwrap(),
// text: hex_to_color("#050505").unwrap(),

//night theme
// accent: hex_to_color("#928fd6").unwrap(),
// background: hex_to_color("#050505").unwrap(),
// primary: hex_to_color("#2a4b74").unwrap(),
// secondary: hex_to_color("#0e0e25").unwrap(),
// text: hex_to_color("#fafafa").unwrap(),
accent: hex_to_color("#928fd6").unwrap(),
background: hex_to_color("#050505").unwrap(),
primary: hex_to_color("#2a4b74").unwrap(),
secondary: hex_to_color("#0e0e25").unwrap(),
text: hex_to_color("#fafafa").unwrap(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/theme/shades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ fn lighten(color: Color, amount: f32) -> Color {
from_hsl(hsl)
}

pub fn is_dark(color: Color) -> bool {
to_hsl(color).lightness < 0.5
pub fn is_light(color: Color) -> bool {
to_hsl(color).lightness > 0.5
}

0 comments on commit 145c801

Please sign in to comment.