Files
novem/src/screen/dashboard/screen.rs

102 lines
2.9 KiB
Rust
Raw Normal View History

2026-05-11 00:32:12 +08:00
use gpui::{AppContext, ParentElement, Styled, div};
2026-04-26 16:06:49 +01:00
2026-05-06 01:42:38 +08:00
use crate::{
2026-05-11 00:32:12 +08:00
api, app,
2026-05-06 01:42:38 +08:00
screen::dashboard::{
issue_list::{self, IssueList},
2026-05-11 00:32:12 +08:00
pull_request_view::{self, PullRequestView},
2026-05-06 01:42:38 +08:00
titlebar::{self, TitleBar},
},
};
2026-04-26 16:06:49 +01:00
pub(crate) struct Screen {
2026-05-06 01:42:38 +08:00
titlebar: gpui::Entity<TitleBar>,
issue_list: gpui::Entity<IssueList>,
2026-05-11 00:32:12 +08:00
pull_request_view: gpui::Entity<PullRequestView>,
2026-05-06 01:42:38 +08:00
issue_filter: Option<&'static str>,
}
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),
2026-05-11 00:32:12 +08:00
pull_request_view: cx.new(pull_request_view::new),
2026-05-06 01:42:38 +08:00
issue_filter: None,
};
screen.on_create(cx);
screen
2026-04-26 16:06:49 +01:00
}
2026-05-06 01:42:38 +08:00
impl Screen {
fn on_create(&mut self, cx: &mut gpui::Context<Self>) {
2026-05-11 00:32:12 +08:00
_ = cx
.subscribe(&self.issue_list, |this, _, event, cx| match event {
2026-05-14 00:05:31 +08:00
| issue_list::Event::ItemSelected(pr_id) => {
this.handle_issue_list_item_selected(pr_id, cx);
}
2026-05-11 00:32:12 +08:00
})
.detach();
2026-05-06 01:42:38 +08:00
}
2026-05-11 00:32:12 +08:00
fn handle_issue_list_item_selected(
&mut self,
id: &api::issues::Id,
2026-05-12 01:34:33 +08:00
cx: &mut gpui::Context<Self>,
) {
2026-05-11 00:32:12 +08:00
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();
})
}
2026-04-26 16:06:49 +01:00
}
impl gpui::Render for Screen {
fn render(
&mut self,
_window: &mut gpui::Window,
cx: &mut gpui::Context<Self>,
) -> impl gpui::IntoElement {
let theme = app::current_theme(cx);
div()
.flex()
.flex_col()
.size_full()
2026-05-14 00:05:31 +08:00
.bg(theme.colors.surface_chrome)
2026-04-26 16:06:49 +01:00
.child(self.titlebar.clone())
.child(
div()
.flex()
.flex_row()
.flex_1()
2026-05-11 02:14:05 +08:00
.min_h_0()
2026-04-26 16:06:49 +01:00
.w_full()
2026-05-11 00:32:12 +08:00
.child(
div()
.w_64()
.flex_shrink_0()
2026-05-06 01:42:38 +08:00
.h_full()
2026-05-14 00:05:31 +08:00
.ml_2()
2026-05-06 01:42:38 +08:00
.overflow_hidden()
.child(self.issue_list.clone()),
)
.child(
div()
.flex_1()
2026-05-11 00:32:12 +08:00
.min_w_0()
2026-05-11 02:14:05 +08:00
.min_h_0()
2026-05-14 00:05:31 +08:00
.m_2()
.mt_0()
.rounded_lg()
2026-05-11 02:14:05 +08:00
.overflow_hidden()
2026-05-14 00:05:31 +08:00
.border_1()
.border_color(theme.colors.border_muted)
2026-05-11 00:32:12 +08:00
.child(self.pull_request_view.clone()),
2026-05-06 01:42:38 +08:00
),
2026-04-26 16:06:49 +01:00
)
}
}