-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
63 lines (55 loc) · 1.76 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import flet as ft
from Utility import *
from view import routes
# add last read
# reduce the image
def metadata(page: ft.Page):
page.title = "BookReader"
page.theme_mode = 'Light'
page.window.width = 320
# page.window_resizable = False
# def set_theme(page):
# save_colors = defualt_theme
# if not page.client_storage.get("theme_color"):
# page.client_storage.set('theme_color', save_colors)
# else:
# save_colors = page.client_storage.get("theme_color")
# page.theme = ft.Theme(
# color_scheme= ft.ColorScheme(
# primary= save_colors['accent'],
# primary_container= save_colors['container'],
# surface= save_colors['background'],
# on_surface= save_colors['text'],
# on_surface_variant= save_colors['text'],
# ),
# )
def add_overlays(page):
page.overlay.append(ft.SnackBar(ft.Text("love"), duration= 1000))
page.overlay.append(ft.FilePicker())
# add audio manager
# add download manager
# add popup
def main(page: ft.Page): # add security
metadata(page)
add_overlays(page)
# set_theme(page)
# overlays = overlay(page)
def route_change(e: ft.RouteChangeEvent) -> None:
page.views.clear()
page.views.append((
routes[
page.route
if page.route in list(routes.keys())
else "/"
]
)())
page.update()
def view_pop(e: ft.ViewPopEvent) -> None:
page.views.pop()
top_view: ft.View = page.views.pop()
page.go(top_view.route)
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)
if __name__ == "__main__":
ft.app(target=main, assets_dir="assets")