-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
43 lines (35 loc) · 990 Bytes
/
app.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
import flet as ft
from flet_core.types import AppView
from settings.settings import APP_CONFIG
from stores.chat_store import ChatStore
from stores.user_store import UserStore
from stores.ai_store import AIStore
from views.chat import ChatView
def main(page: ft.Page):
# add storages
page.user_store = UserStore(page=page)
page.chat_store = ChatStore(page=page)
page.ai_store = AIStore(page=page)
page.title = APP_CONFIG["title"]
page.theme_mode = ft.ThemeMode.DARK
# FIRST APP LAUNCH
# 1. create new chat
first_chat = page.chat_store.new_chat()
# 2. start chatting
page.views.append(
ChatView(
page=page,
chat=first_chat,
user=page.user_store.user,
)
)
# first render
page.update()
ft.app(
name=APP_CONFIG["name"],
view=AppView.FLET_APP,
assets_dir=APP_CONFIG["assets_dir"],
upload_dir=APP_CONFIG["upload_dir"],
use_color_emoji=True,
target=main,
),