Skip to content

Commit b427374

Browse files
authored
Merge pull request #239 from tuttle-dev/streamline
Streamline UI/UX for version 2.1
2 parents f4adfb2 + 086401b commit b427374

15 files changed

Lines changed: 3136 additions & 1187 deletions

File tree

app.py

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818

1919
from tuttle.app.auth.view import ProfileScreen, SplashScreen
20-
from tuttle.app.contracts.view import ContractEditorScreen, ViewContractScreen
2120
from tuttle.app.core.abstractions import TView, TViewParams
2221
from tuttle.app.core.client_storage_impl import ClientStorageImpl
2322
from tuttle.app.core.database_storage_impl import DatabaseStorageImpl
@@ -29,7 +28,6 @@
2928
from tuttle.app.preferences.intent import PreferencesIntent
3029
from tuttle.app.preferences.model import PreferencesStorageKeys
3130
from tuttle.app.preferences.view import PreferencesScreen
32-
from tuttle.app.projects.view import ProjectEditorScreen, ViewProjectScreen
3331
from tuttle.app.res.colors import (
3432
accent,
3533
bg,
@@ -46,13 +44,9 @@
4644
from tuttle.app.res.dimens import MIN_WINDOW_HEIGHT, MIN_WINDOW_WIDTH
4745
from tuttle.app.res.fonts import APP_FONTS, HEADLINE_4_SIZE, HEADLINE_FONT
4846
from tuttle.app.res.res_utils import (
49-
CONTRACT_DETAILS_SCREEN_ROUTE,
50-
CONTRACT_EDITOR_SCREEN_ROUTE,
5147
HOME_SCREEN_ROUTE,
5248
PREFERENCES_SCREEN_ROUTE,
5349
PROFILE_SCREEN_ROUTE,
54-
PROJECT_DETAILS_SCREEN_ROUTE,
55-
PROJECT_EDITOR_SCREEN_ROUTE,
5650
SPLASH_SCREEN_ROUTE,
5751
)
5852
from tuttle.app.res.theme import APP_THEME, THEME_MODES, get_theme_mode_from_value
@@ -184,6 +178,12 @@ def show_snack(
184178
action=action,
185179
open=True,
186180
)
181+
182+
def on_snack_dismiss(e):
183+
if snack in self.page.overlay:
184+
self.page.overlay.remove(snack)
185+
186+
snack.on_dismiss = on_snack_dismiss
187187
self.page.show_dialog(snack)
188188

189189
def control_alert_dialog(
@@ -238,6 +238,12 @@ def on_route_change(self, e=None):
238238
if current_route in self.route_to_route_view_cache:
239239
# route already visited: reuse cached view
240240
self.current_route_view = self.route_to_route_view_cache[current_route]
241+
if not self.current_route_view.keep_back_stack:
242+
self.route_to_route_view_cache.clear()
243+
self.route_to_route_view_cache[current_route] = self.current_route_view
244+
self.page.views.clear()
245+
if self.current_route_view.view not in self.page.views:
246+
self.page.views.append(self.current_route_view.view)
241247
self.page.update()
242248
self.current_route_view.on_window_resized(
243249
self.page.window.width, self.page.window.height
@@ -338,40 +344,12 @@ def parse_route(self, pageRoute: str):
338344
screen = ProfileScreen(
339345
params=self.tuttle_view_params,
340346
)
341-
elif routePath.match(CONTRACT_EDITOR_SCREEN_ROUTE):
342-
screen = ContractEditorScreen(params=self.tuttle_view_params)
343-
elif routePath.match(f"{CONTRACT_DETAILS_SCREEN_ROUTE}/:contractId"):
344-
screen = ViewContractScreen(
345-
params=self.tuttle_view_params, contract_id=routePath.contractId
346-
)
347-
elif routePath.match(f"{CONTRACT_EDITOR_SCREEN_ROUTE}/:contractId"):
348-
contractId = None
349-
if hasattr(routePath, "contractId"):
350-
contractId = routePath.contractId
351-
screen = ContractEditorScreen(
352-
params=self.tuttle_view_params, contract_id_if_editing=contractId
353-
)
354347
elif routePath.match(PREFERENCES_SCREEN_ROUTE):
355348
screen = PreferencesScreen(
356349
params=self.tuttle_view_params,
357350
on_theme_changed_callback=self.on_theme_changed,
358351
on_reset_app_callback=self.on_reset_and_quit,
359352
)
360-
elif routePath.match(PROJECT_EDITOR_SCREEN_ROUTE):
361-
screen = ProjectEditorScreen(params=self.tuttle_view_params)
362-
elif routePath.match(f"{PROJECT_DETAILS_SCREEN_ROUTE}/:projectId"):
363-
screen = ViewProjectScreen(
364-
params=self.tuttle_view_params, project_id=routePath.projectId
365-
)
366-
elif routePath.match(PROJECT_EDITOR_SCREEN_ROUTE) or routePath.match(
367-
f"{PROJECT_EDITOR_SCREEN_ROUTE}/:projectId"
368-
):
369-
projectId = None
370-
if hasattr(routePath, "projectId"):
371-
projectId = routePath.projectId
372-
screen = ProjectEditorScreen(
373-
params=self.tuttle_view_params, project_id_if_editing=projectId
374-
)
375353
else:
376354
screen = Error404Screen(params=self.tuttle_view_params)
377355

0 commit comments

Comments
 (0)