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
48
49
50
51
52
53
54
55
56
|
use extern "ui"
use ui::components::Button;
use ui::components::Label;
use ui::components::FlexView;
type Action =
| Increment
| Decrement
fn update(state, message) {
match message {
Action::Increment -> state + 1,
Action::Decrement -> state - 1,
}
}
fn render(state, dispatch) {
return FlexView([
Button("-", action: -> dispatch(Action::Decrement)),
Label(state),
Button("+", action: -> dispatch(Action::Increment)),
FlexView(
height: 500,
width: 220,
body: [
Label("List 1"),
Label("List 2"),
Label("List 3"),
],
)
Button(
width: 100,
height: 20,
action: -> (),
body: Label("Sign up"),
)
])
}
fn app() {
# Creating our state
val state = 0
# Creating our app
val app = ui::App(
state,
on_update: update,
on_render: render,
)
# Starting our app
app.start()
}
|