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 .flex_col()
12 .gap_3()
13 .bg(rgb(0x505050))
14 .size(Length::Definite(Pixels(500.0).into()))
15 .justify_center()
16 .items_center()
17 .shadow_lg()
18 .border_1()
19 .border_color(rgb(0x0000ff))
20 .text_xl()
21 .text_color(rgb(0xffffff))
22 .child(format!("Hello, {}!", &self.text))
23 .child(
24 div()
25 .flex()
26 .gap_2()
27 .child(div().size_8().bg(gpui::red()))
28 .child(div().size_8().bg(gpui::green()))
29 .child(div().size_8().bg(gpui::blue()))
30 .child(div().size_8().bg(gpui::yellow()))
31 .child(div().size_8().bg(gpui::black()))
32 .child(div().size_8().bg(gpui::white())),
33 )
34 }
35}
36
37fn main() {
38 App::new().run(|cx: &mut AppContext| {
39 let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);
40 cx.open_window(
41 WindowOptions {
42 window_bounds: Some(WindowBounds::Windowed(bounds)),
43 ..Default::default()
44 },
45 |cx| {
46 cx.new_view(|_cx| HelloWorld {
47 text: "World".into(),
48 })
49 },
50 )
51 .unwrap();
52 });
53}