WIP
This commit is contained in:
parent
c22778bd92
commit
e34a488b55
1 changed files with 136 additions and 92 deletions
|
@ -1,13 +1,31 @@
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use gpui3::{px, relative, view, Context, Size, View};
|
use gpui3::{px, relative, view, Context, Size, View};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::settings::Settings;
|
||||||
|
use crate::{h_stack, prelude::*, Button};
|
||||||
use crate::{
|
use crate::{
|
||||||
theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label,
|
theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label,
|
||||||
LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel,
|
LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel,
|
||||||
SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin,
|
SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct GPUI2UIDebug {
|
||||||
|
pub in_livestream: bool,
|
||||||
|
pub enable_user_settings: bool,
|
||||||
|
pub show_toast: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for GPUI2UIDebug {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
in_livestream: false,
|
||||||
|
enable_user_settings: false,
|
||||||
|
show_toast: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
title_bar: View<TitleBar>,
|
title_bar: View<TitleBar>,
|
||||||
|
@ -18,11 +36,14 @@ pub struct Workspace {
|
||||||
show_assistant_panel: bool,
|
show_assistant_panel: bool,
|
||||||
show_notifications_panel: bool,
|
show_notifications_panel: bool,
|
||||||
show_terminal: bool,
|
show_terminal: bool,
|
||||||
|
show_debug: bool,
|
||||||
show_language_selector: bool,
|
show_language_selector: bool,
|
||||||
left_panel_scroll_state: ScrollState,
|
left_panel_scroll_state: ScrollState,
|
||||||
right_panel_scroll_state: ScrollState,
|
right_panel_scroll_state: ScrollState,
|
||||||
tab_bar_scroll_state: ScrollState,
|
tab_bar_scroll_state: ScrollState,
|
||||||
bottom_panel_scroll_state: ScrollState,
|
bottom_panel_scroll_state: ScrollState,
|
||||||
|
debug: GPUI2UIDebug,
|
||||||
|
settings: Settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Workspace {
|
impl Workspace {
|
||||||
|
@ -36,11 +57,14 @@ impl Workspace {
|
||||||
show_assistant_panel: false,
|
show_assistant_panel: false,
|
||||||
show_terminal: true,
|
show_terminal: true,
|
||||||
show_language_selector: false,
|
show_language_selector: false,
|
||||||
|
show_debug: false,
|
||||||
show_notifications_panel: true,
|
show_notifications_panel: true,
|
||||||
left_panel_scroll_state: ScrollState::default(),
|
left_panel_scroll_state: ScrollState::default(),
|
||||||
right_panel_scroll_state: ScrollState::default(),
|
right_panel_scroll_state: ScrollState::default(),
|
||||||
tab_bar_scroll_state: ScrollState::default(),
|
tab_bar_scroll_state: ScrollState::default(),
|
||||||
bottom_panel_scroll_state: ScrollState::default(),
|
bottom_panel_scroll_state: ScrollState::default(),
|
||||||
|
debug: GPUI2UIDebug::default(),
|
||||||
|
settings: Settings::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +146,21 @@ impl Workspace {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggle_debug(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
self.show_debug = !self.show_debug;
|
||||||
|
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn debug_toggle_user_settings(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
if self.debug.enable_user_settings {
|
||||||
|
self.debug.enable_user_settings = false;
|
||||||
|
} else {
|
||||||
|
self.debug.enable_user_settings = true;
|
||||||
|
}
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn view(cx: &mut WindowContext) -> View<Self> {
|
pub fn view(cx: &mut WindowContext) -> View<Self> {
|
||||||
view(cx.entity(|cx| Self::new(cx)), Self::render)
|
view(cx.entity(|cx| Self::new(cx)), Self::render)
|
||||||
}
|
}
|
||||||
|
@ -141,6 +180,8 @@ impl Workspace {
|
||||||
SplitDirection::Horizontal,
|
SplitDirection::Horizontal,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
v_stack()
|
||||||
|
.child(
|
||||||
div()
|
div()
|
||||||
.relative()
|
.relative()
|
||||||
.size_full()
|
.size_full()
|
||||||
|
@ -208,7 +249,8 @@ impl Workspace {
|
||||||
Some(
|
Some(
|
||||||
Panel::new(self.right_panel_scroll_state.clone())
|
Panel::new(self.right_panel_scroll_state.clone())
|
||||||
.side(PanelSide::Right)
|
.side(PanelSide::Right)
|
||||||
.child(ChatPanel::new(ScrollState::default()).messages(vec![
|
.child(ChatPanel::new(ScrollState::default()).messages(
|
||||||
|
vec![
|
||||||
ChatMessage::new(
|
ChatMessage::new(
|
||||||
"osiewicz".to_string(),
|
"osiewicz".to_string(),
|
||||||
"is this thing on?".to_string(),
|
"is this thing on?".to_string(),
|
||||||
|
@ -223,7 +265,8 @@ impl Workspace {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.naive_local(),
|
.naive_local(),
|
||||||
),
|
),
|
||||||
])),
|
],
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
.filter(|_| self.is_chat_panel_open()),
|
.filter(|_| self.is_chat_panel_open()),
|
||||||
)
|
)
|
||||||
|
@ -255,13 +298,14 @@ impl Workspace {
|
||||||
)
|
)
|
||||||
.filter(|_| self.is_language_selector_open()),
|
.filter(|_| self.is_language_selector_open()),
|
||||||
)
|
)
|
||||||
.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
|
.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast"))),
|
||||||
// .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast")))
|
)
|
||||||
// .child(NotificationToast::new(
|
.child(
|
||||||
// "Can't pull changes from origin",
|
h_stack().gap_2().child(
|
||||||
// "Your local branch is behind the remote branch. Please pull the latest changes before pushing.",
|
Button::<Workspace>::new("Toggle Debug")
|
||||||
// Button::new("Stash & Switch").variant(ButtonVariant::Filled),
|
.on_click(|workspace, cx| workspace.toggle_debug(cx)),
|
||||||
// ).secondary_action(Button::new("Cancel")))
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue