-
Notifications
You must be signed in to change notification settings - Fork 193
/
home-store.py
42 lines (34 loc) · 1.08 KB
/
home-store.py
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
import flet
from flet import AppBar, ElevatedButton, Page, Text, View, colors
def main(page: Page):
page.title = "Routes Example"
def route_change(e):
page.views.clear()
page.views.append(
View(
"/",
[
AppBar(title=Text("Flet app"), bgcolor=colors.SURFACE_VARIANT),
ElevatedButton("Visit Store", on_click=lambda _: page.go("/store")),
],
)
)
if page.route == "/store":
page.views.append(
View(
"/store",
[
AppBar(title=Text("Store"), bgcolor=colors.SURFACE_VARIANT),
ElevatedButton("Go Home", on_click=lambda _: page.go("/")),
],
)
)
page.update()
def view_pop(e):
page.views.pop()
top_view = page.views[-1]
page.go(top_view.route)
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)
flet.app(main)