Skip to content

Commit

Permalink
fix: theme
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
  • Loading branch information
ryanabx committed Aug 22, 2024
1 parent aeafcfc commit a74688a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 106 deletions.
91 changes: 20 additions & 71 deletions src/app_tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ fn get_horizontal_rule<'a>(
} else {
iced::widget::container(
iced::widget::horizontal_rule(1)
.style(|_| iced::widget::rule::Style {
color: Color::WHITE,
.style(|theme: &Theme| iced::widget::rule::Style {
color: theme.palette().primary,
width: 2,
radius: 4.into(),
fill_mode: iced::widget::rule::FillMode::Full,
Expand All @@ -220,81 +220,30 @@ fn get_default_icon() -> Option<PathBuf> {
}

fn tray_button_style<'a>(
_theme: &Theme,
theme: &Theme,
status: button::Status,
app_info: &ApplicationGroup,
active_window: &Option<&WindowHandle>,
) -> button::Style {
let (border_color, background_color) = if app_info.toplevels.is_empty() {
(
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: if matches!(status, button::Status::Hovered | button::Status::Pressed) {
0.11
} else {
0.0
},
},
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: if matches!(status, button::Status::Hovered | button::Status::Pressed) {
0.1
} else {
0.0
},
},
)
let mut border_color = theme.palette().primary;
let mut background_color = theme.palette().primary;
(border_color.a, background_color.a) = if app_info.toplevels.is_empty() {
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
(0.11, 0.1)
} else {
(0.0, 0.0)
}
} else if active_window.is_some_and(|x| app_info.toplevels.contains_key(x)) {
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
(0.21, 0.2)
} else {
(0.11, 0.1)
}
} else {
if active_window.is_some_and(|x| app_info.toplevels.contains_key(x)) {
(
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: if matches!(status, button::Status::Hovered | button::Status::Pressed) {
0.21
} else {
0.11
},
},
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: if matches!(status, button::Status::Hovered | button::Status::Pressed) {
0.2
} else {
0.1
},
},
)
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
(0.11, 0.1)
} else {
(
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: if matches!(status, button::Status::Hovered | button::Status::Pressed) {
0.11
} else {
0.06
},
},
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: if matches!(status, button::Status::Hovered | button::Status::Pressed) {
0.1
} else {
0.05
},
},
)
(0.06, 0.05)
}
};

Expand Down
32 changes: 6 additions & 26 deletions src/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl<'a> Panel<'a> {

#[derive(Clone, Debug)]
pub enum Message {
Panic,
AppTray(AppTrayMessage),
SettingsTray(SettingsTrayMessage),
}
Expand All @@ -48,15 +47,16 @@ impl<'a> Application for Panel<'a> {
(Panel::new(flags), Command::<self::Message>::none())
}

fn theme(&self, _id: iced::window::Id) -> Self::Theme {
Theme::Dark
}

fn title(&self, _id: iced::window::Id) -> String {
"Window".into()
}

fn update(&mut self, message: Self::Message) -> iced::Command<Self::Message> {
match message {
Message::Panic => {
panic!("Panic button pressed hehe");
}
Message::AppTray(app_tray_msg) => self
.app_tray
.handle_message(app_tray_msg)
Expand All @@ -83,20 +83,14 @@ impl<'a> Application for Panel<'a> {
bottom: 0.0,
});
iced::widget::container(column![
iced::widget::horizontal_rule(1).style(|_| iced::widget::rule::Style {
color: Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: 0.3,
},
iced::widget::horizontal_rule(1).style(|theme: &Theme| iced::widget::rule::Style {
color: theme.palette().primary.inverse(),
width: 1,
radius: Radius::from(0),
fill_mode: iced::widget::rule::FillMode::Full
}),
panel_items
])
.style(|theme| self.panel_style(theme))
.fill()
.into()
}
Expand All @@ -108,17 +102,3 @@ impl<'a> Application for Panel<'a> {
])
}
}

impl<'a> Panel<'a> {
fn panel_style(&self, _theme: &Theme) -> iced::widget::container::Style {
iced::widget::container::Style {
background: Some(Background::Color(Color {
r: 30.0 / 256.0,
g: 30.0 / 256.0,
b: 30.0 / 256.0,
a: 1.0,
})),
..Default::default()
}
}
}
10 changes: 1 addition & 9 deletions src/settings_tray/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ impl Clock {
iced::widget::container(column![
iced::widget::text!("{}", self.time)
.horizontal_alignment(iced::alignment::Horizontal::Center)
.size(14)
.style(white_text),
.size(14),
iced::widget::text!("{}", self.date)
.horizontal_alignment(iced::alignment::Horizontal::Center)
.size(10)
.style(white_text)
])
.center_y(Length::Fill)
.into()
Expand Down Expand Up @@ -91,9 +89,3 @@ impl Clock {
)
}
}

fn white_text(_theme: &iced::Theme) -> iced::widget::text::Style {
Style {
color: Some(Color::WHITE),
}
}

0 comments on commit a74688a

Please sign in to comment.