mirror of
https://github.com/veeso/termscp.git
synced 2026-04-02 00:02:17 -07:00
feat: replace dual progress bar components with single TransferProgressBar
This commit is contained in:
@@ -67,8 +67,7 @@ enum Id {
|
||||
MkdirPopup,
|
||||
NewfilePopup,
|
||||
OpenWithPopup,
|
||||
ProgressBarFull,
|
||||
ProgressBarPartial,
|
||||
TransferProgressBar,
|
||||
QuitPopup,
|
||||
RenamePopup,
|
||||
ReplacePopup,
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user