Skip to content

Commit 2f31d14

Browse files
Remove old theme.py
1 parent 4e95fcf commit 2f31d14

File tree

4 files changed

+28
-93
lines changed

4 files changed

+28
-93
lines changed

internal_filesystem/lib/mpos/ui/appearance_manager.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,26 @@ def set_light_mode(cls, is_light, prefs=None):
155155

156156
print(f"[AppearanceManager] Light mode set to: {is_light}")
157157

158+
@classmethod
159+
def set_theme(cls, prefs):
160+
"""
161+
Set the theme from preferences and reinitialize LVGL theme.
162+
163+
This is a convenience method that loads theme settings from SharedPreferences
164+
and applies them. It's equivalent to calling init() with the preferences.
165+
166+
Args:
167+
prefs: SharedPreferences object containing theme settings
168+
169+
Example:
170+
from mpos import AppearanceManager
171+
import mpos.config
172+
173+
prefs = mpos.config.SharedPreferences("theme_settings")
174+
AppearanceManager.set_theme(prefs)
175+
"""
176+
cls.init(prefs)
177+
158178
# ========== Theme Colors ==========
159179

160180
@classmethod

internal_filesystem/lib/mpos/ui/theme.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

tests/test_graphical_custom_keyboard.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import lvgl as lv
1414
import sys
1515
import os
16-
from mpos import MposKeyboard, wait_for_render, capture_screenshot
16+
from mpos import MposKeyboard, wait_for_render, capture_screenshot, AppearanceManager
1717

1818

1919
class TestGraphicalMposKeyboard(unittest.TestCase):
@@ -200,12 +200,11 @@ def test_keyboard_visibility_light_mode(self):
200200

201201
# Set light mode (should already be default)
202202
import mpos.config
203-
import mpos.ui.theme
204203
prefs = mpos.config.SharedPreferences("theme_settings")
205204
editor = prefs.edit()
206205
editor.put_string("theme_light_dark", "light")
207206
editor.commit()
208-
mpos.ui.theme.set_theme(prefs)
207+
AppearanceManager.set_theme(prefs)
209208
wait_for_render(10)
210209

211210
# Create keyboard

tests/test_graphical_keyboard_styling.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from mpos import (
2626
wait_for_render,
2727
capture_screenshot,
28+
AppearanceManager,
2829
)
2930

3031

@@ -62,7 +63,7 @@ def tearDown(self):
6263
editor.commit()
6364

6465
# Reapply original theme
65-
mpos.ui.theme.set_theme(prefs)
66+
AppearanceManager.set_theme(prefs)
6667

6768
print("=== Test cleanup complete ===\n")
6869

@@ -90,7 +91,7 @@ def _create_test_keyboard(self):
9091
keyboard.set_style_min_height(160, 0)
9192

9293
# Apply the keyboard button fix
93-
mpos.ui.theme.fix_keyboard_button_style(keyboard)
94+
AppearanceManager.apply_keyboard_fix(keyboard)
9495

9596
# Load the screen and wait for rendering
9697
lv.screen_load(screen)
@@ -228,7 +229,7 @@ def test_keyboard_buttons_visible_in_light_mode(self):
228229
editor.commit()
229230

230231
# Apply theme
231-
mpos.ui.theme.set_theme(prefs)
232+
AppearanceManager.set_theme(prefs)
232233
wait_for_render(iterations=10)
233234

234235
# Create test keyboard
@@ -282,7 +283,7 @@ def test_keyboard_buttons_visible_in_dark_mode(self):
282283
editor.commit()
283284

284285
# Apply theme
285-
mpos.ui.theme.set_theme(prefs)
286+
AppearanceManager.set_theme(prefs)
286287
wait_for_render(iterations=10)
287288

288289
# Create test keyboard
@@ -335,7 +336,7 @@ def test_keyboard_buttons_not_pure_white_in_light_mode(self):
335336
editor.commit()
336337

337338
# Apply theme
338-
mpos.ui.theme.set_theme(prefs)
339+
AppearanceManager.set_theme(prefs)
339340
wait_for_render(iterations=10)
340341

341342
# Create test keyboard

0 commit comments

Comments
 (0)