use gpui::{AppContext, ParentElement, Styled, div}; use crate::{ api, app, screen::dashboard::{ issue_list::{self, IssueList}, pull_request_view::{self, PullRequestView}, titlebar::{self, TitleBar}, }, }; pub(crate) struct Screen { titlebar: gpui::Entity, issue_list: gpui::Entity, pull_request_view: gpui::Entity, issue_filter: Option<&'static str>, } pub(crate) fn new(cx: &mut gpui::Context) -> Screen { let mut screen = Screen { titlebar: cx.new(titlebar::new), issue_list: cx.new(issue_list::new), pull_request_view: cx.new(pull_request_view::new), issue_filter: None, }; screen.on_create(cx); screen } impl Screen { fn on_create(&mut self, cx: &mut gpui::Context) { _ = 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_issue_list_item_selected( &mut self, id: &api::issues::Id, cx: &mut gpui::Context, ) { 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 { fn render( &mut self, _window: &mut gpui::Window, cx: &mut gpui::Context, ) -> impl gpui::IntoElement { let theme = app::current_theme(cx); div() .flex() .flex_col() .bg(theme.colors.background) .size_full() .child(self.titlebar.clone()) .child( div() .flex() .flex_row() .flex_1() .min_h_0() .w_full() .child( div() .w_64() .flex_shrink_0() .h_full() .bg(theme.colors.surface_chrome) .overflow_hidden() .child(self.issue_list.clone()), ) .child( div() .flex_1() .min_w_0() .min_h_0() .h_full() .overflow_hidden() .bg(theme.colors.surface) .child(self.pull_request_view.clone()), ), ) } }