Checkpoint
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{get_workspace_state, Button, Icon, IconButton, IconColor, ToolDivider};
|
||||
use crate::{prelude::*, Workspace};
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
pub enum Tool {
|
||||
@@ -30,17 +29,17 @@ impl Default for ToolGroup {
|
||||
}
|
||||
|
||||
#[derive(Element)]
|
||||
pub struct StatusBar<S: 'static + Send + Sync + Clone> {
|
||||
state_type: PhantomData<S>,
|
||||
#[element(view_state = "Workspace")]
|
||||
pub struct StatusBar {
|
||||
left_tools: Option<ToolGroup>,
|
||||
right_tools: Option<ToolGroup>,
|
||||
bottom_tools: Option<ToolGroup>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync + Clone> StatusBar<S> {
|
||||
impl StatusBar {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
state_type: PhantomData,
|
||||
// state_type: PhantomData,
|
||||
left_tools: None,
|
||||
right_tools: None,
|
||||
bottom_tools: None,
|
||||
@@ -83,7 +82,11 @@ impl<S: 'static + Send + Sync + Clone> StatusBar<S> {
|
||||
self
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
fn render(
|
||||
&mut self,
|
||||
view: &mut Workspace,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) -> impl Element<ViewState = Workspace> {
|
||||
let theme = theme(cx);
|
||||
|
||||
div()
|
||||
@@ -94,34 +97,35 @@ impl<S: 'static + Send + Sync + Clone> StatusBar<S> {
|
||||
.justify_between()
|
||||
.w_full()
|
||||
.fill(theme.lowest.base.default.background)
|
||||
.child(self.left_tools(&theme))
|
||||
.child(self.left_tools(view, &theme))
|
||||
.child(self.right_tools(&theme))
|
||||
}
|
||||
|
||||
fn left_tools(&self, theme: &Theme) -> impl Element<ViewState = S> {
|
||||
let workspace_state = get_workspace_state();
|
||||
|
||||
div()
|
||||
fn left_tools(
|
||||
&self,
|
||||
workspace: &mut Workspace,
|
||||
theme: &Theme,
|
||||
) -> impl Element<ViewState = Workspace> {
|
||||
div::<Workspace>()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_1()
|
||||
.child(
|
||||
IconButton::new(Icon::FileTree)
|
||||
.when(workspace_state.is_project_panel_open(), |this| {
|
||||
IconButton::<Workspace>::new(Icon::FileTree)
|
||||
.when(workspace.is_project_panel_open(), |this| {
|
||||
this.color(IconColor::Accent)
|
||||
})
|
||||
.on_click(|_, cx| {
|
||||
workspace_state.toggle_project_panel();
|
||||
cx.notify();
|
||||
.on_click(|workspace, cx| {
|
||||
workspace.toggle_project_panel(cx);
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
IconButton::new(Icon::Hash)
|
||||
.when(workspace_state.is_collab_panel_open(), |this| {
|
||||
IconButton::<Workspace>::new(Icon::Hash)
|
||||
.when(workspace.is_collab_panel_open(), |this| {
|
||||
this.color(IconColor::Accent)
|
||||
})
|
||||
.on_click(|_, cx| {
|
||||
workspace_state.toggle_collab_panel();
|
||||
.on_click(|workspace, cx| {
|
||||
workspace.toggle_collab_panel();
|
||||
cx.notify();
|
||||
}),
|
||||
)
|
||||
@@ -129,7 +133,7 @@ impl<S: 'static + Send + Sync + Clone> StatusBar<S> {
|
||||
.child(IconButton::new(Icon::XCircle))
|
||||
}
|
||||
|
||||
fn right_tools(&self, theme: &Theme) -> impl Element<ViewState = S> {
|
||||
fn right_tools(&self, theme: &Theme) -> impl Element<ViewState = Workspace> {
|
||||
let workspace_state = get_workspace_state();
|
||||
|
||||
div()
|
||||
|
||||
Reference in New Issue
Block a user