Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
lib: Introduce footer block without top border
Erik Kundt committed 1 year ago
commit c0e1d0316776990049c9ea1d2536bce6e56fe531
parent 67192825db72ead4280c99e508b31aaf7b3afbb6
2 files changed +12 -5
modified src/ui/ext.rs
@@ -115,7 +115,7 @@ impl Widget for HeaderBlock {

#[derive(Clone)]
pub enum FooterBlockType {
-
    Single,
+
    Single { top: bool },
    Begin,
    End,
    Repeat,
@@ -138,8 +138,8 @@ pub struct FooterBlock {
impl Default for FooterBlock {
    fn default() -> Self {
        Self {
-
            block_type: FooterBlockType::Single,
-
            borders: Self::borders(FooterBlockType::Single),
+
            block_type: FooterBlockType::Single { top: true },
+
            borders: Self::borders(FooterBlockType::Single { top: true }),
            border_style: Default::default(),
            border_type: BorderType::Rounded,
            style: Default::default(),
@@ -171,7 +171,14 @@ impl FooterBlock {

    fn borders(block_type: FooterBlockType) -> Borders {
        match block_type {
-
            FooterBlockType::Single | FooterBlockType::Begin => Borders::ALL,
+
            FooterBlockType::Single { top } => {
+
                if top {
+
                    Borders::ALL
+
                } else {
+
                    Borders::LEFT | Borders::RIGHT | Borders::BOTTOM
+
                }
+
            }
+
            FooterBlockType::Begin => Borders::ALL,
            FooterBlockType::End | FooterBlockType::Repeat => {
                Borders::TOP | Borders::RIGHT | Borders::BOTTOM
            }
modified src/ui/widget/container.rs
@@ -336,7 +336,7 @@ impl<'a: 'static, S, M> View for Footer<S, M> {

        for (i, (cell, area)) in cells.into_iter().enumerate() {
            let block_type = match i {
-
                0 if len == 1 => FooterBlockType::Single,
+
                0 if len == 1 => FooterBlockType::Single { top: true },
                0 => FooterBlockType::Begin,
                _ if i == last => FooterBlockType::End,
                _ => FooterBlockType::Repeat,