wip: pull request view & md rendering
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use gpui::{AppContext, BorrowAppContext, ParentElement, Styled, div};
|
||||
use gpui::{AppContext, ParentElement, Styled, div};
|
||||
|
||||
use crate::{
|
||||
app,
|
||||
api, app,
|
||||
screen::dashboard::{
|
||||
issue_list::{self, IssueList},
|
||||
pull_request_view::{self, PullRequestView},
|
||||
sidebar::{self, Sidebar, SidebarItemValue},
|
||||
titlebar::{self, TitleBar},
|
||||
},
|
||||
@@ -13,6 +14,7 @@ pub(crate) struct Screen {
|
||||
titlebar: gpui::Entity<TitleBar>,
|
||||
issue_list: gpui::Entity<IssueList>,
|
||||
sidebar: gpui::Entity<Sidebar>,
|
||||
pull_request_view: gpui::Entity<PullRequestView>,
|
||||
|
||||
issue_filter: Option<&'static str>,
|
||||
}
|
||||
@@ -22,6 +24,8 @@ pub(crate) fn new(cx: &mut gpui::Context<Screen>) -> Screen {
|
||||
titlebar: cx.new(titlebar::new),
|
||||
issue_list: cx.new(issue_list::new),
|
||||
sidebar: cx.new(|_| sidebar::new()),
|
||||
pull_request_view: cx.new(pull_request_view::new),
|
||||
|
||||
issue_filter: None,
|
||||
};
|
||||
screen.on_create(cx);
|
||||
@@ -36,6 +40,14 @@ impl Screen {
|
||||
self.sidebar.update(cx, |sidebar, _| {
|
||||
sidebar.on_item_change(on_item_change);
|
||||
});
|
||||
|
||||
_ = cx
|
||||
.subscribe(&self.issue_list, |this, _, event, cx| match event {
|
||||
issue_list::Event::ItemSelected(pr_id) => {
|
||||
this.handle_issue_list_item_selected(pr_id, cx);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
fn handle_sidebar_item_change(
|
||||
@@ -50,6 +62,19 @@ impl Screen {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_issue_list_item_selected(
|
||||
&mut self,
|
||||
id: &api::issues::Id,
|
||||
cx: &mut gpui::Context<Self>,
|
||||
) {
|
||||
println!("handle issue list item selected: {:?}", id);
|
||||
self.pull_request_view.update(cx, |view, cx| {
|
||||
view.change_displayed_pull_request(id.clone(), cx);
|
||||
println!("change displayed pull request: {:?}", id);
|
||||
cx.notify();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl gpui::Render for Screen {
|
||||
@@ -71,10 +96,17 @@ impl gpui::Render for Screen {
|
||||
.flex_row()
|
||||
.flex_1()
|
||||
.w_full()
|
||||
.child(div().w_40().h_full().child(self.sidebar.clone()))
|
||||
.child(
|
||||
div()
|
||||
.w_80()
|
||||
.w_40()
|
||||
.flex_shrink_0()
|
||||
.h_full()
|
||||
.child(self.sidebar.clone()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.w_64()
|
||||
.flex_shrink_0()
|
||||
.h_full()
|
||||
.bg(theme.colors.surface)
|
||||
.border_x_1()
|
||||
@@ -86,10 +118,12 @@ impl gpui::Render for Screen {
|
||||
.child(
|
||||
div()
|
||||
.flex_1()
|
||||
.min_w_0()
|
||||
.h_full()
|
||||
.bg(theme.colors.surface)
|
||||
.border_l_1()
|
||||
.border_color(theme.colors.border),
|
||||
.border_color(theme.colors.border)
|
||||
.child(self.pull_request_view.clone()),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user