Layout Host¶
Source: ui/layout_host.py
Body-wrapper builders and width synchronization helpers for shell and deep-route layouts. Wrapper choices are explained in Chrome and wrappers.
Build route body hosts and synchronize their responsive widths.
control_is_on_page ¶
Return whether a control is currently attached to a page.
Accessing Control.page may raise while a control is detached; this
helper treats that state as not mounted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control
|
Control
|
Control whose attachment state should be checked. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/learning_app/ui/layout_host.py
wrap_safe_area ¶
wrap_safe_area(
content: Control,
*,
avoid_intrusions_top: bool = True,
avoid_intrusions_bottom: bool = True,
avoid_intrusions_left: bool = True,
avoid_intrusions_right: bool = True,
maintain_bottom_view_padding: bool = False,
) -> SafeArea
Wrap content in an expanding safe area.
Safe-area protection prevents route content from being obscured by device cutouts, system bars, rounded corners, and gesture regions. Callers may disable an edge when shared application chrome already owns that inset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
Control
|
Control to protect from system intrusions. |
required |
avoid_intrusions_top
|
bool
|
Whether to inset content from top intrusions. |
True
|
avoid_intrusions_bottom
|
bool
|
Whether to inset content from bottom intrusions. |
True
|
avoid_intrusions_left
|
bool
|
Whether to inset content from left intrusions. |
True
|
avoid_intrusions_right
|
bool
|
Whether to inset content from right intrusions. |
True
|
maintain_bottom_view_padding
|
bool
|
Whether to preserve bottom view padding when the on-screen keyboard is visible. |
False
|
Returns:
| Type | Description |
|---|---|
SafeArea
|
An expanding safe-area control containing |
Source code in src/learning_app/ui/layout_host.py
build_shell_body ¶
Build a centered, responsive column for shell-route content.
Shell chrome owns its own insets, so this function only establishes body width and alignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page used to refresh responsive layout metrics. |
required |
*controls
|
Control
|
Controls to place in the shell body. |
()
|
Returns:
| Type | Description |
|---|---|
Column
|
An expanding shell body column. |
Source code in src/learning_app/ui/layout_host.py
build_bottom_inset_shell_body ¶
Build shell content protected below its app bar.
Settings and information routes retain the shared app bar but have no bottom app bar. The app bar owns the top inset, while the safe area keeps content clear of side and bottom system intrusions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page used to calculate responsive body width. |
required |
*controls
|
Control
|
Controls to place in the shell body. |
()
|
Returns:
| Type | Description |
|---|---|
SafeArea
|
A safe-area wrapper with top-intrusion avoidance disabled. |
Source code in src/learning_app/ui/layout_host.py
build_deep_body ¶
build_deep_body(
page: Page,
*controls: Control,
content_alignment: MainAxisAlignment = START,
) -> Container
Build a centered, width-constrained body for a deep form route.
Deep routes do not use shared shell chrome. This host supplies consistent vertical form spacing; route-specific wrappers decide whether additional safe-area handling is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page used to refresh responsive layout metrics. |
required |
*controls
|
Control
|
Controls to place in the form column. |
()
|
content_alignment
|
MainAxisAlignment
|
Main-axis alignment for controls in the form. |
START
|
Returns:
| Type | Description |
|---|---|
Container
|
An expanding themed container holding the form column. |
Source code in src/learning_app/ui/layout_host.py
sync_body_column_width ¶
Update the active route body's column width when it is mounted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Page whose top view contains the route body. |
required |
width
|
float
|
New logical-pixel width for the body column. |
required |