diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index 922bbfc2ba6608ea2264b52af9f98d9be25d4568..5093097e6b7f799b9bb8c689f116ac92e206b0be 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -99,7 +99,7 @@ impl ListHeader { let color = ThemeColor::new(cx); let is_toggleable = self.toggleable != Toggleable::NotToggleable; - let is_toggled = Toggleable::is_toggled(&self.toggleable); + let is_toggled = self.toggleable.is_toggled(); let disclosure_control = self.disclosure_control(); diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs index 0df024d4538f63da65bd8d873abdf5d9f5299ea4..c58f83596c8b5fdc99fdb887a40c10b927d332b4 100644 --- a/crates/ui2/src/components/workspace.rs +++ b/crates/ui2/src/components/workspace.rs @@ -1,22 +1,22 @@ use chrono::DateTime; -use gpui3::{px, relative, rems, view, Context, Size, View}; +use gpui3::{px, relative, view, Context, Size, View}; use crate::prelude::*; use crate::{ - theme, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label, - LanguageSelector, NotificationToast, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, - ProjectPanel, SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin, + theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label, + LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel, + SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin, }; #[derive(Clone)] pub struct Workspace { title_bar: View, editor_1: View, - editor_2: View, show_project_panel: bool, show_collab_panel: bool, show_chat_panel: bool, show_assistant_panel: bool, + show_notifications_panel: bool, show_terminal: bool, show_language_selector: bool, left_panel_scroll_state: ScrollState, @@ -30,13 +30,13 @@ impl Workspace { Self { title_bar: TitleBar::view(cx), editor_1: EditorPane::view(cx), - editor_2: EditorPane::view(cx), show_project_panel: true, show_collab_panel: false, - show_chat_panel: true, + show_chat_panel: false, show_assistant_panel: false, show_terminal: true, show_language_selector: false, + show_notifications_panel: true, left_panel_scroll_state: ScrollState::default(), right_panel_scroll_state: ScrollState::default(), tab_bar_scroll_state: ScrollState::default(), @@ -88,6 +88,18 @@ impl Workspace { cx.notify(); } + pub fn is_notifications_panel_open(&self) -> bool { + self.show_notifications_panel + } + + pub fn toggle_notifications_panel(&mut self, cx: &mut ViewContext) { + self.show_notifications_panel = !self.show_notifications_panel; + + self.show_notifications_panel = false; + + cx.notify(); + } + pub fn is_assistant_panel_open(&self) -> bool { self.show_assistant_panel } @@ -117,43 +129,15 @@ impl Workspace { pub fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx).clone(); - let temp_size = rems(36.).into(); - - let root_group = PaneGroup::new_groups( - vec![ - PaneGroup::new_panes( - vec![ - Pane::new( - ScrollState::default(), - Size { - width: relative(1.).into(), - height: temp_size, - }, - ) - .child(self.editor_1.clone()), - Pane::new( - ScrollState::default(), - Size { - width: relative(1.).into(), - height: temp_size, - }, - ) - .child(Terminal::new()), - ], - SplitDirection::Vertical, - ), - PaneGroup::new_panes( - vec![Pane::new( - ScrollState::default(), - Size { - width: relative(1.).into(), - height: relative(1.).into(), - }, - ) - .child(self.editor_2.clone())], - SplitDirection::Vertical, - ), - ], + let root_group = PaneGroup::new_panes( + vec![Pane::new( + ScrollState::default(), + Size { + width: relative(1.).into(), + height: relative(1.).into(), + }, + ) + .child(self.editor_1.clone())], SplitDirection::Horizontal, ); @@ -243,6 +227,14 @@ impl Workspace { ) .filter(|_| self.is_chat_panel_open()), ) + .children( + Some( + Panel::new(self.right_panel_scroll_state.clone()) + .side(PanelSide::Right) + .child(div().w_96().h_full().child("Notifications")), + ) + .filter(|_| self.is_notifications_panel_open()), + ) .children( Some( Panel::new(self.right_panel_scroll_state.clone()) @@ -264,12 +256,12 @@ impl Workspace { .filter(|_| self.is_language_selector_open()), ) .child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast"))) - // .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast"))) - .child(NotificationToast::new( - "Can't pull changes from origin", - "Your local branch is behind the remote branch. Please pull the latest changes before pushing.", - Button::new("Stash & Switch").variant(ButtonVariant::Filled), - ).secondary_action(Button::new("Cancel"))) + // .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast"))) + // .child(NotificationToast::new( + // "Can't pull changes from origin", + // "Your local branch is behind the remote branch. Please pull the latest changes before pushing.", + // Button::new("Stash & Switch").variant(ButtonVariant::Filled), + // ).secondary_action(Button::new("Cancel"))) } }