Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
tui: Add dashboard widget
Erik Kundt committed 3 years ago
commit 95b002926748bf267a65af79fde8cd7b7b15983c
parent 38c9f0a1c0b335cb4b83126f767a926f11e06335
3 files changed +45 -5
modified radicle-tui/src/app.rs
@@ -14,7 +14,9 @@ use radicle_tui::ui;
use radicle_tui::ui::components::container::{GlobalListener, LabeledContainer, Tabs};
use radicle_tui::ui::components::context::{ContextBar, Shortcuts};
use radicle_tui::ui::components::list::PropertyList;
-
use radicle_tui::ui::components::workspace::{Browser, IssueBrowser, PatchActivity, PatchFiles};
+
use radicle_tui::ui::components::workspace::{
+
    Browser, Dashboard, IssueBrowser, PatchActivity, PatchFiles,
+
};
use radicle_tui::ui::layout;
use radicle_tui::ui::theme::{self, Theme};
use radicle_tui::ui::widget::Widget;
@@ -428,6 +430,12 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<Browser<(PatchId, Patc
    }
}

+
impl tuirealm::Component<Message, NoUserEvent> for Widget<Dashboard> {
+
    fn on(&mut self, _event: Event<NoUserEvent>) -> Option<Message> {
+
        None
+
    }
+
}
+

impl tuirealm::Component<Message, NoUserEvent> for Widget<IssueBrowser> {
    fn on(&mut self, _event: Event<NoUserEvent>) -> Option<Message> {
        None
modified radicle-tui/src/ui.rs
@@ -22,7 +22,7 @@ use widget::Widget;
use self::cob::patch;
use self::components::context::ContextBar;
use self::components::list::{List, Table};
-
use self::components::workspace::{Browser, IssueBrowser, PatchActivity, PatchFiles};
+
use self::components::workspace::{Browser, Dashboard, IssueBrowser, PatchActivity, PatchFiles};
use self::theme::Theme;

pub fn global_listener() -> Widget<GlobalListener> {
@@ -212,8 +212,8 @@ pub fn patch_navigation(theme: &theme::Theme) -> Widget<Tabs> {
    tabs(theme, vec![label("activity"), label("files")])
}

-
pub fn dashboard(theme: &theme::Theme, id: &Id, project: &Project) -> Widget<LabeledContainer> {
-
    labeled_container(
+
pub fn dashboard(theme: &theme::Theme, id: &Id, project: &Project) -> Widget<Dashboard> {
+
    let about = labeled_container(
        theme,
        "about",
        property_list(
@@ -225,5 +225,8 @@ pub fn dashboard(theme: &theme::Theme, id: &Id, project: &Project) -> Widget<Lab
            ],
        )
        .to_boxed(),
-
    )
+
    );
+
    let dashboard = Dashboard::new(about);
+

+
    Widget::new(dashboard)
}
modified radicle-tui/src/ui/components/workspace.rs
@@ -8,6 +8,7 @@ use tuirealm::{AttrValue, Attribute, Frame, MockComponent, State};
use crate::ui::layout;
use crate::ui::widget::{Widget, WidgetComponent};

+
use super::container::LabeledContainer;
use super::label::Label;
use super::list::{List, Table};

@@ -44,9 +45,37 @@ impl<T: List> WidgetComponent for Browser<T> {
    }
}

+
pub struct Dashboard {
+
    about: Widget<LabeledContainer>,
+
}
+
impl Dashboard {
+
    pub fn new(about: Widget<LabeledContainer>) -> Self {
+
        Self { about }
+
    }
+
}
+

+
impl WidgetComponent for Dashboard {
+
    fn view(&mut self, _properties: &Props, frame: &mut Frame, area: Rect) {
+
        let layout = Layout::default()
+
            .direction(Direction::Vertical)
+
            .constraints(vec![Constraint::Length(4)].as_ref())
+
            .split(area);
+
        self.about.view(frame, layout[0]);
+
    }
+

+
    fn state(&self) -> State {
+
        State::None
+
    }
+

+
    fn perform(&mut self, _properties: &Props, _cmd: Cmd) -> CmdResult {
+
        CmdResult::None
+
    }
+
}
+

pub struct IssueBrowser {
    label: Widget<Label>,
}
+

impl IssueBrowser {
    pub fn new(label: Widget<Label>) -> Self {
        Self { label }