Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ impl App {
},
]
}
pub fn render(&self, show_icons: bool) -> impl Into<iced::Element<'_, Message>> {
pub fn render(&self, theme: &crate::config::Theme) -> impl Into<iced::Element<'_, Message>> {
let mut tile = Row::new().width(Fill).height(55);

if show_icons {
if theme.show_icons {
if let Some(icon) = &self.icons {
tile = tile
.push(Viewer::new(icon).height(35).width(35))
Expand All @@ -83,6 +83,7 @@ impl App {
Text::new(&self.name)
.height(Fill)
.width(Fill)
.color(theme.text_color(1.))
.align_y(Vertical::Center),
)
.on_press(Message::RunFunction(self.open_command.clone()))
Expand All @@ -98,7 +99,7 @@ impl App {
);

tile = tile
.push(container(Text::new(&self.desc)).padding(15))
.push(container(Text::new(&self.desc).color(theme.text_color(0.4))).padding(15))
.width(Fill);

container(tile)
Expand Down Expand Up @@ -204,7 +205,7 @@ impl Tile {
frontmost: None,
focused: false,
config: config.clone(),
theme: config.theme.to_owned().to_iced_theme(),
theme: config.theme.to_owned().into(),
open_hotkey_id: keybind_id,
},
Task::batch([open.map(|_| Message::OpenWindow)]),
Expand Down Expand Up @@ -394,8 +395,7 @@ impl Tile {

let mut search_results = Column::new();
for result in &self.results {
search_results =
search_results.push(result.render(self.config.theme.clone().show_icons));
search_results = search_results.push(result.render(&self.config.theme));
}

Column::new()
Expand Down
41 changes: 25 additions & 16 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,11 @@ impl Default for Theme {
}
}

impl Theme {
pub fn to_iced_theme(&self) -> iced::Theme {
let text_color = self.text_color;
let bg_color = self.background_color;
impl From<Theme> for iced::Theme {
fn from(value: Theme) -> Self {
let palette = iced::theme::Palette {
background: iced::Color {
r: bg_color.0,
g: bg_color.1,
b: bg_color.2,
a: self.background_opacity,
},
text: iced::Color {
r: text_color.0,
g: text_color.1,
b: text_color.2,
a: 1.,
},
background: value.bg_color(),
text: value.text_color(1.),
primary: iced::Color {
r: 0.22,
g: 0.55,
Expand Down Expand Up @@ -101,6 +89,27 @@ impl Theme {
}
}

impl Theme {
pub fn text_color(&self, opacity: f32) -> iced::Color {
let theme = self.to_owned();
iced::Color {
r: theme.text_color.0,
g: theme.text_color.1,
b: theme.text_color.2,
a: opacity,
}
}

pub fn bg_color(&self) -> iced::Color {
iced::Color {
r: self.background_color.0,
g: self.background_color.1,
b: self.background_color.2,
a: self.background_opacity,
}
}
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct Buffer {
Expand Down