diff --git a/crates/gpui/examples/views_post.rs b/crates/gpui/examples/views_post.rs new file mode 100644 index 0000000000..b0820a14bf --- /dev/null +++ b/crates/gpui/examples/views_post.rs @@ -0,0 +1,32 @@ +use gpui::*; + +struct Counter { + count: usize, +} + +impl Counter { + fn new(cx: &mut WindowContext) -> View { + cx.new_view(|_cx| Self { count: 0 }) + } +} + +impl Render for Counter { + fn render(&mut self, _cx: &mut gpui::ViewContext) -> impl IntoElement { + div() + .size_full() + .flex() + .justify_center() + .items_center() + .text_xl() + .bg(rgb(0x2d004b)) + .text_color(rgb(0xffffff)) + .child(self.count.to_string()) + } +} + +fn main() { + App::new().run(|cx: &mut AppContext| { + cx.open_window(WindowOptions::default(), Counter::new); + cx.activate(true); + }); +}