From 67ed98c1002b1df3261ec095d4836e78e420592e Mon Sep 17 00:00:00 2001 From: Eric Betts Date: Sun, 7 Apr 2024 23:42:25 -0700 Subject: [PATCH] Picopass: add subheader to loclass UI (#197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: あく --- picopass/scenes/picopass_scene_loclass.c | 1 + picopass/views/loclass.c | 26 +++++++++++++++++++++++- picopass/views/loclass.h | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/picopass/scenes/picopass_scene_loclass.c b/picopass/scenes/picopass_scene_loclass.c index 616cba05..0015bda6 100644 --- a/picopass/scenes/picopass_scene_loclass.c +++ b/picopass/scenes/picopass_scene_loclass.c @@ -36,6 +36,7 @@ void picopass_scene_loclass_on_enter(void* context) { loclass_set_callback(picopass->loclass, picopass_loclass_result_callback, picopass); loclass_set_header(picopass->loclass, "Loclass"); + loclass_set_subheader(picopass->loclass, "Hold To Reader"); picopass_blink_emulate_start(picopass); view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewLoclass); diff --git a/picopass/views/loclass.c b/picopass/views/loclass.c index 4f9da2a4..f46a9dfc 100644 --- a/picopass/views/loclass.c +++ b/picopass/views/loclass.c @@ -13,14 +13,16 @@ struct Loclass { typedef struct { FuriString* header; uint8_t num_macs; + FuriString* subheader; } LoclassViewModel; static void loclass_draw_callback(Canvas* canvas, void* model) { LoclassViewModel* m = model; char draw_str[32] = {}; - canvas_set_font(canvas, FontSecondary); + canvas_set_font(canvas, FontPrimary); canvas_draw_str_aligned(canvas, 64, 0, AlignCenter, AlignTop, furi_string_get_cstr(m->header)); + canvas_set_font(canvas, FontSecondary); if(m->num_macs == 255) { return; @@ -37,6 +39,9 @@ static void loclass_draw_callback(Canvas* canvas, void* model) { elements_progress_bar_with_text(canvas, 0, 20, 128, progress, draw_str); + canvas_draw_str_aligned( + canvas, 64, 45, AlignCenter, AlignBottom, furi_string_get_cstr(m->subheader)); + elements_button_center(canvas, "Skip"); } @@ -61,6 +66,11 @@ Loclass* loclass_alloc() { view_set_context(loclass->view, loclass); with_view_model( loclass->view, LoclassViewModel * model, { model->header = furi_string_alloc(); }, false); + with_view_model( + loclass->view, + LoclassViewModel * model, + { model->subheader = furi_string_alloc(); }, + false); return loclass; } @@ -68,6 +78,8 @@ void loclass_free(Loclass* loclass) { furi_assert(loclass); with_view_model( loclass->view, LoclassViewModel * model, { furi_string_free(model->header); }, false); + with_view_model( + loclass->view, LoclassViewModel * model, { furi_string_free(model->subheader); }, false); view_free(loclass->view); free(loclass); } @@ -80,6 +92,7 @@ void loclass_reset(Loclass* loclass) { { model->num_macs = 0; furi_string_reset(model->header); + furi_string_reset(model->subheader); }, false); } @@ -104,6 +117,17 @@ void loclass_set_header(Loclass* loclass, const char* header) { loclass->view, LoclassViewModel * model, { furi_string_set(model->header, header); }, true); } +void loclass_set_subheader(Loclass* loclass, const char* subheader) { + furi_assert(loclass); + furi_assert(subheader); + + with_view_model( + loclass->view, + LoclassViewModel * model, + { furi_string_set(model->subheader, subheader); }, + true); +} + void loclass_set_num_macs(Loclass* loclass, uint16_t num_macs) { furi_assert(loclass); with_view_model( diff --git a/picopass/views/loclass.h b/picopass/views/loclass.h index 0e39b608..fc5a49d5 100644 --- a/picopass/views/loclass.h +++ b/picopass/views/loclass.h @@ -19,4 +19,6 @@ void loclass_set_callback(Loclass* loclass, LoclassCallback callback, void* cont void loclass_set_header(Loclass* loclass, const char* header); +void loclass_set_subheader(Loclass* loclass, const char* subheader); + void loclass_set_num_macs(Loclass* loclass, uint16_t num_macs);