-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_framework_listview.py
More file actions
executable file
·76 lines (67 loc) · 2.69 KB
/
example_framework_listview.py
File metadata and controls
executable file
·76 lines (67 loc) · 2.69 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
from boldui.app import App
from boldui.framework import Rectangle, SizedBox, Text, Stack, Widget, Flexible, Row, ListView, Padding, Column
from boldui.store import BaseModel
class Model(BaseModel):
list_state1: ListView.State
list_state2: ListView.State
class MainPage(Widget):
def __init__(self, model):
self.model = model
def build(self):
PADDING = 200
return Stack([
# Background
Rectangle(color=0xff222222),
# List
Row([
Stack([
Rectangle(color=0xff202090),
Padding(
ListView(
state=self.model.list_state1,
builder=lambda i: SizedBox(
Row([
Flexible(),
Stack([
Rectangle(color=0x80ff0000 if (i % 2 == 0) else 0x8000ff00),
Text(text=f"{i}", color=0xffffffff, font_size=24),
]),
Flexible(),
]),
height=48 + (80 if (i % 5 == 0) else 0),
),
clip=False,
),
vertical=PADDING,
),
# Highlight padding
Column([
SizedBox(Rectangle(color=0xaa202090), height=PADDING),
Rectangle(color=0x0),
SizedBox(Rectangle(color=0xaa202090), height=PADDING),
])
]),
Stack([
Rectangle(color=0xff202060),
ListView(
state=self.model.list_state2,
builder=lambda i: SizedBox(
Row([
Flexible(),
Stack([
Rectangle(color=0x80ff0000 if (i % 2 == 0) else 0x8000ff00),
Text(text=f"{i}", color=0xffffffff, font_size=24),
]),
Flexible(),
]),
height=48 + (80 if (i % 5 == 0) else 0),
)
),
]),
]),
])
if __name__ == '__main__':
app_model = Model.open_db('/run/user/1000/example_app.db')
app = App(lambda: MainPage(app_model), durable_model=app_model)
app.run()