From a73fdc4d0baa737e40406262e39dcd3dc1b208f0 Mon Sep 17 00:00:00 2001 From: Christian Visintin Date: Sat, 21 Mar 2026 20:43:51 +0100 Subject: [PATCH] feat: consolidate theme progress bar fields into single transfer_progress_bar --- src/config/serialization.rs | 3 +- src/config/themes.rs | 17 +++----- .../activities/filetransfer/lib/transfer.rs | 9 ++-- src/ui/activities/filetransfer/view/popups.rs | 2 +- src/ui/activities/setup.rs | 9 ++-- src/ui/activities/setup/actions.rs | 19 +++----- src/ui/activities/setup/components/theme.rs | 43 ++++--------------- src/ui/activities/setup/update.rs | 20 +++------ src/ui/activities/setup/view/theme.rs | 35 ++++----------- themes/catppuccin-frappe.toml | 3 +- themes/catppuccin-latte.toml | 3 +- themes/catppuccin-macchiato.toml | 3 +- themes/catppuccin-moka.toml | 3 +- themes/default.toml | 3 +- themes/earth-wind-fire.toml | 3 +- themes/horizon.toml | 3 +- themes/mono-bright.toml | 3 +- themes/mono-dark.toml | 3 +- themes/sugarplum.toml | 3 +- themes/ubuntu.toml | 3 +- themes/veeso.toml | 3 +- 21 files changed, 56 insertions(+), 137 deletions(-) diff --git a/src/config/serialization.rs b/src/config/serialization.rs index 7809d4b..cbc7f80 100644 --- a/src/config/serialization.rs +++ b/src/config/serialization.rs @@ -775,8 +775,7 @@ mod tests { transfer_local_explorer_highlighted = "Yellow" transfer_log_background = "255, 255, 255" transfer_log_window = "LightGreen" - transfer_progress_bar_full = "forestgreen" - transfer_progress_bar_partial = "Green" + transfer_progress_bar = "forestgreen" transfer_remote_explorer_background = "#f0f0f0" transfer_remote_explorer_foreground = "rgb(40, 40, 40)" transfer_remote_explorer_highlighted = "LightBlue" diff --git a/src/config/themes.rs b/src/config/themes.rs index da82f3c..32f938f 100644 --- a/src/config/themes.rs +++ b/src/config/themes.rs @@ -114,14 +114,11 @@ pub struct Theme { pub transfer_log_window: Color, #[serde( deserialize_with = "deserialize_color", - serialize_with = "serialize_color" + serialize_with = "serialize_color", + alias = "transfer_progress_bar_full", + alias = "transfer_progress_bar_partial" )] - pub transfer_progress_bar_full: Color, - #[serde( - deserialize_with = "deserialize_color", - serialize_with = "serialize_color" - )] - pub transfer_progress_bar_partial: Color, + pub transfer_progress_bar: Color, #[serde( deserialize_with = "deserialize_color", serialize_with = "serialize_color" @@ -176,8 +173,7 @@ impl Default for Theme { transfer_local_explorer_highlighted: Color::Yellow, transfer_log_background: Color::Reset, transfer_log_window: Color::LightGreen, - transfer_progress_bar_partial: Color::Green, - transfer_progress_bar_full: Color::Green, + transfer_progress_bar: Color::Green, transfer_remote_explorer_background: Color::Reset, transfer_remote_explorer_foreground: Color::Reset, transfer_remote_explorer_highlighted: Color::LightBlue, @@ -239,8 +235,7 @@ mod test { assert_eq!(theme.transfer_local_explorer_highlighted, Color::Yellow); assert_eq!(theme.transfer_log_background, Color::Reset); assert_eq!(theme.transfer_log_window, Color::LightGreen); - assert_eq!(theme.transfer_progress_bar_full, Color::Green); - assert_eq!(theme.transfer_progress_bar_partial, Color::Green); + assert_eq!(theme.transfer_progress_bar, Color::Green); assert_eq!(theme.transfer_remote_explorer_background, Color::Reset); assert_eq!(theme.transfer_remote_explorer_foreground, Color::Reset); assert_eq!(theme.transfer_remote_explorer_highlighted, Color::LightBlue); diff --git a/src/ui/activities/filetransfer/lib/transfer.rs b/src/ui/activities/filetransfer/lib/transfer.rs index 6a679a9..8af3238 100644 --- a/src/ui/activities/filetransfer/lib/transfer.rs +++ b/src/ui/activities/filetransfer/lib/transfer.rs @@ -142,18 +142,17 @@ impl TransferProgress { self.files_total <= 1 } + #[cfg(test)] pub fn bytes_written(&self) -> usize { self.bytes_written } + #[cfg(test)] pub fn files_completed(&self) -> usize { self.files_completed } - pub fn files_total(&self) -> usize { - self.files_total - } - + #[cfg(test)] pub fn files_started(&self) -> usize { self.files_started } @@ -381,7 +380,7 @@ mod test { progress.add_bytes(256); let display = progress.to_string(); - assert!(display.contains("/ 1.0 KB")); + assert!(display.contains("/ 1.0 KiB")); assert!(!display.contains('~')); } diff --git a/src/ui/activities/filetransfer/view/popups.rs b/src/ui/activities/filetransfer/view/popups.rs index 38812d4..39104ee 100644 --- a/src/ui/activities/filetransfer/view/popups.rs +++ b/src/ui/activities/filetransfer/view/popups.rs @@ -426,7 +426,7 @@ impl FileTransferActivity { &mut self, root_name: String, ) { - let prog_color = self.theme().transfer_progress_bar_full; + let prog_color = self.theme().transfer_progress_bar; ui_result(self.app.remount( Id::TransferProgressBar, Box::new(components::TransferProgressBar::new( diff --git a/src/ui/activities/setup.rs b/src/ui/activities/setup.rs index 1a6fb2b..8fcf1ad 100644 --- a/src/ui/activities/setup.rs +++ b/src/ui/activities/setup.rs @@ -103,8 +103,7 @@ pub enum IdTheme { MiscSave, MiscTitle, MiscWarn, - ProgBarFull, - ProgBarPartial, + ProgBar, StatusHidden, StatusSorting, StatusSync, @@ -225,10 +224,8 @@ pub enum ThemeMsg { MiscSaveBlurUp, MiscWarnBlurDown, MiscWarnBlurUp, - ProgBarFullBlurDown, - ProgBarFullBlurUp, - ProgBarPartialBlurDown, - ProgBarPartialBlurUp, + ProgBarBlurDown, + ProgBarBlurUp, StatusHiddenBlurDown, StatusHiddenBlurUp, StatusSortingBlurDown, diff --git a/src/ui/activities/setup/actions.rs b/src/ui/activities/setup/actions.rs index 8c1c149..76acd85 100644 --- a/src/ui/activities/setup/actions.rs +++ b/src/ui/activities/setup/actions.rs @@ -248,11 +248,8 @@ impl SetupActivity { IdTheme::LogWindow => { theme.transfer_log_window = color; } - IdTheme::ProgBarFull => { - theme.transfer_progress_bar_full = color; - } - IdTheme::ProgBarPartial => { - theme.transfer_progress_bar_partial = color; + IdTheme::ProgBar => { + theme.transfer_progress_bar = color; } IdTheme::StatusHidden => { theme.transfer_status_hidden = color; @@ -339,12 +336,9 @@ impl SetupActivity { let transfer_log_window = self .get_color(&Id::Theme(IdTheme::LogWindow)) .map_err(|_| Id::Theme(IdTheme::LogWindow))?; - let transfer_progress_bar_full = self - .get_color(&Id::Theme(IdTheme::ProgBarFull)) - .map_err(|_| Id::Theme(IdTheme::ProgBarFull))?; - let transfer_progress_bar_partial = self - .get_color(&Id::Theme(IdTheme::ProgBarPartial)) - .map_err(|_| Id::Theme(IdTheme::ProgBarPartial))?; + let transfer_progress_bar = self + .get_color(&Id::Theme(IdTheme::ProgBar)) + .map_err(|_| Id::Theme(IdTheme::ProgBar))?; let transfer_status_hidden = self .get_color(&Id::Theme(IdTheme::StatusHidden)) .map_err(|_| Id::Theme(IdTheme::StatusHidden))?; @@ -378,8 +372,7 @@ impl SetupActivity { theme.transfer_remote_explorer_highlighted = transfer_remote_explorer_highlighted; theme.transfer_log_background = transfer_log_background; theme.transfer_log_window = transfer_log_window; - theme.transfer_progress_bar_full = transfer_progress_bar_full; - theme.transfer_progress_bar_partial = transfer_progress_bar_partial; + theme.transfer_progress_bar = transfer_progress_bar; theme.transfer_status_hidden = transfer_status_hidden; theme.transfer_status_sorting = transfer_status_sorting; theme.transfer_status_sync_browsing = transfer_status_sync_browsing; diff --git a/src/ui/activities/setup/components/theme.rs b/src/ui/activities/setup/components/theme.rs index ef0ecad..6f2c344 100644 --- a/src/ui/activities/setup/components/theme.rs +++ b/src/ui/activities/setup/components/theme.rs @@ -649,50 +649,25 @@ impl Component for MiscWarn { } #[derive(MockComponent)] -pub struct ProgBarFull { +pub struct ProgBar { component: InputColor, } -impl ProgBarFull { - pub fn new(value: Color) -> Self { +impl ProgBar { + pub fn new(color: Color) -> Self { Self { component: InputColor::new( - "'Full transfer' Progress bar", - IdTheme::ProgBarFull, - value, - Msg::Theme(ThemeMsg::ProgBarFullBlurDown), - Msg::Theme(ThemeMsg::ProgBarFullBlurUp), + "Progress bar", + IdTheme::ProgBar, + color, + Msg::Theme(ThemeMsg::ProgBarBlurDown), + Msg::Theme(ThemeMsg::ProgBarBlurUp), ), } } } -impl Component for ProgBarFull { - fn on(&mut self, ev: Event) -> Option { - self.component.on(ev) - } -} - -#[derive(MockComponent)] -pub struct ProgBarPartial { - component: InputColor, -} - -impl ProgBarPartial { - pub fn new(value: Color) -> Self { - Self { - component: InputColor::new( - "'Partial transfer' Progress bar", - IdTheme::ProgBarPartial, - value, - Msg::Theme(ThemeMsg::ProgBarPartialBlurDown), - Msg::Theme(ThemeMsg::ProgBarPartialBlurUp), - ), - } - } -} - -impl Component for ProgBarPartial { +impl Component for ProgBar { fn on(&mut self, ev: Event) -> Option { self.component.on(ev) } diff --git a/src/ui/activities/setup/update.rs b/src/ui/activities/setup/update.rs index 2e86dad..24589ce 100644 --- a/src/ui/activities/setup/update.rs +++ b/src/ui/activities/setup/update.rs @@ -467,7 +467,7 @@ impl SetupActivity { } } ThemeMsg::ExplorerRemoteHgBlurDown => { - if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarFull)) { + if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBar)) { error!("Failed to activate component: {err}"); } } @@ -476,23 +476,13 @@ impl SetupActivity { error!("Failed to activate component: {err}"); } } - ThemeMsg::ProgBarFullBlurDown => { - if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarPartial)) { - error!("Failed to activate component: {err}"); - } - } - ThemeMsg::ProgBarFullBlurUp => { - if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteHg)) { - error!("Failed to activate component: {err}"); - } - } - ThemeMsg::ProgBarPartialBlurDown => { + ThemeMsg::ProgBarBlurDown => { if let Err(err) = self.app.active(&Id::Theme(IdTheme::LogBg)) { error!("Failed to activate component: {err}"); } } - ThemeMsg::ProgBarPartialBlurUp => { - if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarFull)) { + ThemeMsg::ProgBarBlurUp => { + if let Err(err) = self.app.active(&Id::Theme(IdTheme::ExplorerRemoteHg)) { error!("Failed to activate component: {err}"); } } @@ -502,7 +492,7 @@ impl SetupActivity { } } ThemeMsg::LogBgBlurUp => { - if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBarPartial)) { + if let Err(err) = self.app.active(&Id::Theme(IdTheme::ProgBar)) { error!("Failed to activate component: {err}"); } } diff --git a/src/ui/activities/setup/view/theme.rs b/src/ui/activities/setup/view/theme.rs index d28601f..8d9c661 100644 --- a/src/ui/activities/setup/view/theme.rs +++ b/src/ui/activities/setup/view/theme.rs @@ -184,8 +184,7 @@ impl SetupActivity { .constraints( [ Constraint::Length(1), // Title - Constraint::Length(3), // Full prog bar - Constraint::Length(3), // Partial prog bar + Constraint::Length(3), // prog bar Constraint::Length(3), // log bg Constraint::Length(3), // log window Constraint::Length(3), // status sorting @@ -202,39 +201,34 @@ impl SetupActivity { transfer_colors_layout_col2[0], ); self.app.view( - &Id::Theme(IdTheme::ProgBarFull), + &Id::Theme(IdTheme::ProgBar), f, transfer_colors_layout_col2[1], ); self.app.view( - &Id::Theme(IdTheme::ProgBarPartial), + &Id::Theme(IdTheme::LogBg), f, transfer_colors_layout_col2[2], ); self.app.view( - &Id::Theme(IdTheme::LogBg), + &Id::Theme(IdTheme::LogWindow), f, transfer_colors_layout_col2[3], ); self.app.view( - &Id::Theme(IdTheme::LogWindow), + &Id::Theme(IdTheme::StatusSorting), f, transfer_colors_layout_col2[4], ); self.app.view( - &Id::Theme(IdTheme::StatusSorting), + &Id::Theme(IdTheme::StatusHidden), f, transfer_colors_layout_col2[5], ); - self.app.view( - &Id::Theme(IdTheme::StatusHidden), - f, - transfer_colors_layout_col2[6], - ); self.app.view( &Id::Theme(IdTheme::StatusSync), f, - transfer_colors_layout_col2[7], + transfer_colors_layout_col2[6], ); // Popups self.view_popups(f); @@ -430,19 +424,8 @@ impl SetupActivity { error!("Failed to remount component: {err}"); } if let Err(err) = self.app.remount( - Id::Theme(IdTheme::ProgBarFull), - Box::new(components::ProgBarFull::new( - theme.transfer_progress_bar_full, - )), - vec![], - ) { - error!("Failed to remount component: {err}"); - } - if let Err(err) = self.app.remount( - Id::Theme(IdTheme::ProgBarPartial), - Box::new(components::ProgBarPartial::new( - theme.transfer_progress_bar_partial, - )), + Id::Theme(IdTheme::ProgBar), + Box::new(components::ProgBar::new(theme.transfer_progress_bar)), vec![], ) { error!("Failed to remount component: {err}"); diff --git a/themes/catppuccin-frappe.toml b/themes/catppuccin-frappe.toml index d02222d..1830282 100644 --- a/themes/catppuccin-frappe.toml +++ b/themes/catppuccin-frappe.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "#c6d0f5" transfer_local_explorer_highlighted = "#e5c890" transfer_log_background = "#303446" transfer_log_window = "#e5c890" -transfer_progress_bar_full = "##a6d189" -transfer_progress_bar_partial = "##a6d189" +transfer_progress_bar = "##a6d189" transfer_remote_explorer_background = "#303446" transfer_remote_explorer_foreground = "#c6d0f5" transfer_remote_explorer_highlighted = "#99d1db" diff --git a/themes/catppuccin-latte.toml b/themes/catppuccin-latte.toml index 3fa3b10..c5aa684 100644 --- a/themes/catppuccin-latte.toml +++ b/themes/catppuccin-latte.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "#4c4f69" transfer_local_explorer_highlighted = "#fe640b" transfer_log_background = "#eff1f5" transfer_log_window = "#179299" -transfer_progress_bar_full = "#40a02b" -transfer_progress_bar_partial = "#40a02b" +transfer_progress_bar = "#40a02b" transfer_remote_explorer_background = "#eff1f5" transfer_remote_explorer_foreground = "#4c4f69" transfer_remote_explorer_highlighted = "#1e66f5" diff --git a/themes/catppuccin-macchiato.toml b/themes/catppuccin-macchiato.toml index 6f347de..32ab4a8 100644 --- a/themes/catppuccin-macchiato.toml +++ b/themes/catppuccin-macchiato.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "#cad3f5" transfer_local_explorer_highlighted = "#f5a97f" transfer_log_background = "#cad3f5" transfer_log_window = "#a6da95" -transfer_progress_bar_full = "#a6da95" -transfer_progress_bar_partial = "#a6da95" +transfer_progress_bar = "#a6da95" transfer_remote_explorer_background = "#24273a" transfer_remote_explorer_foreground = "#cad3f5" transfer_remote_explorer_highlighted = "#8aadf4" diff --git a/themes/catppuccin-moka.toml b/themes/catppuccin-moka.toml index 3eb8685..1d554b0 100644 --- a/themes/catppuccin-moka.toml +++ b/themes/catppuccin-moka.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "#cdd6f4" transfer_local_explorer_highlighted = "#fab387" transfer_log_background = "#1e1e2e" transfer_log_window = "#a6e3a1" -transfer_progress_bar_full = "#a6e3a1" -transfer_progress_bar_partial = "#a6e3a1" +transfer_progress_bar = "#a6e3a1" transfer_remote_explorer_background = "#1e1e2e" transfer_remote_explorer_foreground = "#cdd6f4" transfer_remote_explorer_highlighted = "#89b4fa" diff --git a/themes/default.toml b/themes/default.toml index 9f54d04..6895e9e 100644 --- a/themes/default.toml +++ b/themes/default.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "Default" transfer_local_explorer_highlighted = "Yellow" transfer_log_background = "Default" transfer_log_window = "LightGreen" -transfer_progress_bar_full = "Green" -transfer_progress_bar_partial = "Green" +transfer_progress_bar = "Green" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "Default" transfer_remote_explorer_highlighted = "LightBlue" diff --git a/themes/earth-wind-fire.toml b/themes/earth-wind-fire.toml index c31d16a..ee2b868 100644 --- a/themes/earth-wind-fire.toml +++ b/themes/earth-wind-fire.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "Default" transfer_local_explorer_highlighted = "aquamarine" transfer_log_background = "Default" transfer_log_window = "#c43bff" -transfer_progress_bar_full = "deeppink" -transfer_progress_bar_partial = "turquoise" +transfer_progress_bar = "deeppink" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "Default" transfer_remote_explorer_highlighted = "greenyellow" diff --git a/themes/horizon.toml b/themes/horizon.toml index 97bfbfd..33485f9 100644 --- a/themes/horizon.toml +++ b/themes/horizon.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "lightcoral" transfer_local_explorer_highlighted = "coral" transfer_log_background = "Default" transfer_log_window = "royalblue" -transfer_progress_bar_full = "hotpink" -transfer_progress_bar_partial = "deeppink" +transfer_progress_bar = "hotpink" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "lightsalmon" transfer_remote_explorer_highlighted = "salmon" diff --git a/themes/mono-bright.toml b/themes/mono-bright.toml index 9b8d8d7..be11100 100644 --- a/themes/mono-bright.toml +++ b/themes/mono-bright.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "Default" transfer_local_explorer_highlighted = "#bbbbbb" transfer_log_background = "Default" transfer_log_window = "black" -transfer_progress_bar_full = "black" -transfer_progress_bar_partial = "black" +transfer_progress_bar = "black" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "Default" transfer_remote_explorer_highlighted = "#bbbbbb" diff --git a/themes/mono-dark.toml b/themes/mono-dark.toml index 15b93f4..e1f8dd9 100644 --- a/themes/mono-dark.toml +++ b/themes/mono-dark.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "Default" transfer_local_explorer_highlighted = "white" transfer_log_background = "Default" transfer_log_window = "white" -transfer_progress_bar_full = "white" -transfer_progress_bar_partial = "white" +transfer_progress_bar = "white" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "Default" transfer_remote_explorer_highlighted = "white" diff --git a/themes/sugarplum.toml b/themes/sugarplum.toml index 0ecb617..ad5b0cc 100644 --- a/themes/sugarplum.toml +++ b/themes/sugarplum.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "pink" transfer_local_explorer_highlighted = "hotpink" transfer_log_background = "Default" transfer_log_window = "palevioletred" -transfer_progress_bar_full = "hotpink" -transfer_progress_bar_partial = "deeppink" +transfer_progress_bar = "hotpink" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "plum" transfer_remote_explorer_highlighted = "violet" diff --git a/themes/ubuntu.toml b/themes/ubuntu.toml index 0fb50fd..1d7e9a5 100644 --- a/themes/ubuntu.toml +++ b/themes/ubuntu.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "Default" transfer_local_explorer_highlighted = "Yellow" transfer_log_background = "Default" transfer_log_window = "lawngreen" -transfer_progress_bar_full = "lawngreen" -transfer_progress_bar_partial = "lawngreen" +transfer_progress_bar = "lawngreen" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "Default" transfer_remote_explorer_highlighted = "turquoise" diff --git a/themes/veeso.toml b/themes/veeso.toml index c393382..a8c2cf1 100644 --- a/themes/veeso.toml +++ b/themes/veeso.toml @@ -17,8 +17,7 @@ transfer_local_explorer_foreground = "Default" transfer_local_explorer_highlighted = "orange" transfer_log_background = "Default" transfer_log_window = "limegreen" -transfer_progress_bar_full = "lawngreen" -transfer_progress_bar_partial = "limegreen" +transfer_progress_bar = "lawngreen" transfer_remote_explorer_background = "Default" transfer_remote_explorer_foreground = "Default" transfer_remote_explorer_highlighted = "turquoise"