Router¶
Source: ui/router.py
Route-change and resize handlers that build views, synchronize shell chrome,
and apply route-specific layouts. Screen authors normally use
Navigation API instead; see the
Routing concept for the end-to-end flow and
Startup and lifecycle for when handlers are
attached in app.py.
Coordinate route views, shared chrome, and responsive layout state.
is_current_route ¶
Return whether the page's current route path matches a path.
Query parameters on page.route are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose current route should be inspected. |
required |
route
|
str
|
Canonical route path to compare. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/learning_app/ui/router.py
reset_to_route
async
¶
Replace the view stack with one normalized route.
Unknown paths resolve to the home route. The operation rebuilds the target view, updates the browser/page route, reapplies the theme, and refreshes the page. When a deep-route factory falls back (for example a missing set file or a stale create-set edit URL whose CSV already exists), the fallback view route is pushed so the URL stays consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose view stack should be replaced. |
required |
full_route
|
str
|
Route path with optional encoded query parameters. |
required |
Source code in src/learning_app/ui/router.py
reanchor_active_deep_view_on_home
async
¶
Replace the stack with a rebuilt Home and a rebuilt edit view.
Used after the first save of a newly created set so UI Back and system back reveal a fresh home catalog instead of the create-set form and a stale tile list. Both views are new objects assigned in one update so Flutter's navigator is not left with the previous create-set stack under a mutated live edit view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose view stack should be rewritten. |
required |
edit_route
|
str
|
Canonical edit route URL (typically |
required |
Source code in src/learning_app/ui/router.py
push_route_view
async
¶
Push a normalized deep route or reset to a shell route.
An already-active complete route is not duplicated. Unknown routes and
registered shell routes are handled as stack replacements. When the deep
factory falls back (missing file, deleted set CSV, or stale create-set
edit URL), the stack is reset to the fallback route instead of pushing a
mismatched URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose view stack should be updated. |
required |
full_route
|
str
|
Route path with optional encoded query parameters. |
required |
Source code in src/learning_app/ui/router.py
remove_views_for_set_file ¶
Drop stacked views that reference a deleted set and resync the top route.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose view stack may contain learn/edit/session views. |
required |
file_name
|
str
|
Set basename or path that was removed. |
required |
Source code in src/learning_app/ui/router.py
pop_route_view
async
¶
Remove the active view and restore state for the revealed route.
When no previous view exists, the page is reset to the home route.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose active route view should be removed. |
required |
Source code in src/learning_app/ui/router.py
initialize_routes
async
¶
Initialize a page with the home route.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose route stack should be initialized. |
required |
handle_route_change ¶
Synchronize or schedule navigation after a Flet route change.
Active routes are refreshed in place. Routes already present below the top of the view stack (typical browser back/forward) pop down to that view instead of pushing a duplicate. Drawer routes replace the stack, and new deep routes are pushed above the active shell view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
RouteChangeEvent
|
Route-change event containing the affected page. |
required |
Source code in src/learning_app/ui/router.py
handle_view_pop
async
¶
Remove the popped view and restore the route exposed underneath.
When in-place search is open, close it instead of popping the shell view (search is not a route).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
ViewPopEvent
|
View-pop event containing the affected page. |
required |
Source code in src/learning_app/ui/router.py
handle_page_resize ¶
Reapply route layout and theme after a page resize.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
ControlEvent
|
Resize event containing the affected page. |
required |