hello_world.rs

 1use gpui::*;
 2
 3struct HelloWorld {
 4    text: SharedString,
 5}
 6
 7impl Render for HelloWorld {
 8    fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
 9        div()
10            .flex()
11            .bg(rgb(0x2e7d32))
12            .size_full()
13            .justify_center()
14            .items_center()
15            .text_xl()
16            .text_color(rgb(0xffffff))
17            .child(format!("Hello, {}!", &self.text))
18    }
19}
20
21fn main() {
22    App::new().run(|cx: &mut AppContext| {
23        cx.open_window(WindowOptions::default(), |cx| {
24            cx.new_view(|_cx| HelloWorld {
25                text: "World".into(),
26            })
27        });
28    });
29}