feat: replace dual progress bar components with single TransferProgressBar

This commit is contained in:
Christian Visintin
2026-03-21 17:11:24 +01:00
parent 12b5d86191
commit 7066f64cc6
4 changed files with 10 additions and 53 deletions

View File

@@ -67,8 +67,7 @@ enum Id {
MkdirPopup,
NewfilePopup,
OpenWithPopup,
ProgressBarFull,
ProgressBarPartial,
TransferProgressBar,
QuitPopup,
RenamePopup,
ReplacePopup,

View File

@@ -20,9 +20,9 @@ pub use misc::FooterBar;
pub use popups::{
ATTR_FILES, ChmodPopup, CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, FatalPopup,
FileInfoPopup, FilterPopup, GotoPopup, KeybindingsPopup, MkdirPopup, NewfilePopup,
OpenWithPopup, ProgressBarFull, ProgressBarPartial, QuitPopup, RenamePopup, ReplacePopup,
SaveAsPopup, SortingPopup, StatusBarLocal, StatusBarRemote, SymlinkPopup,
SyncBrowsingMkdirPopup, WaitPopup, WalkdirWaitPopup, WatchedPathsList, WatcherPopup,
OpenWithPopup, QuitPopup, RenamePopup, ReplacePopup, SaveAsPopup, SortingPopup, StatusBarLocal,
StatusBarRemote, SymlinkPopup, SyncBrowsingMkdirPopup, TransferProgressBar, WaitPopup,
WalkdirWaitPopup, WatchedPathsList, WatcherPopup,
};
pub use transfer::{ExplorerFind, ExplorerFuzzy, ExplorerLocal, ExplorerRemote};

View File

@@ -37,7 +37,7 @@ pub use self::keybindings::KeybindingsPopup;
pub use self::mkdir::{MkdirPopup, SyncBrowsingMkdirPopup};
pub use self::newfile::NewfilePopup;
pub use self::open_with::OpenWithPopup;
pub use self::progress_bar::{ProgressBarFull, ProgressBarPartial};
pub use self::progress_bar::TransferProgressBar;
pub use self::quit::QuitPopup;
pub use self::rename::RenamePopup;
pub use self::replace::ReplacePopup;

View File

@@ -1,24 +1,20 @@
use tui_realm_stdlib::ProgressBar;
use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderSides, BorderType, Borders, Color};
use tuirealm::props::{Alignment, BorderType, Borders, Color};
use tuirealm::{Component, Event, MockComponent, NoUserEvent};
use crate::ui::activities::filetransfer::{Msg, TransferMsg};
#[derive(MockComponent)]
pub struct ProgressBarFull {
pub struct TransferProgressBar {
component: ProgressBar,
}
impl ProgressBarFull {
impl TransferProgressBar {
pub fn new<S: Into<String>>(prog: f64, label: S, title: S, color: Color) -> Self {
Self {
component: ProgressBar::default()
.borders(
Borders::default()
.modifiers(BorderType::Rounded)
.sides(BorderSides::TOP | BorderSides::LEFT | BorderSides::RIGHT),
)
.borders(Borders::default().modifiers(BorderType::Rounded))
.foreground(color)
.label(label)
.progress(prog)
@@ -27,45 +23,7 @@ impl ProgressBarFull {
}
}
impl Component<Msg, NoUserEvent> for ProgressBarFull {
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
if matches!(
ev,
Event::Keyboard(KeyEvent {
code: Key::Char('c'),
modifiers: KeyModifiers::CONTROL
})
) {
Some(Msg::Transfer(TransferMsg::AbortTransfer))
} else {
None
}
}
}
#[derive(MockComponent)]
pub struct ProgressBarPartial {
component: ProgressBar,
}
impl ProgressBarPartial {
pub fn new<S: Into<String>>(prog: f64, label: S, title: S, color: Color) -> Self {
Self {
component: ProgressBar::default()
.borders(
Borders::default()
.modifiers(BorderType::Rounded)
.sides(BorderSides::BOTTOM | BorderSides::LEFT | BorderSides::RIGHT),
)
.foreground(color)
.label(label)
.progress(prog)
.title(title, Alignment::Center),
}
}
}
impl Component<Msg, NoUserEvent> for ProgressBarPartial {
impl Component<Msg, NoUserEvent> for TransferProgressBar {
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
if matches!(
ev,