-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathcounter.rs
47 lines (43 loc) · 1.1 KB
/
counter.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use freya::prelude::*;
fn main() {
launch_with_props(app, "Counter", (400.0, 350.0));
}
fn app() -> Element {
let mut count = use_signal(|| 0);
rsx!(
rect {
height: "50%",
width: "100%",
main_align: "center",
cross_align: "center",
background: "rgb(0, 119, 182)",
color: "white",
shadow: "0 4 20 5 rgb(0, 0, 0, 80)",
label {
font_size: "75",
font_weight: "bold",
"{count}"
}
}
rect {
height: "50%",
width: "100%",
main_align: "center",
cross_align: "center",
direction: "horizontal",
spacing: "8",
Button {
onpress: move |_| count += 1,
label { "Increase" }
}
Button {
onpress: move |_| count -= 1,
label { "Decrease" }
}
}
)
}