parent
6e2bb3fb58
commit
cca6277ea5
2 changed files with 43 additions and 1 deletions
35
crates/story/examples/modal.rs
Normal file
35
crates/story/examples/modal.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use gpui::*;
|
||||
use story::{Assets, ModalStory};
|
||||
|
||||
pub struct Example {
|
||||
root: Entity<ModalStory>,
|
||||
}
|
||||
|
||||
impl Example {
|
||||
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let root = ModalStory::view(window, cx);
|
||||
|
||||
Self { root }
|
||||
}
|
||||
|
||||
fn view(window: &mut Window, cx: &mut App) -> Entity<Self> {
|
||||
cx.new(|cx| Self::new(window, cx))
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for Example {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div().p_4().size_full().child(self.root.clone())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app = Application::new().with_assets(Assets);
|
||||
|
||||
app.run(move |cx| {
|
||||
story::init(cx);
|
||||
cx.activate(true);
|
||||
|
||||
story::create_new_window("Modal Example", Example::view, cx);
|
||||
});
|
||||
}
|
||||
|
|
@ -177,11 +177,18 @@ impl StoryRoot {
|
|||
}
|
||||
|
||||
impl Render for StoryRoot {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let drawer_layer = Root::render_drawer_layer(window, cx);
|
||||
let modal_layer = Root::render_modal_layer(window, cx);
|
||||
let notification_layer = Root::render_notification_layer(window, cx);
|
||||
|
||||
v_flex()
|
||||
.size_full()
|
||||
.child(self.title_bar.clone())
|
||||
.child(self.view.clone())
|
||||
.children(drawer_layer)
|
||||
.children(modal_layer)
|
||||
.child(div().absolute().top_8().children(notification_layer))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue