Use Workspace::view to construct the view

This commit is contained in:
Marshall Bowers 2023-10-12 16:52:32 -04:00
parent 79a61c28d7
commit 6e5ad75c5c

View file

@ -23,10 +23,6 @@ pub struct Workspace {
bottom_panel_scroll_state: ScrollState,
}
fn workspace(cx: &mut WindowContext) -> View<Workspace> {
view(cx.entity(|cx| Workspace::new()), Workspace::render)
}
impl Workspace {
pub fn new() -> Self {
Self {
@ -109,6 +105,10 @@ impl Workspace {
cx.notify();
}
pub fn view(cx: &mut WindowContext) -> View<Self> {
view(cx.entity(|cx| Self::new()), Self::render)
}
pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
let theme = theme(cx).clone();
@ -285,7 +285,7 @@ mod stories {
pub fn view(cx: &mut WindowContext) -> View<Self> {
view(
cx.entity(|cx| Self {
workspace: workspace(cx),
workspace: Workspace::view(cx),
}),
|view, cx| view.workspace.clone(),
)