Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Apr 6, 2024
1 parent 8f2542b commit 406b0c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/screen/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ impl Entries {

fn view_entry((index, entry): (usize, &Entry)) -> Element<Message> {
let check = checkbox("", entry.selected)
.on_toggle(move |selected| Message::Select { index, selected })
.style(style::checkbox::entry);
.on_toggle(move |selected| Message::Select { index, selected });

let filename = text_adv(entry.filename());

Expand Down
16 changes: 4 additions & 12 deletions src/style/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ impl Catalog for Theme {
type Class<'a> = StyleFn<'a, Self>;

fn default<'a>() -> Self::Class<'a> {
Box::new(primary)
Box::new(entry)
}

fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
class(self, status)
}
}

pub fn primary(theme: &Theme, status: Status) -> Style {
pub fn entry(theme: &Theme, status: Status) -> Style {
let p = theme.palette();

match status {
Expand Down Expand Up @@ -47,17 +47,9 @@ pub fn inverted(theme: &Theme, status: Status) -> Style {
let p = theme.palette();

match status {
Status::Active { .. } | Status::Disabled { .. } => Style {
background: p.foreground.into(),
..primary(theme, status)
},
Status::Hovered { .. } => Style {
Status::Active { .. } | Status::Disabled { .. } | Status::Hovered { .. } => Style {
background: p.foreground.into(),
..primary(theme, status)
},
}
}

pub fn entry(theme: &Theme, status: Status) -> Style {
primary(theme, status)
}
}

0 comments on commit 406b0c8

Please sign in to comment.