project_panel.rs

 1use crate::{
 2    input, list, list_section_header, prelude::*, static_project_panel_project_items,
 3    static_project_panel_single_items, theme,
 4};
 5
 6use gpui2::{
 7    elements::{div, div::ScrollState},
 8    style::StyleHelpers,
 9    ParentElement, ViewContext,
10};
11use gpui2::{Element, IntoElement};
12use std::marker::PhantomData;
13
14#[derive(Element)]
15pub struct ProjectPanel<V: 'static> {
16    view_type: PhantomData<V>,
17    scroll_state: ScrollState,
18}
19
20pub fn project_panel<V: 'static>(scroll_state: ScrollState) -> ProjectPanel<V> {
21    ProjectPanel {
22        view_type: PhantomData,
23        scroll_state,
24    }
25}
26
27impl<V: 'static> ProjectPanel<V> {
28    fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
29        let theme = theme(cx);
30
31        div()
32            .w_56()
33            .h_full()
34            .flex()
35            .flex_col()
36            .fill(theme.middle.base.default.background)
37            .child(
38                div()
39                    .w_56()
40                    .flex()
41                    .flex_col()
42                    .overflow_y_scroll(self.scroll_state.clone())
43                    .child(
44                        list(static_project_panel_single_items())
45                            .header(list_section_header("FILES").set_toggle(ToggleState::Toggled))
46                            .empty_message("No files in directory")
47                            .set_toggle(ToggleState::Toggled),
48                    )
49                    .child(
50                        list(static_project_panel_project_items())
51                            .header(list_section_header("PROJECT").set_toggle(ToggleState::Toggled))
52                            .empty_message("No folders in directory")
53                            .set_toggle(ToggleState::Toggled),
54                    ),
55            )
56            .child(
57                input("Find something...")
58                    .value("buffe".to_string())
59                    .state(InteractionState::Focused),
60            )
61    }
62}