Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
all: Progress display
Merged did:key:z6MkgFq6...nBGz opened 2 years ago

lib: Add another progress span

patch: Improve selection progress rendering

inbox: Improve selection progress rendering

issue: Improve selection progress rendering

4 files changed +43 -7 1365b5e5 70208c35
modified bin/commands/inbox/flux/select/ui.rs
@@ -346,13 +346,23 @@ impl Notifications {
                    .magenta()
                    .dim(),
                span::default(" Unseen".to_string()).dim(),
+
                span::default(" | ".to_string()).style(style::border(self.props.focus)),
+
                span::default("Σ ".to_string()).dim(),
+
                span::default(self.props.notifications.len().to_string()).dim(),
            ]
            .to_vec(),
        )
        .alignment(Alignment::Right);

        let (step, len) = self.table.progress(self.props.notifications.len());
-
        let progress = span::progress(step, len, false);
+
        let progress = Line::from(
+
            [
+
                span::default("| ".to_string()).style(style::border(self.props.focus)),
+
                span::progress(step, len),
+
            ]
+
            .to_vec(),
+
        )
+
        .alignment(Alignment::Left);

        self.footer.render::<B>(
            frame,
@@ -362,7 +372,7 @@ impl Notifications {
                widths: [
                    Constraint::Fill(1),
                    Constraint::Fill(1),
-
                    Constraint::Length(progress.width() as u16),
+
                    Constraint::Length(7),
                ],
                focus: self.props.focus,
                cutoff: self.props.cutoff,
modified bin/commands/issue/flux/select/ui.rs
@@ -350,13 +350,23 @@ impl Issues {
                    .magenta()
                    .dim(),
                span::default(" Closed".to_string()).dim(),
+
                span::default(" | ".to_string()).style(style::border(self.props.focus)),
+
                span::default("Σ ".to_string()).dim(),
+
                span::default(self.props.issues.len().to_string()).dim(),
            ]
            .to_vec(),
        )
        .alignment(Alignment::Right);

        let (step, len) = self.table.progress(self.props.issues.len());
-
        let progress = span::progress(step, len, false);
+
        let progress = Line::from(
+
            [
+
                span::default("| ".to_string()).style(style::border(self.props.focus)),
+
                span::progress(step, len),
+
            ]
+
            .to_vec(),
+
        )
+
        .alignment(Alignment::Left);

        self.footer.render::<B>(
            frame,
@@ -366,7 +376,7 @@ impl Issues {
                widths: [
                    Constraint::Fill(1),
                    Constraint::Fill(1),
-
                    Constraint::Length(progress.width() as u16),
+
                    Constraint::Length(7),
                ],
                focus: self.props.focus,
                cutoff: self.props.cutoff,
modified bin/commands/patch/flux/select/ui.rs
@@ -391,13 +391,23 @@ impl Patches {
                    .yellow()
                    .dim(),
                span::default(" Archived".to_string()).dim(),
+
                span::default(" | ".to_string()).style(style::border(self.props.focus)),
+
                span::default("Σ ".to_string()).dim(),
+
                span::default(self.props.patches.len().to_string()).dim(),
            ]
            .to_vec(),
        )
        .alignment(Alignment::Right);

        let (step, len) = self.table.progress(self.props.patches.len());
-
        let progress = span::progress(step, len, false);
+
        let progress = Line::from(
+
            [
+
                span::default("| ".to_string()).style(style::border(self.props.focus)),
+
                span::progress(step, len),
+
            ]
+
            .to_vec(),
+
        )
+
        .alignment(Alignment::Left);

        self.footer.render::<B>(
            frame,
@@ -407,7 +417,7 @@ impl Patches {
                widths: [
                    Constraint::Fill(1),
                    Constraint::Fill(1),
-
                    Constraint::Length(progress.width() as u16),
+
                    Constraint::Length(7),
                ],
                focus: self.props.focus,
                cutoff: self.props.cutoff,
modified src/flux/ui/span.rs
@@ -56,7 +56,7 @@ pub fn notification_type(content: String) -> Span<'static> {
    default(content).style(style::gray().dim())
}

-
pub fn progress(step: usize, len: usize, fill_zeros: bool) -> Span<'static> {
+
pub fn step(step: usize, len: usize, fill_zeros: bool) -> Span<'static> {
    if fill_zeros {
        if len > 10 {
            badge(format!("{:-02}/{:-02}", step, len))
@@ -73,3 +73,9 @@ pub fn progress(step: usize, len: usize, fill_zeros: bool) -> Span<'static> {
        badge(format!("{}/{}", step, len))
    }
}
+

+
pub fn progress(step: usize, len: usize) -> Span<'static> {
+
    let progress = step as f32 / len as f32 * 100_f32;
+
    let progress = progress as usize;
+
    default(format!("{}%", progress)).dim()
+
}