Hold the story view in the StoryWrapper
This commit is contained in:
parent
fc94c4ea40
commit
8496d02fe1
1 changed files with 7 additions and 6 deletions
|
@ -12,7 +12,8 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use gpui3::{
|
use gpui3::{
|
||||||
div, px, size, view, Bounds, Context, Element, ViewContext, WindowBounds, WindowOptions,
|
div, px, size, view, AnyView, Bounds, Context, Element, ViewContext, WindowBounds,
|
||||||
|
WindowOptions,
|
||||||
};
|
};
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use simplelog::SimpleLogger;
|
use simplelog::SimpleLogger;
|
||||||
|
@ -67,7 +68,7 @@ fn main() {
|
||||||
},
|
},
|
||||||
move |cx| {
|
move |cx| {
|
||||||
view(
|
view(
|
||||||
cx.entity(|cx| StoryWrapper::new(selector, theme)),
|
cx.entity(|cx| StoryWrapper::new(selector.story(cx), theme)),
|
||||||
StoryWrapper::render,
|
StoryWrapper::render,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -93,13 +94,13 @@ fn main() {
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct StoryWrapper {
|
pub struct StoryWrapper {
|
||||||
selector: StorySelector,
|
story: AnyView,
|
||||||
theme: Theme,
|
theme: Theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StoryWrapper {
|
impl StoryWrapper {
|
||||||
pub(crate) fn new(selector: StorySelector, theme: Theme) -> Self {
|
pub(crate) fn new(story: AnyView, theme: Theme) -> Self {
|
||||||
Self { selector, theme }
|
Self { story, theme }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
|
||||||
|
@ -108,7 +109,7 @@ impl StoryWrapper {
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.size_full()
|
.size_full()
|
||||||
.child(self.selector.story(cx))
|
.child(self.story.clone())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue