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(Length::Definite(Pixels(300.0).into()))
13            .justify_center()
14            .items_center()
15            .shadow_lg()
16            .border()
17            .border_color(rgb(0x0000ff))
18            .text_xl()
19            .text_color(rgb(0xffffff))
20            .child(format!("Hello, {}!", &self.text))
21    }
22}
23
24fn main() {
25    App::new().run(|cx: &mut AppContext| {
26        cx.open_window(WindowOptions::default(), |cx| {
27            cx.new_view(|_cx| HelloWorld {
28                text: "World".into(),
29            })
30        });
31    });
32}