Skip to content

Commit

Permalink
Merge pull request #86 from Zondax/feat-fix-custom-error
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed May 10, 2023
2 parents 361c691 + ccd39a4 commit 05d42ad
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void view_message_show(const char *title, const char *message);
/// view_error (error view)
void view_error_show();

void view_custom_error_show(const char *title, const char *statusString);
void view_custom_error_show(const char *upper, const char *lower);

void view_review_init(viewfunc_getItem_t viewfuncGetItem,
viewfunc_getNumItems_t viewfuncGetNumItems,
Expand Down
2 changes: 2 additions & 0 deletions app/ui/view_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ void view_message_impl(const char *title, const char *message);

void view_error_show_impl();

void view_custom_error_show_impl();

void h_paging_init();

void view_review_show_impl(unsigned int requireReply);
Expand Down
8 changes: 4 additions & 4 deletions app/ui/view_nano.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ void view_error_show() {
view_error_show_impl();
}

void view_custom_error_show(const char *title, const char *statusString) {
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s", title);
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s", statusString);
view_error_show_impl();
void view_custom_error_show(const char *upper, const char *lower) {
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s", upper);
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s", lower);
view_custom_error_show_impl();
}

///////////////////////////////////
Expand Down
10 changes: 10 additions & 0 deletions app/ui/view_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ const ux_menu_entry_t menu_initialize[] = {
UX_MENU_END
};

const ux_menu_entry_t menu_custom_error[] = {
{NULL, NULL, 0, &C_icon_warning, viewdata.key, viewdata.value, 33, 12},
{NULL, h_error_accept, 0, &C_icon_validate, "Ok", NULL, 50, 29},
UX_MENU_END
};

static const bagl_element_t view_message[] = {
UI_BACKGROUND,
UI_LabelLine(UIID_LABEL + 0, 0, 8, UI_SCREEN_WIDTH, UI_11PX, UI_WHITE, UI_BLACK, viewdata.key),
Expand Down Expand Up @@ -331,6 +337,10 @@ void view_error_show_impl() {
UX_DISPLAY(view_error, view_prepro)
}

void view_custom_error_show_impl() {
UX_MENU_DISPLAY(0, menu_custom_error, NULL);
}

void h_expert_toggle() {
app_mode_set_expert(!app_mode_expert());
view_idle_show(1, NULL);
Expand Down
10 changes: 10 additions & 0 deletions app/ui/view_stax.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ void view_error_show() {
view_error_show_impl();
}

void view_custom_error_show(const char *upper, const char *lower) {
viewdata.key = viewdata.keys[0];
viewdata.value = viewdata.values[0];
MEMZERO(viewdata.key, MAX_CHARS_PER_KEY_LINE);
MEMZERO(viewdata.value, MAX_CHARS_PER_VALUE1_LINE);
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, upper);
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, lower);
view_error_show_impl();
}

void view_error_show_impl() {
nbgl_useCaseChoice(&C_round_warning_64px, viewdata.key, viewdata.value, "Ok", NULL, confirm_setting);
}
Expand Down
19 changes: 19 additions & 0 deletions app/ui/view_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ UX_FLOW(

///////////

UX_STEP_NOCB(ux_custom_error_flow_1_step, pbb, { &C_icon_warning, viewdata.key, viewdata.value,});
UX_STEP_VALID(ux_custom_error_flow_2_step, pb, h_error_accept(0), { &C_icon_validate_14, "Ok"});

UX_FLOW(
ux_custom_error_flow,
&ux_custom_error_flow_1_step,
&ux_custom_error_flow_2_step
);

///////////

UX_FLOW_DEF_NOCB(ux_review_flow_1_review_title, pbb, { &C_icon_app, REVIEW_SCREEN_TITLE, REVIEW_SCREEN_TXN_VALUE,});
UX_FLOW_DEF_NOCB(ux_review_flow_2_review_title, pbb, { &C_icon_app, REVIEW_SCREEN_TITLE, REVIEW_SCREEN_ADDR_VALUE,});
UX_FLOW_DEF_NOCB(ux_review_flow_3_review_title, pbb, { &C_icon_app, "Review", "configuration",});
Expand Down Expand Up @@ -424,4 +435,12 @@ void view_error_show_impl() {
}
ux_flow_init(0, ux_error_flow, NULL);
}

void view_custom_error_show_impl() {
ux_layout_bnnn_paging_reset();
if(G_ux.stack_count == 0) {
ux_stack_push();
}
ux_flow_init(0, ux_custom_error_flow, NULL);
}
#endif
2 changes: 1 addition & 1 deletion include/zxversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

#define ZXLIB_MAJOR 19
#define ZXLIB_MINOR 3
#define ZXLIB_PATCH 2
#define ZXLIB_PATCH 3

0 comments on commit 05d42ad

Please sign in to comment.