From 406b0c89b1ed9c6b151923b547eb10394f73f9b5 Mon Sep 17 00:00:00 2001 From: B0ney <40839054+B0ney@users.noreply.github.com> Date: Sat, 6 Apr 2024 14:05:29 +0100 Subject: [PATCH] minor refactoring --- src/screen/entry.rs | 3 +-- src/style/checkbox.rs | 16 ++++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/screen/entry.rs b/src/screen/entry.rs index 5cf65120..7be02de4 100644 --- a/src/screen/entry.rs +++ b/src/screen/entry.rs @@ -180,8 +180,7 @@ impl Entries { fn view_entry((index, entry): (usize, &Entry)) -> Element { 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()); diff --git a/src/style/checkbox.rs b/src/style/checkbox.rs index ec1b4985..35295449 100644 --- a/src/style/checkbox.rs +++ b/src/style/checkbox.rs @@ -8,7 +8,7 @@ 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 { @@ -16,7 +16,7 @@ impl Catalog for Theme { } } -pub fn primary(theme: &Theme, status: Status) -> Style { +pub fn entry(theme: &Theme, status: Status) -> Style { let p = theme.palette(); match status { @@ -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) -} +} \ No newline at end of file