feat: impl dashboard & issue list
This commit is contained in:
@@ -1,14 +1,54 @@
|
||||
use gpui::{AppContext, ParentElement, Styled, div};
|
||||
use gpui::{AppContext, BorrowAppContext, ParentElement, Styled, div};
|
||||
|
||||
use crate::{app, screen::dashboard::titlebar};
|
||||
use crate::{
|
||||
app,
|
||||
screen::dashboard::{
|
||||
issue_list::{self, IssueList},
|
||||
sidebar::{self, Sidebar, SidebarItemValue},
|
||||
titlebar::{self, TitleBar},
|
||||
},
|
||||
};
|
||||
|
||||
pub(crate) struct Screen {
|
||||
titlebar: gpui::Entity<titlebar::TitleBar>,
|
||||
titlebar: gpui::Entity<TitleBar>,
|
||||
issue_list: gpui::Entity<IssueList>,
|
||||
sidebar: gpui::Entity<Sidebar>,
|
||||
|
||||
issue_filter: Option<&'static str>,
|
||||
}
|
||||
|
||||
pub(crate) fn new(cx: &mut gpui::App) -> Screen {
|
||||
Screen {
|
||||
titlebar: cx.new(|cx| titlebar::new(cx)),
|
||||
pub(crate) fn new(cx: &mut gpui::Context<Screen>) -> Screen {
|
||||
let mut screen = Screen {
|
||||
titlebar: cx.new(titlebar::new),
|
||||
issue_list: cx.new(issue_list::new),
|
||||
sidebar: cx.new(|_| sidebar::new()),
|
||||
issue_filter: None,
|
||||
};
|
||||
screen.on_create(cx);
|
||||
screen
|
||||
}
|
||||
|
||||
impl Screen {
|
||||
fn on_create(&mut self, cx: &mut gpui::Context<Self>) {
|
||||
let on_item_change = cx.listener(|this, value, _, cx| {
|
||||
this.handle_sidebar_item_change(value, cx);
|
||||
});
|
||||
self.sidebar.update(cx, |sidebar, _| {
|
||||
sidebar.on_item_change(on_item_change);
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_sidebar_item_change(
|
||||
&mut self,
|
||||
value: &SidebarItemValue,
|
||||
cx: &mut gpui::Context<Self>,
|
||||
) {
|
||||
match value {
|
||||
SidebarItemValue::PullRequest { filter } => {
|
||||
self.issue_filter = Some(*filter);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +71,26 @@ impl gpui::Render for Screen {
|
||||
.flex_row()
|
||||
.flex_1()
|
||||
.w_full()
|
||||
.gap_2()
|
||||
.px_3()
|
||||
.pb_3()
|
||||
.child(div().w_1_4().h_full().rounded_lg().bg(theme.colors.surface))
|
||||
.child(div().w_3_4().h_full().rounded_lg().bg(theme.colors.surface)),
|
||||
.child(div().w_40().h_full().child(self.sidebar.clone()))
|
||||
.child(
|
||||
div()
|
||||
.w_80()
|
||||
.h_full()
|
||||
.bg(theme.colors.surface)
|
||||
.border_x_1()
|
||||
.border_color(theme.colors.border)
|
||||
.mr_2()
|
||||
.overflow_hidden()
|
||||
.child(self.issue_list.clone()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.h_full()
|
||||
.bg(theme.colors.surface)
|
||||
.border_l_1()
|
||||
.border_color(theme.colors.border),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user