Fix toggling of left panel
This commit is contained in:
parent
8496d02fe1
commit
e900ea20b7
1 changed files with 3 additions and 30 deletions
|
@ -13,8 +13,6 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct WorkspaceState {
|
pub struct WorkspaceState {
|
||||||
pub show_project_panel: Arc<AtomicBool>,
|
|
||||||
pub show_collab_panel: Arc<AtomicBool>,
|
|
||||||
pub show_chat_panel: Arc<AtomicBool>,
|
pub show_chat_panel: Arc<AtomicBool>,
|
||||||
pub show_assistant_panel: Arc<AtomicBool>,
|
pub show_assistant_panel: Arc<AtomicBool>,
|
||||||
pub show_terminal: Arc<AtomicBool>,
|
pub show_terminal: Arc<AtomicBool>,
|
||||||
|
@ -30,26 +28,6 @@ impl WorkspaceState {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_project_panel_open(&self) -> bool {
|
|
||||||
self.show_project_panel.load(Ordering::SeqCst)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toggle_project_panel(&self) {
|
|
||||||
Self::toggle_value(&self.show_project_panel);
|
|
||||||
|
|
||||||
self.show_collab_panel.store(false, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_collab_panel_open(&self) -> bool {
|
|
||||||
self.show_collab_panel.load(Ordering::SeqCst)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toggle_collab_panel(&self) {
|
|
||||||
Self::toggle_value(&self.show_collab_panel);
|
|
||||||
|
|
||||||
self.show_project_panel.store(false, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_terminal_open(&self) -> bool {
|
pub fn is_terminal_open(&self) -> bool {
|
||||||
self.show_terminal.load(Ordering::SeqCst)
|
self.show_terminal.load(Ordering::SeqCst)
|
||||||
}
|
}
|
||||||
|
@ -93,8 +71,6 @@ static WORKSPACE_STATE: OnceLock<WorkspaceState> = OnceLock::new();
|
||||||
|
|
||||||
pub fn get_workspace_state() -> &'static WorkspaceState {
|
pub fn get_workspace_state() -> &'static WorkspaceState {
|
||||||
let state = WORKSPACE_STATE.get_or_init(|| WorkspaceState {
|
let state = WORKSPACE_STATE.get_or_init(|| WorkspaceState {
|
||||||
show_project_panel: Arc::new(AtomicBool::new(true)),
|
|
||||||
show_collab_panel: Arc::new(AtomicBool::new(false)),
|
|
||||||
show_chat_panel: Arc::new(AtomicBool::new(true)),
|
show_chat_panel: Arc::new(AtomicBool::new(true)),
|
||||||
show_assistant_panel: Arc::new(AtomicBool::new(false)),
|
show_assistant_panel: Arc::new(AtomicBool::new(false)),
|
||||||
show_terminal: Arc::new(AtomicBool::new(true)),
|
show_terminal: Arc::new(AtomicBool::new(true)),
|
||||||
|
@ -104,7 +80,6 @@ pub fn get_workspace_state() -> &'static WorkspaceState {
|
||||||
state
|
state
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[derive(Element)]
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
show_project_panel: bool,
|
show_project_panel: bool,
|
||||||
|
@ -132,7 +107,7 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_project_panel_open(&self) -> bool {
|
pub fn is_project_panel_open(&self) -> bool {
|
||||||
dbg!(self.show_project_panel)
|
self.show_project_panel
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_project_panel(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn toggle_project_panel(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
@ -140,8 +115,6 @@ impl Workspace {
|
||||||
|
|
||||||
self.show_collab_panel = false;
|
self.show_collab_panel = false;
|
||||||
|
|
||||||
dbg!(self.show_project_panel);
|
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +208,7 @@ impl Workspace {
|
||||||
.side(PanelSide::Left)
|
.side(PanelSide::Left)
|
||||||
.child(ProjectPanel::new(ScrollState::default())),
|
.child(ProjectPanel::new(ScrollState::default())),
|
||||||
)
|
)
|
||||||
.filter(|_| workspace_state.is_project_panel_open()),
|
.filter(|_| self.is_project_panel_open()),
|
||||||
)
|
)
|
||||||
.children(
|
.children(
|
||||||
Some(
|
Some(
|
||||||
|
@ -243,7 +216,7 @@ impl Workspace {
|
||||||
.child(CollabPanel::new(ScrollState::default()))
|
.child(CollabPanel::new(ScrollState::default()))
|
||||||
.side(PanelSide::Left),
|
.side(PanelSide::Left),
|
||||||
)
|
)
|
||||||
.filter(|_| workspace_state.is_collab_panel_open()),
|
.filter(|_| self.is_collab_panel_open()),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
v_stack()
|
v_stack()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue