tui: Add placeholder for issue browser

Signed-off-by: Erik Kundt <erik@zirkular.io>
This commit is contained in:
Erik Kundt 2023-04-06 11:18:20 +02:00 committed by Alexis Sellier
parent f7799e1474
commit 1bde528a1b
No known key found for this signature in database
3 changed files with 46 additions and 3 deletions

View File

@ -16,7 +16,7 @@ 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, PatchActivity, PatchFiles};
use radicle_tui::ui::components::workspace::{Browser, IssueBrowser, PatchActivity, PatchFiles};
use radicle_tui::ui::layout;
use radicle_tui::ui::theme::{self, Theme};
use radicle_tui::ui::widget::Widget;
@ -230,7 +230,7 @@ impl ViewPage for Home {
let navigation = ui::home_navigation(theme).to_boxed();
let dashboard = ui::dashboard(theme, &context.id, &context.project).to_boxed();
let issue_browser = Box::<Phantom>::default();
let issue_browser = ui::issue_browser(&theme).to_boxed();
let patch_browser = ui::patch_browser(theme, &context.patches, &context.profile).to_boxed();
let shortcuts = ui::shortcuts(
@ -430,6 +430,12 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<Browser<(PatchId, Patc
}
}
impl tuirealm::Component<Message, NoUserEvent> for Widget<IssueBrowser> {
fn on(&mut self, _event: Event<NoUserEvent>) -> Option<Message> {
None
}
}
impl tuirealm::Component<Message, NoUserEvent> for Widget<PatchActivity> {
fn on(&mut self, event: Event<NoUserEvent>) -> Option<Message> {
match event {

View File

@ -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, PatchActivity, PatchFiles};
use self::components::workspace::{Browser, IssueBrowser, PatchActivity, PatchFiles};
use self::theme::Theme;
pub fn global_listener() -> Widget<GlobalListener> {
@ -121,6 +121,13 @@ pub fn table(theme: &theme::Theme, items: &[impl List], profile: &Profile) -> Wi
.highlight(theme.colors.item_list_highlighted_bg)
}
pub fn issue_browser(theme: &theme::Theme) -> Widget<IssueBrowser> {
let not_implemented = label("not implemented").foreground(theme.colors.default_fg);
let browser = IssueBrowser::new(not_implemented);
Widget::new(browser)
}
pub fn patch_browser(
theme: &theme::Theme,
items: &[(PatchId, Patch)],

View File

@ -44,6 +44,36 @@ impl<T: List> WidgetComponent for Browser<T> {
}
}
pub struct IssueBrowser {
label: Widget<Label>,
}
impl IssueBrowser {
pub fn new(label: Widget<Label>) -> Self {
Self { label }
}
}
impl WidgetComponent for IssueBrowser {
fn view(&mut self, _properties: &Props, frame: &mut Frame, area: Rect) {
let label_w = self
.label
.query(Attribute::Width)
.unwrap_or(AttrValue::Size(1))
.unwrap_size();
let rect = layout::centered_label(label_w, area);
self.label.view(frame, rect);
}
fn state(&self) -> State {
State::None
}
fn perform(&mut self, _properties: &Props, _cmd: Cmd) -> CmdResult {
CmdResult::None
}
}
pub struct PatchActivity {
label: Widget<Label>,
}