Checkpoint
This commit is contained in:
parent
2044ccdc0b
commit
ce8533f83b
11 changed files with 161 additions and 181 deletions
|
@ -33,59 +33,50 @@ impl<S: 'static + Send + Sync + Clone> AssistantPanel<S> {
|
|||
pub scroll_state: ScrollState,
|
||||
}
|
||||
|
||||
Panel::new(
|
||||
self.scroll_state.clone(),
|
||||
|_, payload| {
|
||||
let payload = payload.downcast_ref::<PanelPayload>().unwrap();
|
||||
|
||||
vec![div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.h_full()
|
||||
.px_2()
|
||||
.gap_2()
|
||||
// Header
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.justify_between()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.child(IconButton::new(Icon::Menu))
|
||||
.child(Label::new("New Conversation")),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_px()
|
||||
.child(IconButton::new(Icon::SplitMessage))
|
||||
.child(IconButton::new(Icon::Quote))
|
||||
.child(IconButton::new(Icon::MagicWand))
|
||||
.child(IconButton::new(Icon::Plus))
|
||||
.child(IconButton::new(Icon::Maximize)),
|
||||
),
|
||||
)
|
||||
// Chat Body
|
||||
.child(
|
||||
div()
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_3()
|
||||
.overflow_y_scroll(payload.scroll_state.clone())
|
||||
.child(Label::new("Is this thing on?")),
|
||||
)
|
||||
.into_any()]
|
||||
},
|
||||
Box::new(PanelPayload {
|
||||
scroll_state: self.scroll_state.clone(),
|
||||
}),
|
||||
)
|
||||
.side(self.current_side)
|
||||
.width(AbsoluteLength::Rems(rems(32.)))
|
||||
Panel::new(self.scroll_state.clone())
|
||||
.children(vec![div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.h_full()
|
||||
.px_2()
|
||||
.gap_2()
|
||||
// Header
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.justify_between()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.child(IconButton::new(Icon::Menu))
|
||||
.child(Label::new("New Conversation")),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap_px()
|
||||
.child(IconButton::new(Icon::SplitMessage))
|
||||
.child(IconButton::new(Icon::Quote))
|
||||
.child(IconButton::new(Icon::MagicWand))
|
||||
.child(IconButton::new(Icon::Plus))
|
||||
.child(IconButton::new(Icon::Maximize)),
|
||||
),
|
||||
)
|
||||
// Chat Body
|
||||
.child(
|
||||
div()
|
||||
.w_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap_3()
|
||||
.overflow_y_scroll(self.scroll_state.clone())
|
||||
.child(Label::new("Is this thing on?")),
|
||||
)
|
||||
.into_any()])
|
||||
.side(self.current_side)
|
||||
.width(AbsoluteLength::Rems(rems(32.)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +101,11 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
fn render(
|
||||
&mut self,
|
||||
_view: &mut S,
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl Element<ViewState = S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, AssistantPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
|
|
|
@ -20,7 +20,7 @@ impl<S: 'static + Send + Sync + Clone> ChatPanel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn with_messages(mut self, messages: Vec<ChatMessage<S>>) -> Self {
|
||||
pub fn messages(mut self, messages: Vec<ChatMessage<S>>) -> Self {
|
||||
self.messages = messages;
|
||||
self
|
||||
}
|
||||
|
@ -130,39 +130,36 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
fn render(
|
||||
&mut self,
|
||||
_view: &mut S,
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl Element<ViewState = S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ChatPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(Panel::new(
|
||||
ScrollState::default(),
|
||||
|_, _| vec![ChatPanel::new(ScrollState::default()).into_any()],
|
||||
Box::new(()),
|
||||
))
|
||||
.child(
|
||||
Panel::new(ScrollState::default())
|
||||
.child(ChatPanel::new(ScrollState::default())),
|
||||
)
|
||||
.child(Story::label(cx, "With Mesages"))
|
||||
.child(Panel::new(
|
||||
ScrollState::default(),
|
||||
|_, _| {
|
||||
vec![ChatPanel::new(ScrollState::default())
|
||||
.with_messages(vec![
|
||||
ChatMessage::new(
|
||||
"osiewicz".to_string(),
|
||||
"is this thing on?".to_string(),
|
||||
DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z")
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
ChatMessage::new(
|
||||
"maxdeviant".to_string(),
|
||||
"Reading you loud and clear!".to_string(),
|
||||
DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z")
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
])
|
||||
.into_any()]
|
||||
},
|
||||
Box::new(()),
|
||||
.child(Panel::new(ScrollState::default()).child(
|
||||
ChatPanel::new(ScrollState::default()).messages(vec![
|
||||
ChatMessage::new(
|
||||
"osiewicz".to_string(),
|
||||
"is this thing on?".to_string(),
|
||||
DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z")
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
ChatMessage::new(
|
||||
"maxdeviant".to_string(),
|
||||
"Reading you loud and clear!".to_string(),
|
||||
DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z")
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
]),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,11 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
fn render(
|
||||
&mut self,
|
||||
_view: &mut S,
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl Element<ViewState = S> {
|
||||
let theme = theme(cx);
|
||||
|
||||
Story::container(cx)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use gpui3::AbsoluteLength;
|
||||
use gpui3::{AbsoluteLength, AnyElement};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{prelude::*, theme};
|
||||
use crate::{token, v_stack};
|
||||
|
@ -47,16 +48,11 @@ pub struct Panel<S: 'static + Send + Sync> {
|
|||
allowed_sides: PanelAllowedSides,
|
||||
initial_width: AbsoluteLength,
|
||||
width: Option<AbsoluteLength>,
|
||||
children: HackyChildren<S>,
|
||||
payload: HackyChildrenPayload,
|
||||
children: SmallVec<[AnyElement<S>; 2]>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Panel<S> {
|
||||
pub fn new(
|
||||
scroll_state: ScrollState,
|
||||
children: HackyChildren<S>,
|
||||
payload: HackyChildrenPayload,
|
||||
) -> Self {
|
||||
pub fn new(scroll_state: ScrollState) -> Self {
|
||||
let token = token();
|
||||
|
||||
Self {
|
||||
|
@ -66,8 +62,7 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
|||
allowed_sides: PanelAllowedSides::default(),
|
||||
initial_width: token.default_panel_size,
|
||||
width: None,
|
||||
children,
|
||||
payload,
|
||||
children: SmallVec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +135,15 @@ impl<S: 'static + Send + Sync> Panel<S> {
|
|||
}
|
||||
}
|
||||
|
||||
panel_base.children_any((self.children)(cx, self.payload.as_ref()))
|
||||
panel_base.children(self.children.drain(..))
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> ParentElement for Panel<S> {
|
||||
type State = S;
|
||||
|
||||
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement<Self::State>; 2]> {
|
||||
&mut self.children
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,20 +168,21 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
fn render(
|
||||
&mut self,
|
||||
_view: &mut S,
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl Element<ViewState = S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, Panel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(Panel::new(
|
||||
ScrollState::default(),
|
||||
|_, _| {
|
||||
vec![div()
|
||||
.child(
|
||||
Panel::new(ScrollState::default()).child(
|
||||
div()
|
||||
.overflow_y_scroll(ScrollState::default())
|
||||
.children((0..100).map(|ix| Label::new(format!("Item {}", ix + 1))))
|
||||
.into_any()]
|
||||
},
|
||||
Box::new(()),
|
||||
))
|
||||
.children((0..100).map(|ix| Label::new(format!("Item {}", ix + 1)))),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,15 +78,18 @@ mod stories {
|
|||
}
|
||||
}
|
||||
|
||||
fn render(&mut self, _view: &mut S, cx: &mut ViewContext<S>) -> impl Element<ViewState = S> {
|
||||
fn render(
|
||||
&mut self,
|
||||
_view: &mut S,
|
||||
cx: &mut ViewContext<S>,
|
||||
) -> impl Element<ViewState = S> {
|
||||
Story::container(cx)
|
||||
.child(Story::title_for::<_, ProjectPanel<S>>(cx))
|
||||
.child(Story::label(cx, "Default"))
|
||||
.child(Panel::new(
|
||||
ScrollState::default(),
|
||||
|_, _| vec![ProjectPanel::new(ScrollState::default()).into_any()],
|
||||
Box::new(()),
|
||||
))
|
||||
.child(
|
||||
Panel::new(ScrollState::default())
|
||||
.child(ProjectPanel::new(ScrollState::default())),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -244,27 +244,17 @@ impl Workspace {
|
|||
.border_color(theme.lowest.base.default.border)
|
||||
.children(
|
||||
Some(
|
||||
Panel::new(
|
||||
self.left_panel_scroll_state.clone(),
|
||||
|_, payload| {
|
||||
vec![ProjectPanel::new(ScrollState::default()).into_any()]
|
||||
},
|
||||
Box::new(()),
|
||||
)
|
||||
.side(PanelSide::Left),
|
||||
Panel::new(self.left_panel_scroll_state.clone())
|
||||
.side(PanelSide::Left)
|
||||
.child(ProjectPanel::new(ScrollState::default())),
|
||||
)
|
||||
.filter(|_| workspace_state.is_project_panel_open()),
|
||||
)
|
||||
.children(
|
||||
Some(
|
||||
Panel::new(
|
||||
self.left_panel_scroll_state.clone(),
|
||||
|_, payload| {
|
||||
vec![CollabPanel::new(ScrollState::default()).into_any()]
|
||||
},
|
||||
Box::new(()),
|
||||
)
|
||||
.side(PanelSide::Left),
|
||||
Panel::new(self.left_panel_scroll_state.clone())
|
||||
.child(CollabPanel::new(ScrollState::default()))
|
||||
.side(PanelSide::Left),
|
||||
)
|
||||
.filter(|_| workspace_state.is_collab_panel_open()),
|
||||
)
|
||||
|
@ -285,57 +275,42 @@ impl Workspace {
|
|||
)
|
||||
.children(
|
||||
Some(
|
||||
Panel::new(
|
||||
self.bottom_panel_scroll_state.clone(),
|
||||
|_, _| vec![Terminal::new().into_any()],
|
||||
Box::new(()),
|
||||
)
|
||||
.allowed_sides(PanelAllowedSides::BottomOnly)
|
||||
.side(PanelSide::Bottom),
|
||||
Panel::new(self.bottom_panel_scroll_state.clone())
|
||||
.child(Terminal::new())
|
||||
.allowed_sides(PanelAllowedSides::BottomOnly)
|
||||
.side(PanelSide::Bottom),
|
||||
)
|
||||
.filter(|_| workspace_state.show_terminal.load(Ordering::SeqCst)),
|
||||
),
|
||||
)
|
||||
.children(
|
||||
Some(
|
||||
Panel::new(
|
||||
self.right_panel_scroll_state.clone(),
|
||||
|_, payload| {
|
||||
vec![ChatPanel::new(ScrollState::default())
|
||||
.with_messages(vec![
|
||||
ChatMessage::new(
|
||||
"osiewicz".to_string(),
|
||||
"is this thing on?".to_string(),
|
||||
DateTime::parse_from_rfc3339(
|
||||
"2023-09-27T15:40:52.707Z",
|
||||
)
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
ChatMessage::new(
|
||||
"maxdeviant".to_string(),
|
||||
"Reading you loud and clear!".to_string(),
|
||||
DateTime::parse_from_rfc3339(
|
||||
"2023-09-28T15:40:52.707Z",
|
||||
)
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
])
|
||||
.into_any()]
|
||||
},
|
||||
Box::new(()),
|
||||
)
|
||||
.side(PanelSide::Right),
|
||||
Panel::new(self.right_panel_scroll_state.clone())
|
||||
.side(PanelSide::Right)
|
||||
.child(ChatPanel::new(ScrollState::default()).messages(vec![
|
||||
ChatMessage::new(
|
||||
"osiewicz".to_string(),
|
||||
"is this thing on?".to_string(),
|
||||
DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z")
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
ChatMessage::new(
|
||||
"maxdeviant".to_string(),
|
||||
"Reading you loud and clear!".to_string(),
|
||||
DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z")
|
||||
.unwrap()
|
||||
.naive_local(),
|
||||
),
|
||||
])),
|
||||
)
|
||||
.filter(|_| workspace_state.is_chat_panel_open()),
|
||||
)
|
||||
.children(
|
||||
Some(Panel::new(
|
||||
self.right_panel_scroll_state.clone(),
|
||||
|_, _| vec![AssistantPanel::new().into_any()],
|
||||
Box::new(()),
|
||||
))
|
||||
Some(
|
||||
Panel::new(self.right_panel_scroll_state.clone())
|
||||
.child(AssistantPanel::new()),
|
||||
)
|
||||
.filter(|_| workspace_state.is_assistant_panel_open()),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue