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 gpui3::{px, relative, view, Context, Size, View};
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::settings::Settings;
|
||||
use crate::{h_stack, prelude::*, Button};
|
||||
use crate::{
|
||||
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 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)]
|
||||
pub struct Workspace {
|
||||
title_bar: View<TitleBar>,
|
||||
|
@ -18,11 +36,14 @@ pub struct Workspace {
|
|||
show_assistant_panel: bool,
|
||||
show_notifications_panel: bool,
|
||||
show_terminal: bool,
|
||||
show_debug: bool,
|
||||
show_language_selector: bool,
|
||||
left_panel_scroll_state: ScrollState,
|
||||
right_panel_scroll_state: ScrollState,
|
||||
tab_bar_scroll_state: ScrollState,
|
||||
bottom_panel_scroll_state: ScrollState,
|
||||
debug: GPUI2UIDebug,
|
||||
settings: Settings,
|
||||
}
|
||||
|
||||
impl Workspace {
|
||||
|
@ -36,11 +57,14 @@ impl Workspace {
|
|||
show_assistant_panel: false,
|
||||
show_terminal: true,
|
||||
show_language_selector: false,
|
||||
show_debug: false,
|
||||
show_notifications_panel: true,
|
||||
left_panel_scroll_state: ScrollState::default(),
|
||||
right_panel_scroll_state: ScrollState::default(),
|
||||
tab_bar_scroll_state: ScrollState::default(),
|
||||
bottom_panel_scroll_state: ScrollState::default(),
|
||||
debug: GPUI2UIDebug::default(),
|
||||
settings: Settings::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,6 +146,21 @@ impl Workspace {
|
|||
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> {
|
||||
view(cx.entity(|cx| Self::new(cx)), Self::render)
|
||||
}
|
||||
|
@ -141,6 +180,8 @@ impl Workspace {
|
|||
SplitDirection::Horizontal,
|
||||
);
|
||||
|
||||
v_stack()
|
||||
.child(
|
||||
div()
|
||||
.relative()
|
||||
.size_full()
|
||||
|
@ -208,7 +249,8 @@ impl Workspace {
|
|||
Some(
|
||||
Panel::new(self.right_panel_scroll_state.clone())
|
||||
.side(PanelSide::Right)
|
||||
.child(ChatPanel::new(ScrollState::default()).messages(vec![
|
||||
.child(ChatPanel::new(ScrollState::default()).messages(
|
||||
vec![
|
||||
ChatMessage::new(
|
||||
"osiewicz".to_string(),
|
||||
"is this thing on?".to_string(),
|
||||
|
@ -223,7 +265,8 @@ impl Workspace {
|
|||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
])),
|
||||
],
|
||||
)),
|
||||
)
|
||||
.filter(|_| self.is_chat_panel_open()),
|
||||
)
|
||||
|
@ -255,13 +298,14 @@ 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::Bottom).child(Label::new("A toast"))),
|
||||
)
|
||||
.child(
|
||||
h_stack().gap_2().child(
|
||||
Button::<Workspace>::new("Toggle Debug")
|
||||
.on_click(|workspace, cx| workspace.toggle_debug(cx)),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue