Skip to content

Commit dc1616b

Browse files
authored
Merge pull request #2 from DashieTM/oxicedtheme
feat(theme): Use new custom theme
2 parents 49ceea2 + 5dbafdc commit dc1616b

File tree

5 files changed

+136
-38
lines changed

5 files changed

+136
-38
lines changed

.direnv/flake-profile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
flake-profile-4-link
1+
flake-profile-1-link
File renamed without changes.

Cargo.lock

Lines changed: 111 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ license = "GPL-3.0-only"
99
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1010

1111
[dependencies]
12-
oxiced = "0.4.0"
12+
oxiced = "0.5.0"
1313
iced = { version = "0.13.1", features = ["advanced", "canvas", "image", "svg"] }
14-
iced_layershell = "0.13.5"
14+
iced_layershell = "0.12.0"

src/main.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use iced_layershell::{
1212
reexport::{Anchor, KeyboardInteractivity, Layer},
1313
settings::{LayerShellSettings, Settings},
1414
};
15+
use oxiced::theme::theme::{get_derived_iced_theme, OXITHEME};
1516
use oxiced::{
16-
theme::get_theme,
1717
widgets::{
18-
common::{darken_color, lighten_color},
1918
oxi_button::{self, ButtonVariant},
2019
},
2120
};
@@ -74,12 +73,12 @@ impl TryInto<LayershellCustomActions> for Message {
7473
}
7574

7675
fn box_style(theme: &Theme) -> Style {
77-
let palette = theme.extended_palette();
76+
let palette = OXITHEME;
7877
Style {
79-
background: Some(iced::Background::Color(darken_color(
80-
palette.background.base.color,
81-
))),
82-
border: iced::border::rounded(10.0),
78+
background: Some(iced::Background::Color(
79+
palette.base
80+
)),
81+
border: iced::border::color(palette.primary).width(2.0).rounded(palette.border_radius),
8382
..container::rounded_box(theme)
8483
}
8584
}
@@ -153,7 +152,10 @@ fn mk_button<'a>(
153152
focused_action: &Action,
154153
) -> Element<'a, Message> {
155154
let handle = iced::widget::svg::Handle::from_path(svg_path(asset));
156-
let svg = iced::widget::svg(handle).content_fit(iced::ContentFit::Contain);
155+
let svg = iced::widget::svg(handle).content_fit(iced::ContentFit::Contain).style(move |_, _| {
156+
let palette = OXITHEME;
157+
iced::widget::svg::Style { color: Some(palette.primary) }
158+
});
157159
let is_focused = focused_action == &action;
158160
oxiced::widgets::oxi_button::button(
159161
iced::widget::row!(svg)
@@ -166,14 +168,16 @@ fn mk_button<'a>(
166168
.height(Length::Fill)
167169
.width(Length::Fill)
168170
.style(move |theme, status| {
169-
let palette = theme.extended_palette().primary;
170-
let default_style = oxi_button::primary_button(theme, status);
171+
let palette = OXITHEME;
172+
let default_style = oxi_button::row_entry(theme, status);
171173
let background = if status == Status::Hovered {
172-
default_style.background
173-
} else if status != Status::Hovered && is_focused {
174-
default_style.background
174+
Some(iced::Background::Color(palette.primary_bg_active))
175+
} else if status == Status::Pressed {
176+
Some(iced::Background::Color(palette.primary_bg_active))
177+
} else if is_focused {
178+
Some(iced::Background::Color(palette.primary_bg_hover))
175179
} else {
176-
Some(iced::Background::Color(lighten_color(palette.base.color)))
180+
Some(iced::Background::Color(palette.primary_bg))
177181
};
178182
iced::widget::button::Style {
179183
background,
@@ -192,7 +196,7 @@ impl Application for OxiShut {
192196
fn new(_flags: ()) -> (Self, Task<Message>) {
193197
(
194198
Self {
195-
theme: get_theme(),
199+
theme: get_derived_iced_theme(),
196200
focused_action: Action::ShutDown,
197201
},
198202
Task::none(),
@@ -270,11 +274,11 @@ impl Application for OxiShut {
270274
}
271275

272276
// remove the annoying background color
273-
fn style(&self, theme: &Self::Theme) -> iced_layershell::Appearance {
274-
let palette = theme.extended_palette();
277+
fn style(&self, _: &Self::Theme) -> iced_layershell::Appearance {
278+
let palette = OXITHEME;
275279
iced_layershell::Appearance {
276280
background_color: iced::Color::TRANSPARENT,
277-
text_color: palette.background.base.text,
281+
text_color: palette.text
278282
}
279283
}
280284

0 commit comments

Comments
 (0)