App Theme¶
Source: ui/app_theme.py
Process-wide theme mode and content background colors, loaded from and saved to preferences. Ownership and preference keys are in State and persistence; startup restore order is in Startup.
Runtime theme mode and page background shade backed by preferences.
AppTheme ¶
Process-wide theme mode and content background colors.
Settings updates these class attributes and persists keys through
SharedPreferences. Startup loads them before the first route so the
first frame matches saved preferences. Shell chrome colors in app.py
are separate and are not stored here.
Attributes:
| Name | Type | Description |
|---|---|---|
theme_mode |
ThemeMode | None
|
Current |
dark_theme_slider_value |
Shade index (1–4) for dark mode. |
|
light_theme_slider_value |
Shade index (1–4) for light mode. |
|
dark_theme_bgcolor |
Resolved dark page/view background color. |
|
light_theme_bgcolor |
Resolved light page/view background color. |
Source code in src/learning_app/ui/app_theme.py
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
is_dark_mode
classmethod
¶
sync_from_page
classmethod
¶
Copy page.theme_mode into theme_mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Application page whose theme mode is authoritative. |
required |
set_slider_value
classmethod
¶
Store the shade slider index for one theme mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme_mode
|
ThemeMode
|
Light or dark mode the value belongs to. |
required |
value
|
Slider position (typically 1–4). |
required |
Source code in src/learning_app/ui/app_theme.py
get_slider_value
classmethod
¶
Return the shade slider index for a mode or the active mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme_mode
|
|
''
|
Returns:
| Type | Description |
|---|---|
|
Integer slider value for that mode. |
Source code in src/learning_app/ui/app_theme.py
set_bgcolor
classmethod
¶
Store the content background color for one theme mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme_mode
|
ThemeMode
|
Light or dark mode the color belongs to. |
required |
color
|
Flet color enum or string value. |
required |
Source code in src/learning_app/ui/app_theme.py
resolve_bgcolor
classmethod
¶
Return the active mode bgcolor, or SURFACE if unset.
Returns:
| Type | Description |
|---|---|
|
Normalized color string for page and view backgrounds. |
Source code in src/learning_app/ui/app_theme.py
apply_bgcolor
classmethod
¶
Set page.bgcolor and every stacked view's bgcolor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Application page. |
required |
bgcolor
|
Color to apply (enum or string). |
required |
Source code in src/learning_app/ui/app_theme.py
apply_to_page
classmethod
¶
Apply the resolved current bgcolor to the page and views.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Page
|
Application page. |
required |
current_bgcolor
classmethod
¶
save_slider_settings
async
classmethod
¶
Persist slider index and bgcolor for one theme mode string.
Writes {mode}_theme_slider_value and {mode}_theme_bgcolor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme_mode_value
|
str
|
|
required |
value
|
int
|
Slider index to store. |
required |
color
|
Background color to store. |
required |
Source code in src/learning_app/ui/app_theme.py
get_bgcolor
classmethod
¶
Return the stored bgcolor for a mode or the active mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme_mode
|
|
''
|
Returns:
| Type | Description |
|---|---|
|
Stored color value, or |
Source code in src/learning_app/ui/app_theme.py
load_from_preferences
async
classmethod
¶
Load light/dark slider values and bgcolors from preferences.
Does not set theme_mode; call sync_from_page after the page
theme mode is restored at startup.