Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add empty browse context bar to home page
Erik Kundt committed 2 years ago
commit 2bf3e69d77a605eb9443c8aa51d6d9c332624cdd
parent 5e9b0699606a3a20279a29cd6d56b0182ee51ac1
5 files changed +46 -33
modified src/app.rs
@@ -28,6 +28,7 @@ pub enum HomeCid {
    Dashboard,
    IssueBrowser,
    PatchBrowser,
+
    Context,
    Shortcuts,
}

modified src/app/page.rs
@@ -116,6 +116,31 @@ impl HomeView {
        .collect()
    }

+
    fn update_context(
+
        &self,
+
        app: &mut Application<Cid, Message, NoUserEvent>,
+
        theme: &Theme,
+
        cid: HomeCid,
+
    ) -> Result<()> {
+
        let context = match cid {
+
            HomeCid::IssueBrowser => {
+
                let context = widget::issue::browse_context(theme);
+
                Some(context)
+
            }
+
            HomeCid::PatchBrowser => {
+
                let context = widget::patch::browse_context(theme);
+
                Some(context)
+
            }
+
            _ => None,
+
        };
+

+
        if let Some(context) = context {
+
            app.remount(Cid::Home(HomeCid::Context), context.to_boxed(), vec![])?;
+
        }
+

+
        Ok(())
+
    }
+

    fn update_shortcuts(
        &self,
        app: &mut Application<Cid, Message, NoUserEvent>,
@@ -155,6 +180,7 @@ impl ViewPage for HomeView {
        let active_component = Cid::Home(self.active_component.clone());
        app.active(&active_component)?;
        self.update_shortcuts(app, self.active_component.clone())?;
+
        self.update_context(app, theme, self.active_component.clone())?;

        Ok(())
    }
@@ -164,6 +190,8 @@ impl ViewPage for HomeView {
        app.umount(&Cid::Home(HomeCid::Dashboard))?;
        app.umount(&Cid::Home(HomeCid::IssueBrowser))?;
        app.umount(&Cid::Home(HomeCid::PatchBrowser))?;
+
        app.umount(&Cid::Home(HomeCid::Context))?;
+
        app.umount(&Cid::Home(HomeCid::Shortcuts))?;
        Ok(())
    }

@@ -171,7 +199,7 @@ impl ViewPage for HomeView {
        &mut self,
        app: &mut Application<Cid, Message, NoUserEvent>,
        _context: &Context,
-
        _theme: &Theme,
+
        theme: &Theme,
        message: Message,
    ) -> Result<Option<Message>> {
        if let Message::NavigationChanged(index) = message {
@@ -179,7 +207,9 @@ impl ViewPage for HomeView {

            let active_component = Cid::Home(self.active_component.clone());
            app.active(&active_component)?;
+

            self.update_shortcuts(app, self.active_component.clone())?;
+
            self.update_context(app, theme, self.active_component.clone())?;
        }

        Ok(None)
@@ -196,6 +226,11 @@ impl ViewPage for HomeView {
            frame,
            layout.component,
        );
+

+
        if self.active_component != HomeCid::Dashboard {
+
            app.view(&Cid::Home(HomeCid::Context), frame, layout.context);
+
        }
+

        app.view(&Cid::Home(HomeCid::Shortcuts), frame, layout.shortcuts);
    }

modified src/ui/widget/common/context.rs
@@ -195,8 +195,8 @@ pub fn bar(
        .foreground(theme.colors.context_light)
        .background(theme.colors.context_bg);
    let comments = super::label(&format!(" {label_4} "))
-
        .foreground(theme.colors.context_dark)
-
        .background(theme.colors.context_light);
+
        .foreground(theme.colors.context_light)
+
        .background(theme.colors.context_bg);

    let context_bar = ContextBar::new(context, id, author, title, comments);

modified src/ui/widget/issue.rs
@@ -1,17 +1,15 @@
use radicle::cob::thread::Comment;
use radicle::cob::thread::CommentId;
-
use radicle_cli::terminal::format;

use radicle::cob::issue::Issue;
use radicle::cob::issue::IssueId;
-
use radicle::Profile;
-
use tuirealm::props::Color;
use tuirealm::tui::layout::Constraint;
use tuirealm::tui::layout::Direction;
use tuirealm::tui::layout::Layout;

use super::common::container::Container;
use super::common::container::LabeledContainer;
+
use super::common::context::ContextBar;
use super::common::label::Textarea;
use super::common::list::List;
use super::common::list::Property;
@@ -21,7 +19,6 @@ use crate::ui::cob;
use crate::ui::cob::IssueItem;
use crate::ui::context::Context;
use crate::ui::theme::Theme;
-
use crate::ui::widget::common::context::ContextBar;

use super::*;

@@ -276,30 +273,6 @@ pub fn details(
    Widget::new(discussion)
}

-
pub fn context(theme: &Theme, issue: (IssueId, &Issue), profile: &Profile) -> Widget<ContextBar> {
-
    let (id, issue) = issue;
-
    let is_you = *issue.author().id() == profile.did();
-

-
    let id = format::cob(&id);
-
    let title = issue.title();
-
    let author = cob::format_author(issue.author().id(), is_you);
-
    let comments = issue.comments().count();
-

-
    let context = common::label(" issue ").background(theme.colors.context_badge_bg);
-
    let id = common::label(&format!(" {id} "))
-
        .foreground(theme.colors.context_id_fg)
-
        .background(theme.colors.context_id_bg);
-
    let title = common::label(&format!(" {title} "))
-
        .foreground(theme.colors.default_fg)
-
        .background(theme.colors.context_bg);
-
    let author = common::label(&format!(" {author} "))
-
        .foreground(theme.colors.context_id_author_fg)
-
        .background(theme.colors.context_bg);
-
    let comments = common::label(&format!(" {comments} "))
-
        .foreground(Color::Rgb(70, 70, 70))
-
        .background(theme.colors.context_light_bg);
-

-
    let context_bar = ContextBar::new(context, id, author, title, comments);
-

-
    Widget::new(context_bar).height(1)
+
pub fn browse_context(theme: &Theme) -> Widget<ContextBar> {
+
    common::context::bar(theme, "Browse", "", "", "", "")
}
modified src/ui/widget/patch.rs
@@ -115,3 +115,7 @@ pub fn context(context: &Context, theme: &Theme, patch: (PatchId, Patch)) -> Wid

    common::context::bar(theme, "Patch", &id, title, &author, &comments.to_string())
}
+

+
pub fn browse_context(theme: &Theme) -> Widget<ContextBar> {
+
    common::context::bar(theme, "Browse", "", "", "", "")
+
}