tui: Add dashboard widget
This commit is contained in:
parent
38c9f0a1c0
commit
95b0029267
|
|
@ -14,7 +14,9 @@ use radicle_tui::ui;
|
||||||
use radicle_tui::ui::components::container::{GlobalListener, LabeledContainer, Tabs};
|
use radicle_tui::ui::components::container::{GlobalListener, LabeledContainer, Tabs};
|
||||||
use radicle_tui::ui::components::context::{ContextBar, Shortcuts};
|
use radicle_tui::ui::components::context::{ContextBar, Shortcuts};
|
||||||
use radicle_tui::ui::components::list::PropertyList;
|
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::layout;
|
||||||
use radicle_tui::ui::theme::{self, Theme};
|
use radicle_tui::ui::theme::{self, Theme};
|
||||||
use radicle_tui::ui::widget::Widget;
|
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> {
|
impl tuirealm::Component<Message, NoUserEvent> for Widget<IssueBrowser> {
|
||||||
fn on(&mut self, _event: Event<NoUserEvent>) -> Option<Message> {
|
fn on(&mut self, _event: Event<NoUserEvent>) -> Option<Message> {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ use widget::Widget;
|
||||||
use self::cob::patch;
|
use self::cob::patch;
|
||||||
use self::components::context::ContextBar;
|
use self::components::context::ContextBar;
|
||||||
use self::components::list::{List, Table};
|
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;
|
use self::theme::Theme;
|
||||||
|
|
||||||
pub fn global_listener() -> Widget<GlobalListener> {
|
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")])
|
tabs(theme, vec![label("activity"), label("files")])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dashboard(theme: &theme::Theme, id: &Id, project: &Project) -> Widget<LabeledContainer> {
|
pub fn dashboard(theme: &theme::Theme, id: &Id, project: &Project) -> Widget<Dashboard> {
|
||||||
labeled_container(
|
let about = labeled_container(
|
||||||
theme,
|
theme,
|
||||||
"about",
|
"about",
|
||||||
property_list(
|
property_list(
|
||||||
|
|
@ -225,5 +225,8 @@ pub fn dashboard(theme: &theme::Theme, id: &Id, project: &Project) -> Widget<Lab
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.to_boxed(),
|
.to_boxed(),
|
||||||
)
|
);
|
||||||
|
let dashboard = Dashboard::new(about);
|
||||||
|
|
||||||
|
Widget::new(dashboard)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use tuirealm::{AttrValue, Attribute, Frame, MockComponent, State};
|
||||||
use crate::ui::layout;
|
use crate::ui::layout;
|
||||||
use crate::ui::widget::{Widget, WidgetComponent};
|
use crate::ui::widget::{Widget, WidgetComponent};
|
||||||
|
|
||||||
|
use super::container::LabeledContainer;
|
||||||
use super::label::Label;
|
use super::label::Label;
|
||||||
use super::list::{List, Table};
|
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 {
|
pub struct IssueBrowser {
|
||||||
label: Widget<Label>,
|
label: Widget<Label>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IssueBrowser {
|
impl IssueBrowser {
|
||||||
pub fn new(label: Widget<Label>) -> Self {
|
pub fn new(label: Widget<Label>) -> Self {
|
||||||
Self { label }
|
Self { label }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue