-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
81 lines (67 loc) · 2.67 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#sudo ln -s /usr/lib64/libmpv.so /usr/lib64/libmpv.so.1
import flet as ft
from urllib.parse import urlencode
import os
from ui.login_ui import login_page
from ui.bills_ui import bills_page
from ui.home_ui import home_page
from ui.settings_ui import settings_page
from ui.earnings_ui import pay_page
from ui.edit_bills_ui import edit_bills_page
from ui.theme import light_theme, dark_theme, green_theme
from ui.charts_ui import charts_page
from ui.alert import create_loader, show_loader, hide_loader
BASE_URL = "https://checkbookwizard.com/"
#BASE_URL = 'http://localhost:1338/' # For development
def main(page: ft.Page):
page.title = "Checkbook Wizard"
if page.platform is page.platform.WINDOWS or page.platform is page.platform.LINUX or page.platform is page.platform.MACOS:
page.window.width = 400
page.window.height = 675
# page.platform = ft.PagePlatform.ANDROID
user_info = {}
#page.client_storage.clear()
user_id = page.client_storage.get("burnison.me.user.id")
print(user_id)
loader = create_loader(page)
#show_loader(page, loader)
# page.close(loader)
def route_change(route):
saved_theme = page.client_storage.get("burnison.me.current.theme")
current_theme = None
if saved_theme == "light" or saved_theme is None:
current_theme = light_theme()
elif saved_theme == "dark":
current_theme = dark_theme()
elif saved_theme == "green":
current_theme = green_theme()
page.views.clear()
# page.views.append(home_page(page, BASE_URL))
# bills_page(current_theme,page, BASE_URL, user_id)
if page.route == "/login":
page.views.clear()
page.views.append(login_page(current_theme, page, BASE_URL))
elif page.route == "/bills":
bills_page(current_theme, page, BASE_URL, user_id)
elif page.route == "/edit_bills":
edit_bills_page(current_theme, page, BASE_URL, user_id)
elif page.route == "/charts":
charts_page(current_theme, page, BASE_URL, user_id)
elif page.route == "/pay":
pay_page(current_theme, page, BASE_URL, user_id)
elif page.route == "/settings":
page.views.append(settings_page(current_theme, page, BASE_URL))
page.update()
def view_pop(view):
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
if user_id is None:
hide_loader(page, loader)
page.go("/login")
else:
print(f"Welcome, user {user_id}")
page.go("/bills")
ft.app(target=main, assets_dir="assets")