Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 12 additions & 34 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


from tuttle.app.auth.view import ProfileScreen, SplashScreen
from tuttle.app.contracts.view import ContractEditorScreen, ViewContractScreen
from tuttle.app.core.abstractions import TView, TViewParams
from tuttle.app.core.client_storage_impl import ClientStorageImpl
from tuttle.app.core.database_storage_impl import DatabaseStorageImpl
Expand All @@ -29,7 +28,6 @@
from tuttle.app.preferences.intent import PreferencesIntent
from tuttle.app.preferences.model import PreferencesStorageKeys
from tuttle.app.preferences.view import PreferencesScreen
from tuttle.app.projects.view import ProjectEditorScreen, ViewProjectScreen
from tuttle.app.res.colors import (
accent,
bg,
Expand All @@ -46,13 +44,9 @@
from tuttle.app.res.dimens import MIN_WINDOW_HEIGHT, MIN_WINDOW_WIDTH
from tuttle.app.res.fonts import APP_FONTS, HEADLINE_4_SIZE, HEADLINE_FONT
from tuttle.app.res.res_utils import (
CONTRACT_DETAILS_SCREEN_ROUTE,
CONTRACT_EDITOR_SCREEN_ROUTE,
HOME_SCREEN_ROUTE,
PREFERENCES_SCREEN_ROUTE,
PROFILE_SCREEN_ROUTE,
PROJECT_DETAILS_SCREEN_ROUTE,
PROJECT_EDITOR_SCREEN_ROUTE,
SPLASH_SCREEN_ROUTE,
)
from tuttle.app.res.theme import APP_THEME, THEME_MODES, get_theme_mode_from_value
Expand Down Expand Up @@ -184,6 +178,12 @@ def show_snack(
action=action,
open=True,
)

def on_snack_dismiss(e):
if snack in self.page.overlay:
self.page.overlay.remove(snack)

snack.on_dismiss = on_snack_dismiss
self.page.show_dialog(snack)

def control_alert_dialog(
Expand Down Expand Up @@ -238,6 +238,12 @@ def on_route_change(self, e=None):
if current_route in self.route_to_route_view_cache:
# route already visited: reuse cached view
self.current_route_view = self.route_to_route_view_cache[current_route]
if not self.current_route_view.keep_back_stack:
self.route_to_route_view_cache.clear()
self.route_to_route_view_cache[current_route] = self.current_route_view
self.page.views.clear()
if self.current_route_view.view not in self.page.views:
self.page.views.append(self.current_route_view.view)
self.page.update()
self.current_route_view.on_window_resized(
self.page.window.width, self.page.window.height
Expand Down Expand Up @@ -338,40 +344,12 @@ def parse_route(self, pageRoute: str):
screen = ProfileScreen(
params=self.tuttle_view_params,
)
elif routePath.match(CONTRACT_EDITOR_SCREEN_ROUTE):
screen = ContractEditorScreen(params=self.tuttle_view_params)
elif routePath.match(f"{CONTRACT_DETAILS_SCREEN_ROUTE}/:contractId"):
screen = ViewContractScreen(
params=self.tuttle_view_params, contract_id=routePath.contractId
)
elif routePath.match(f"{CONTRACT_EDITOR_SCREEN_ROUTE}/:contractId"):
contractId = None
if hasattr(routePath, "contractId"):
contractId = routePath.contractId
screen = ContractEditorScreen(
params=self.tuttle_view_params, contract_id_if_editing=contractId
)
elif routePath.match(PREFERENCES_SCREEN_ROUTE):
screen = PreferencesScreen(
params=self.tuttle_view_params,
on_theme_changed_callback=self.on_theme_changed,
on_reset_app_callback=self.on_reset_and_quit,
)
elif routePath.match(PROJECT_EDITOR_SCREEN_ROUTE):
screen = ProjectEditorScreen(params=self.tuttle_view_params)
elif routePath.match(f"{PROJECT_DETAILS_SCREEN_ROUTE}/:projectId"):
screen = ViewProjectScreen(
params=self.tuttle_view_params, project_id=routePath.projectId
)
elif routePath.match(PROJECT_EDITOR_SCREEN_ROUTE) or routePath.match(
f"{PROJECT_EDITOR_SCREEN_ROUTE}/:projectId"
):
projectId = None
if hasattr(routePath, "projectId"):
projectId = routePath.projectId
screen = ProjectEditorScreen(
params=self.tuttle_view_params, project_id_if_editing=projectId
)
else:
screen = Error404Screen(params=self.tuttle_view_params)

Expand Down
Loading
Loading