From 791c378d4e6d0e3f878e2f0569d627ebb313ca19 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Wed, 22 Feb 2023 12:35:56 +0100 Subject: [PATCH] tui: Show project payload Signed-off-by: Erik Kundt --- radicle-tui/src/app.rs | 35 +++++++++- radicle-tui/src/ui.rs | 20 +++++- radicle-tui/src/ui/components.rs | 108 ++++++++++++++++++++++++++++++- radicle-tui/src/ui/theme.rs | 2 + 4 files changed, 161 insertions(+), 4 deletions(-) diff --git a/radicle-tui/src/app.rs b/radicle-tui/src/app.rs index b2f4bc78..9835d452 100644 --- a/radicle-tui/src/app.rs +++ b/radicle-tui/src/app.rs @@ -9,7 +9,7 @@ use tuirealm::tui::layout::{Constraint, Direction, Layout}; use tuirealm::{Application, Component, Frame, NoUserEvent, Sub, SubClause, SubEventClause}; use radicle_tui::ui; -use radicle_tui::ui::components::{GlobalListener, ShortcutBar}; +use radicle_tui::ui::components::{GlobalListener, LabeledContainer, PropertyList, ShortcutBar}; use radicle_tui::ui::theme; use radicle_tui::ui::widget::Widget; @@ -33,6 +33,7 @@ pub enum Message { /// All components known to this application. #[derive(Debug, Eq, PartialEq, Clone, Hash)] pub enum ComponentId { + Workspaces, ShortcutBar, GlobalListener, } @@ -53,6 +54,25 @@ impl Tui for App { fn init(&mut self, app: &mut Application) -> Result<()> { let theme = theme::default_dark(); + app.mount( + ComponentId::Workspaces, + ui::labeled_container( + &theme, + "about", + ui::property_list( + &theme, + vec![ + ui::property(&theme, "id", &self.id.to_string()), + ui::property(&theme, "name", self.project.name()), + ui::property(&theme, "description", self.project.description()), + ], + ) + .to_boxed(), + ) + .to_boxed(), + vec![], + )?; + app.mount( ComponentId::ShortcutBar, ui::shortcut_bar( @@ -114,6 +134,7 @@ impl Tui for App { ) .split(area); + app.view(&ComponentId::Workspaces, frame, layout[0]); app.view(&ComponentId::ShortcutBar, frame, layout[1]); } @@ -147,6 +168,18 @@ impl Component for Widget { } } +impl Component for Widget { + fn on(&mut self, _event: Event) -> Option { + None + } +} + +impl Component for Widget { + fn on(&mut self, _event: Event) -> Option { + None + } +} + impl Component for Widget { fn on(&mut self, _event: Event) -> Option { None diff --git a/radicle-tui/src/ui.rs b/radicle-tui/src/ui.rs index d7a19d6d..757f43fb 100644 --- a/radicle-tui/src/ui.rs +++ b/radicle-tui/src/ui.rs @@ -6,7 +6,10 @@ pub mod widget; use tuirealm::props::Attribute; use tuirealm::{MockComponent, StateValue}; -use components::{GlobalListener, Label, Property, PropertyList, Shortcut, ShortcutBar}; +use components::{ + ContainerHeader, GlobalListener, Label, LabeledContainer, Property, PropertyList, Shortcut, + ShortcutBar, +}; use widget::Widget; pub fn global_listener() -> Widget { @@ -21,6 +24,21 @@ pub fn label(content: &str) -> Widget