2929#include "pbl/services/i18n/i18n.h"
3030#include "pbl/services/system_task.h"
3131#include "system/bootbits.h"
32+ #include "shell/system_theme.h"
3233#include "system/passert.h"
3334#include "shell/prefs.h"
3435
@@ -62,10 +63,18 @@ typedef struct SettingsData {
6263// Pref change handler
6364///////////////////////
6465
66+ static void prv_refresh_theme_colors (SettingsData * data ) {
67+ const GColor bg = system_theme_get_bg_color ();
68+ const GColor fg = system_theme_get_fg_color ();
69+ window_set_background_color (& data -> window , bg );
70+ status_bar_layer_set_colors (& data -> status_layer , bg , fg );
71+ menu_layer_set_normal_colors (& data -> menu_layer , bg , fg );
72+ layer_mark_dirty (menu_layer_get_layer (& data -> menu_layer ));
73+ }
74+
6575static void prv_pref_change_handler (PebbleEvent * event , void * context ) {
6676 SettingsData * data = context ;
67- // Refresh the menu when any pref changes
68- layer_mark_dirty (menu_layer_get_layer (& data -> menu_layer ));
77+ prv_refresh_theme_colors (data );
6978}
7079
7180// Filter category helpers
@@ -85,8 +94,8 @@ static void prv_set_sub_menu_colors(GContext *ctx, const Layer *cell_layer, bool
8594 graphics_context_set_fill_color (ctx , highlight_bg );
8695 graphics_context_set_text_color (ctx , gcolor_legible_over (highlight_bg ));
8796 } else {
88- graphics_context_set_fill_color (ctx , GColorWhite );
89- graphics_context_set_text_color (ctx , GColorBlack );
97+ graphics_context_set_fill_color (ctx , system_theme_get_bg_color () );
98+ graphics_context_set_text_color (ctx , system_theme_get_fg_color () );
9099 }
91100 graphics_fill_rect (ctx , & cell_layer -> bounds );
92101}
@@ -183,7 +192,7 @@ static void prv_settings_window_load(Window *window) {
183192 ? data -> title_override
184193 : settings_menu_get_status_name (data -> current_category );
185194 status_bar_layer_set_title (status_layer , i18n_get (title , data ), false, false);
186- status_bar_layer_set_colors (status_layer , GColorWhite , GColorBlack );
195+ status_bar_layer_set_colors (status_layer , system_theme_get_bg_color (), system_theme_get_fg_color () );
187196 status_bar_layer_set_separator_mode (status_layer , OPTION_MENU_STATUS_SEPARATOR_MODE );
188197 layer_add_child (& data -> window .layer , status_bar_layer_get_layer (status_layer ));
189198
@@ -203,9 +212,6 @@ static void prv_settings_window_load(Window *window) {
203212 .selection_changed = prv_selection_changed_callback ,
204213 .selection_will_change = prv_selection_will_change_callback ,
205214 });
206- menu_layer_set_normal_colors (menu_layer , GColorWhite , GColorBlack );
207- GColor highlight_bg = shell_prefs_get_theme_highlight_color ();
208- menu_layer_set_highlight_colors (menu_layer , highlight_bg , gcolor_legible_over (highlight_bg ));
209215 menu_layer_set_click_config_onto_window (menu_layer , & data -> window );
210216 menu_layer_set_scroll_wrap_around (menu_layer , shell_prefs_get_menu_scroll_wrap_around_enable ());
211217 menu_layer_set_scroll_vibe_on_wrap (menu_layer , shell_prefs_get_menu_scroll_vibe_behavior () == MenuScrollVibeOnWrapAround );
@@ -234,6 +240,8 @@ static void prv_settings_window_load(Window *window) {
234240
235241static void prv_settings_window_appear (Window * window ) {
236242 SettingsData * data = window_get_user_data (window );
243+ // Refresh colors in case the theme changed while this window was hidden
244+ prv_refresh_theme_colors (data );
237245 SettingsCallbacks * callbacks = prv_get_current_callbacks (data );
238246 if (callbacks -> appear ) {
239247 callbacks -> appear (data -> callbacks );
@@ -312,7 +320,7 @@ void settings_window_destroy(Window *window) {
312320void settings_menu_mark_dirty (SettingsMenuItem category ) {
313321 SettingsData * data = app_state_get_user_data ();
314322 if (data -> current_category == category ) {
315- layer_mark_dirty ( menu_layer_get_layer ( & data -> menu_layer ) );
323+ prv_refresh_theme_colors ( data );
316324 }
317325}
318326
0 commit comments