Initial scroll layer implementation for status page

This commit is contained in:
2026-08-11 23:53:56 -04:00
parent 5a440ab1a7
commit 0233ece85f
+15 -4
View File
@@ -11,6 +11,7 @@ static Window *s_drop_window;
static Layer *s_top_bar_layer;
static Layer *s_bottom_bar_layer;
static TextLayer *s_counter_txt_layer;
static ScrollLayer *s_status_scroll_layer;
static TextLayer *s_status_txt_layer;
//// setter
static BitmapLayer *s_clock_bmp_layer;
@@ -98,6 +99,8 @@ static void status_2_select_click_handler(void *recognizer, void *ctx) {
}
static void status_0_click_config_provider(void *ctx) {
window_single_click_subscribe(BUTTON_ID_UP, scroll_layer_scroll_up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, scroll_layer_scroll_down_click_handler);
window_single_click_subscribe(BUTTON_ID_BACK, status_0_1_back_click_handler);
window_single_click_subscribe(BUTTON_ID_SELECT, status_0_select_click_handler);
}
@@ -116,13 +119,15 @@ static void status_2_click_config_provider(void *ctx) {
static void status_window_load(uint8_t reason) {
Layer *window_layer = window_get_root_layer(s_status_window);
s_status_scroll_layer = scroll_layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
switch (reason) {
case 0:
tick_timer_service_unsubscribe();
s_status_txt_layer = text_layer_create(GRect(0, 8, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
s_status_txt_layer = text_layer_create(GRect(0, 8, PBL_DISPLAY_WIDTH, 500));
text_layer_set_font(s_status_txt_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
text_layer_set_text(s_status_txt_layer, "Alarm disarmed and re-set successfully.\n\nLast four times:\n1. 12:23\n2. 13:41\n3. 16:11\n4. 16:17");
window_set_click_config_provider(s_status_window, status_0_click_config_provider);
text_layer_set_text(s_status_txt_layer, "Alarm disarmed and re-set successfully.\n\nLast seven times:\n1. 00:00\n2. 00:00\n3. 00:00\n4. 00:00\n5. 00:00\n6. 00:00\n7. 00:00");
window_set_click_config_provider_with_context(s_status_window, status_0_click_config_provider, s_status_scroll_layer);
break;
case 1:
tick_timer_service_unsubscribe();
@@ -139,11 +144,17 @@ static void status_window_load(uint8_t reason) {
}
text_layer_set_background_color(s_status_txt_layer, GColorClear);
text_layer_set_text_alignment(s_status_txt_layer, GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(s_status_txt_layer));
scroll_layer_add_child(s_status_scroll_layer, text_layer_get_layer(s_status_txt_layer));
layer_add_child(window_layer, scroll_layer_get_layer(s_status_scroll_layer));
GSize max_size = text_layer_get_content_size(s_status_txt_layer);
max_size.h += 10;
scroll_layer_set_content_size(s_status_scroll_layer, max_size);
}
static void status_window_unload() {
text_layer_destroy(s_status_txt_layer);
scroll_layer_destroy(s_status_scroll_layer);
}
// reasons: 0 = confirmation, 1 = failure to set alarm, 2 = user sucks at math