Skip to content

Commit 3a1ec48

Browse files
amcolashclaude
andcommitted
fw: Apply dark mode to timeline and notifications
Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrew McOlash <amcolash@gmail.com>
1 parent 1bf7bbb commit 3a1ec48

9 files changed

Lines changed: 30 additions & 12 deletions

File tree

src/fw/apps/system/timeline/layer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,15 +613,15 @@ static void prv_update_proc(struct Layer *layer, GContext* ctx) {
613613
TimelineLayer *timeline_layer = (TimelineLayer *)layer;
614614
const GRect *bounds = &layer->bounds;
615615

616-
graphics_context_set_fill_color(ctx, GColorWhite);
616+
graphics_context_set_fill_color(ctx, system_theme_get_bg_color());
617617
graphics_fill_rect(ctx, &(GRect) { .size = bounds->size });
618618

619619
AnimationProgress progress;
620620
if (timeline_layer->animating_intro_or_exit &&
621621
animation_get_progress(timeline_layer->animation, &progress)) {
622622
const GPoint offset = { PEEK_ANIMATIONS_SPEED_LINES_OFFSET_X,
623623
interpolate_int64_linear(progress, 0, -DISP_ROWS) };
624-
graphics_context_set_fill_color(ctx, GColorBlack);
624+
graphics_context_set_fill_color(ctx, system_theme_get_fg_color());
625625
peek_animations_draw_timeline_speed_lines(ctx, offset);
626626
}
627627

@@ -934,6 +934,7 @@ void timeline_layer_init(TimelineLayer *layer, const GRect *frame_ref,
934934
};
935935
peek_layer_set_icon(&layer->day_separator, &timeline_res);
936936
peek_layer_set_background_color(&layer->day_separator, GColorClear);
937+
peek_layer_set_text_color(&layer->day_separator, system_theme_get_fg_color());
937938
peek_layer_set_dot_diameter(&layer->day_separator, style->day_sep_dot_diameter);
938939
layer_set_hidden((Layer *)&layer->day_separator, true);
939940
layer_add_child((Layer *)layer, (Layer *)&layer->day_separator);

src/fw/apps/system/timeline/peek_layer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void prv_update_proc(Layer *layer, GContext *ctx) {
4646
}
4747

4848
if (peek_layer->show_dot) {
49-
graphics_context_set_fill_color(ctx, GColorBlack);
49+
graphics_context_set_fill_color(ctx, system_theme_get_fg_color());
5050
GRect dot_rect = { .size = { peek_layer->dot_diameter, peek_layer->dot_diameter } };
5151
grect_align(&dot_rect, &peek_layer->layer.bounds, GAlignCenter, false /* clip */);
5252
graphics_fill_radial(ctx, dot_rect, GOvalScaleModeFitCircle, peek_layer->dot_diameter, 0,
@@ -168,6 +168,12 @@ void peek_layer_set_background_color(PeekLayer *peek_layer, GColor color) {
168168
peek_layer->bg_color = color;
169169
}
170170

171+
void peek_layer_set_text_color(PeekLayer *peek_layer, GColor color) {
172+
text_layer_set_text_color(&peek_layer->number.text_layer, color);
173+
text_layer_set_text_color(&peek_layer->title.text_layer, color);
174+
text_layer_set_text_color(&peek_layer->subtitle.text_layer, color);
175+
}
176+
171177
static bool prv_is_dot_size(GSize size) {
172178
return (size.w <= UNFOLD_DOT_SIZE_PX && size.h <= UNFOLD_DOT_SIZE_PX);
173179
}

src/fw/apps/system/timeline/peek_layer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ ImmutableAnimation *peek_layer_create_play_section_animation(PeekLayer *peek_lay
9999
//! Set the background color of the peek layer.
100100
void peek_layer_set_background_color(PeekLayer *peek_layer, GColor color);
101101

102+
//! Set the text color of all peek layer text fields.
103+
void peek_layer_set_text_color(PeekLayer *peek_layer, GColor color);
104+
102105
//! Sets the text of the peek layer text fields. The text is copied over.
103106
//! See the individual text field setters for more information about each field.
104107
void peek_layer_set_fields(PeekLayer *peek_layer, const char *number, const char *title,

src/fw/popups/notifications/notification_window.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "pbl/services/timeline/timeline_resources.h"
5252
#include "system/logging.h"
5353
#include "system/passert.h"
54+
#include "shell/system_theme.h"
5455
#include "util/math.h"
5556
#include "util/trig.h"
5657

@@ -1167,7 +1168,7 @@ static void prv_layout_did_appear_handler(SwapLayer *swap_layer, LayoutLayer *la
11671168
static void prv_update_colors_handler(SwapLayer *swap_layer, GColor bg_color,
11681169
bool status_bar_filled, void *context) {
11691170
NotificationWindowData *data = context;
1170-
GColor status_color = (status_bar_filled) ? bg_color : GColorWhite;
1171+
GColor status_color = (status_bar_filled) ? bg_color : system_theme_get_bg_color();
11711172
// Status bar is clear on round, because the banner is rendered under it
11721173
status_bar_layer_set_colors(&data->status_layer, PBL_IF_ROUND_ELSE(GColorClear, status_color),
11731174
gcolor_legible_over(status_color));

src/fw/popups/timeline/peek.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void prv_draw_background(GContext *ctx, const GRect *frame_orig,
4747
// Fill all the way to the bottom of the screen
4848
frame.size.h = DISP_ROWS - frame.origin.y;
4949
#endif
50-
const GColor background_color = GColorWhite;
50+
const GColor background_color = system_theme_get_bg_color();
5151
graphics_context_set_fill_color(ctx, background_color);
5252
graphics_fill_rect(ctx, &frame);
5353

@@ -59,7 +59,7 @@ static void prv_draw_background(GContext *ctx, const GRect *frame_orig,
5959

6060
// Draw the top border and concurrent event indicators
6161
frame = *frame_orig;
62-
const GColor border_color = GColorBlack;
62+
const GColor border_color = system_theme_is_dark_mode() ? GColorDarkGray : GColorBlack;
6363
for (unsigned int i = 0; i <= num_concurrent; i++) {
6464
const bool has_content = (i < num_concurrent);
6565
for (unsigned int type = 0; type < (has_content ? 2 : 1); type++) {
@@ -421,7 +421,7 @@ static void prv_push_timeline_peek(void *unused) {
421421
void timeline_peek_init(void) {
422422
TimelinePeek *peek = &s_peek;
423423
*peek = (TimelinePeek) {
424-
#if CAPABILITY_HAS_TIMELINE_PEEK && !SHELL_SDK && !TARGET_QEMU
424+
#if CAPABILITY_HAS_TIMELINE_PEEK && !SHELL_SDK
425425
.enabled = timeline_peek_prefs_get_enabled(),
426426
#endif
427427
};
@@ -458,7 +458,7 @@ static bool prv_can_animate(void) {
458458

459459
void timeline_peek_set_visible(bool visible, bool animated) {
460460
TimelinePeek *peek = &s_peek;
461-
#if !SHELL_SDK && !TARGET_QEMU
461+
#if !SHELL_SDK
462462
if (!peek->exists) {
463463
visible = false;
464464
}

src/fw/services/timeline/notification_layout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static NOINLINE void prv_card_render_internal(NotificationLayout *layout, GConte
483483
.text_flow = PBL_IF_ROUND_ELSE(true, false),
484484
.paging = PBL_IF_ROUND_ELSE(true, false),
485485
};
486-
graphics_context_set_text_color(ctx, GColorBlack);
486+
graphics_context_set_text_color(ctx, system_theme_get_fg_color());
487487
(text_visible ? graphics_text_node_draw :
488488
graphics_text_node_get_size)(layout->view_node, ctx, &box, &config,
489489
&layout->view_size);

src/fw/services/timeline/swap_layer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "pbl/services/timeline/layout_layer.h"
1515
#include "pbl/services/timeline/notification_layout.h"
1616
#include "pbl/services/notifications/alerts_preferences_private.h"
17+
#include "shell/system_theme.h"
1718
#include "kernel/ui/kernel_ui.h"
1819
#include "process_state/app_state/app_state.h"
1920
#include "system/logging.h"
@@ -243,7 +244,7 @@ static void prv_arrow_layer_update_proc(Layer *layer, GContext* ctx) {
243244
const GRect *layer_bounds = &layer->bounds;
244245

245246
#if PBL_RECT
246-
graphics_context_set_fill_color(ctx, GColorWhite);
247+
graphics_context_set_fill_color(ctx, system_theme_get_bg_color());
247248
graphics_fill_rect(ctx, layer_bounds);
248249
#endif
249250

@@ -261,7 +262,11 @@ static void prv_arrow_layer_update_proc(Layer *layer, GContext* ctx) {
261262
#if UNITTEST
262263
const GCompOp compositing_mode = GCompOpSet;
263264
#else
264-
const GCompOp compositing_mode = PBL_IF_COLOR_ELSE(GCompOpSet, GCompOpAssign);
265+
// Arrow color is inverted in dark mode
266+
const GCompOp compositing_mode = PBL_IF_COLOR_ELSE(
267+
system_theme_is_dark_mode() ? GCompOpTint : GCompOpSet,
268+
GCompOpAssign
269+
);
265270
#endif
266271
graphics_context_set_compositing_mode(ctx, compositing_mode);
267272

src/fw/services/timeline/timeline_layout.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ static void prv_render_view(TimelineLayout *layout, GContext *ctx, bool render,
659659
GRect box;
660660
(is_card ? prv_get_card_view_bounds : prv_get_pin_view_bounds)(layout, &box);
661661
graphics_context_set_text_color(
662-
ctx, (is_card ? layout_get_colors((LayoutLayer *)layout)->primary_color : GColorBlack));
662+
ctx, (is_card ? layout_get_colors((LayoutLayer *)layout)->primary_color :
663+
system_theme_get_fg_color()));
663664
static const GRect page_frame_on_screen =
664665
{ { 0, STATUS_BAR_LAYER_HEIGHT }, { DISP_COLS, DISP_ROWS - STATUS_BAR_LAYER_HEIGHT } };
665666
const GTextNodeDrawConfig config = {

tests/fw/ui/test_jumboji.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "stubs_pin_db.h"
2727
#include "stubs_resources.h"
2828
#include "stubs_shell_prefs.h"
29+
#include "stubs_system_theme.h"
2930
#include "stubs_text_node.h"
3031
#include "stubs_timeline_item.h"
3132
#include "stubs_timeline_resources.h"

0 commit comments

Comments
 (0)