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_1()
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 let bounds = Bounds::centered(None, size(px(300.0), px(300.0)), cx);
27 cx.open_window(
28 WindowOptions {
29 window_bounds: Some(WindowBounds::Windowed(bounds)),
30 ..Default::default()
31 },
32 |cx| {
33 cx.new_view(|_cx| HelloWorld {
34 text: "World".into(),
35 })
36 },
37 )
38 .unwrap();
39 });
40}