mirror of
https://github.com/veeso/termscp.git
synced 2026-09-25 21:41:20 -07:00
feat: replace dual progress bar components with single TransferProgressBar
This commit is contained in:
@@ -67,8 +67,7 @@ enum Id {
|
|||||||
MkdirPopup,
|
MkdirPopup,
|
||||||
NewfilePopup,
|
NewfilePopup,
|
||||||
OpenWithPopup,
|
OpenWithPopup,
|
||||||
ProgressBarFull,
|
TransferProgressBar,
|
||||||
ProgressBarPartial,
|
|
||||||
QuitPopup,
|
QuitPopup,
|
||||||
RenamePopup,
|
RenamePopup,
|
||||||
ReplacePopup,
|
ReplacePopup,
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ pub use misc::FooterBar;
|
|||||||
pub use popups::{
|
pub use popups::{
|
||||||
ATTR_FILES, ChmodPopup, CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, FatalPopup,
|
ATTR_FILES, ChmodPopup, CopyPopup, DeletePopup, DisconnectPopup, ErrorPopup, FatalPopup,
|
||||||
FileInfoPopup, FilterPopup, GotoPopup, KeybindingsPopup, MkdirPopup, NewfilePopup,
|
FileInfoPopup, FilterPopup, GotoPopup, KeybindingsPopup, MkdirPopup, NewfilePopup,
|
||||||
OpenWithPopup, ProgressBarFull, ProgressBarPartial, QuitPopup, RenamePopup, ReplacePopup,
|
OpenWithPopup, QuitPopup, RenamePopup, ReplacePopup, SaveAsPopup, SortingPopup, StatusBarLocal,
|
||||||
SaveAsPopup, SortingPopup, StatusBarLocal, StatusBarRemote, SymlinkPopup,
|
StatusBarRemote, SymlinkPopup, SyncBrowsingMkdirPopup, TransferProgressBar, WaitPopup,
|
||||||
SyncBrowsingMkdirPopup, WaitPopup, WalkdirWaitPopup, WatchedPathsList, WatcherPopup,
|
WalkdirWaitPopup, WatchedPathsList, WatcherPopup,
|
||||||
};
|
};
|
||||||
pub use transfer::{ExplorerFind, ExplorerFuzzy, ExplorerLocal, ExplorerRemote};
|
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::mkdir::{MkdirPopup, SyncBrowsingMkdirPopup};
|
||||||
pub use self::newfile::NewfilePopup;
|
pub use self::newfile::NewfilePopup;
|
||||||
pub use self::open_with::OpenWithPopup;
|
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::quit::QuitPopup;
|
||||||
pub use self::rename::RenamePopup;
|
pub use self::rename::RenamePopup;
|
||||||
pub use self::replace::ReplacePopup;
|
pub use self::replace::ReplacePopup;
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
use tui_realm_stdlib::ProgressBar;
|
use tui_realm_stdlib::ProgressBar;
|
||||||
use tuirealm::event::{Key, KeyEvent, KeyModifiers};
|
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 tuirealm::{Component, Event, MockComponent, NoUserEvent};
|
||||||
|
|
||||||
use crate::ui::activities::filetransfer::{Msg, TransferMsg};
|
use crate::ui::activities::filetransfer::{Msg, TransferMsg};
|
||||||
|
|
||||||
#[derive(MockComponent)]
|
#[derive(MockComponent)]
|
||||||
pub struct ProgressBarFull {
|
pub struct TransferProgressBar {
|
||||||
component: ProgressBar,
|
component: ProgressBar,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProgressBarFull {
|
impl TransferProgressBar {
|
||||||
pub fn new<S: Into<String>>(prog: f64, label: S, title: S, color: Color) -> Self {
|
pub fn new<S: Into<String>>(prog: f64, label: S, title: S, color: Color) -> Self {
|
||||||
Self {
|
Self {
|
||||||
component: ProgressBar::default()
|
component: ProgressBar::default()
|
||||||
.borders(
|
.borders(Borders::default().modifiers(BorderType::Rounded))
|
||||||
Borders::default()
|
|
||||||
.modifiers(BorderType::Rounded)
|
|
||||||
.sides(BorderSides::TOP | BorderSides::LEFT | BorderSides::RIGHT),
|
|
||||||
)
|
|
||||||
.foreground(color)
|
.foreground(color)
|
||||||
.label(label)
|
.label(label)
|
||||||
.progress(prog)
|
.progress(prog)
|
||||||
@@ -27,45 +23,7 @@ impl ProgressBarFull {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component<Msg, NoUserEvent> for ProgressBarFull {
|
impl Component<Msg, NoUserEvent> for TransferProgressBar {
|
||||||
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 {
|
|
||||||
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
||||||
if matches!(
|
if matches!(
|
||||||
ev,
|
ev,
|
||||||
|
|||||||
Reference in New Issue
Block a user