Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Remove compile-time width from footer
Erik Kundt committed 2 years ago
commit 2ee9528cc3f6d2be7dce8d7e793d24343477af88
parent 4880ba7f5a09182a3e80ec7dcbd98e3c08889a1b
4 files changed +35 -23
modified bin/commands/inbox/select/ui.rs
@@ -412,12 +412,14 @@ impl Notifications {
                    frame,
                    area,
                    FooterProps {
-
                        cells: [search.into(), block.clone().into(), progress.clone().into()],
+
                        cells: [search.into(), block.clone().into(), progress.clone().into()]
+
                            .to_vec(),
                        widths: [
                            Constraint::Fill(1),
                            Constraint::Min(block.width() as u16),
                            Constraint::Min(4),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        focus: self.props.focus,
                        cutoff: self.props.cutoff,
                        cutoff_after: self.props.cutoff_after,
@@ -434,13 +436,15 @@ impl Notifications {
                            seen.clone().into(),
                            unseen.clone().into(),
                            progress.clone().into(),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        widths: [
                            Constraint::Fill(1),
                            Constraint::Min(seen.width() as u16),
                            Constraint::Min(unseen.width() as u16),
                            Constraint::Min(4),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        focus: self.props.focus,
                        cutoff: self.props.cutoff,
                        cutoff_after: self.props.cutoff_after,
@@ -800,8 +804,8 @@ impl<'a> Render<()> for Help<'a> {
            frame,
            footer_area,
            FooterProps {
-
                cells: [String::new().into(), progress.clone().into()],
-
                widths: [Constraint::Fill(1), Constraint::Min(4)],
+
                cells: [String::new().into(), progress.clone().into()].to_vec(),
+
                widths: [Constraint::Fill(1), Constraint::Min(4)].to_vec(),
                focus: self.props.focus,
                cutoff: usize::MAX,
                cutoff_after: usize::MAX,
modified bin/commands/issue/select/ui.rs
@@ -432,12 +432,14 @@ impl Issues {
                    frame,
                    area,
                    FooterProps {
-
                        cells: [search.into(), block.clone().into(), progress.clone().into()],
+
                        cells: [search.into(), block.clone().into(), progress.clone().into()]
+
                            .to_vec(),
                        widths: [
                            Constraint::Fill(1),
                            Constraint::Min(block.width() as u16),
                            Constraint::Min(4),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        focus: self.props.focus,
                        cutoff: self.props.cutoff,
                        cutoff_after: self.props.cutoff_after,
@@ -455,14 +457,16 @@ impl Issues {
                            closed.clone().into(),
                            sum.clone().into(),
                            progress.clone().into(),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        widths: [
                            Constraint::Fill(1),
                            Constraint::Min(open.width() as u16),
                            Constraint::Min(closed.width() as u16),
                            Constraint::Min(sum.width() as u16),
                            Constraint::Min(4),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        focus: self.props.focus,
                        cutoff: self.props.cutoff,
                        cutoff_after: self.props.cutoff_after,
@@ -822,8 +826,8 @@ impl<'a> Render<()> for Help<'a> {
            frame,
            footer_area,
            FooterProps {
-
                cells: [String::new().into(), progress.clone().into()],
-
                widths: [Constraint::Fill(1), Constraint::Min(4)],
+
                cells: [String::new().into(), progress.clone().into()].to_vec(),
+
                widths: [Constraint::Fill(1), Constraint::Min(4)].to_vec(),
                focus: self.props.focus,
                cutoff: usize::MAX,
                cutoff_after: usize::MAX,
modified bin/commands/patch/select/ui.rs
@@ -457,12 +457,14 @@ impl Patches {
                    frame,
                    area,
                    FooterProps {
-
                        cells: [search.into(), block.clone().into(), progress.clone().into()],
+
                        cells: [search.into(), block.clone().into(), progress.clone().into()]
+
                            .to_vec(),
                        widths: [
                            Constraint::Fill(1),
                            Constraint::Min(block.width() as u16),
                            Constraint::Min(4),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        focus: self.props.focus,
                        cutoff: self.props.cutoff,
                        cutoff_after: self.props.cutoff_after,
@@ -482,7 +484,8 @@ impl Patches {
                            archived.clone().into(),
                            sum.clone().into(),
                            progress.clone().into(),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        widths: [
                            Constraint::Fill(1),
                            Constraint::Min(draft.width() as u16),
@@ -491,7 +494,8 @@ impl Patches {
                            Constraint::Min(archived.width() as u16),
                            Constraint::Min(sum.width() as u16),
                            Constraint::Min(4),
-
                        ],
+
                        ]
+
                        .to_vec(),
                        focus: self.props.focus,
                        cutoff: self.props.cutoff,
                        cutoff_after: self.props.cutoff_after,
@@ -859,8 +863,8 @@ impl<'a> Render<()> for Help<'a> {
            frame,
            footer_area,
            FooterProps {
-
                cells: [String::new().into(), progress.clone().into()],
-
                widths: [Constraint::Fill(1), Constraint::Min(4)],
+
                cells: [String::new().into(), progress.clone().into()].to_vec(),
+
                widths: [Constraint::Fill(1), Constraint::Min(4)].to_vec(),
                focus: self.props.focus,
                cutoff: usize::MAX,
                cutoff_after: usize::MAX,
modified src/ui/widget/container.rs
@@ -13,9 +13,9 @@ use crate::ui::theme::style;
use super::{Column, Render, Widget};

#[derive(Debug)]
-
pub struct FooterProps<'a, const W: usize> {
-
    pub cells: [Text<'a>; W],
-
    pub widths: [Constraint; W],
+
pub struct FooterProps<'a> {
+
    pub cells: Vec<Text<'a>>,
+
    pub widths: Vec<Constraint>,
    pub cutoff: usize,
    pub cutoff_after: usize,
    pub focus: bool,
@@ -71,8 +71,8 @@ impl<A> Footer<A> {
    }
}

-
impl<'a, A, const W: usize> Render<FooterProps<'a, W>> for Footer<A> {
-
    fn render<B: Backend>(&self, frame: &mut ratatui::Frame, area: Rect, props: FooterProps<W>) {
+
impl<'a, A> Render<FooterProps<'a>> for Footer<A> {
+
    fn render<B: Backend>(&self, frame: &mut ratatui::Frame, area: Rect, props: FooterProps) {
        let widths = props
            .widths
            .into_iter()