diff --git a/src_nbgl/ui_confirm_parameter_selector.c b/src_nbgl/ui_confirm_parameter_selector.c index 80418e1..b2daa78 100644 --- a/src_nbgl/ui_confirm_parameter_selector.c +++ b/src_nbgl/ui_confirm_parameter_selector.c @@ -5,79 +5,76 @@ typedef enum { PARAMETER_CONFIRMATION, SELECTOR_CONFIRMATION } e_confirmation_type; -static nbgl_layoutTagValue_t pair; -static e_confirmation_type confirm_type; +enum { + TOKEN_APPROVE = FIRST_USER_TOKEN, +}; static void reviewReject(void) { io_seproxyhal_touch_data_cancel(NULL); } -static void confirmTransation(void) { - io_seproxyhal_touch_data_ok(NULL); -} - -static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); +static void long_press_cb(int token, uint8_t index, int page) { + UNUSED(index); + UNUSED(page); + if (token == TOKEN_APPROVE) { + io_seproxyhal_touch_data_ok(NULL); } } -static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - pair.item = (confirm_type == PARAMETER_CONFIRMATION) ? "Parameter" : "Selector"; - pair.value = strings.tmp.tmp; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 1; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *) &pair; - } else if (page == 1) { - snprintf(g_stax_shared_buffer, - sizeof(g_stax_shared_buffer), - "Confirm %s", - (confirm_type == PARAMETER_CONFIRMATION) ? "parameter" : "selector"); - content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true); - content->infoLongPress.text = g_stax_shared_buffer; - content->infoLongPress.longPressText = "Hold to confirm"; - } else { - return false; - } - // valid page so return true - return true; -} +static void buildScreen(e_confirmation_type confirm_type) { + static nbgl_genericContents_t contents = {0}; + static nbgl_content_t contentsList[3] = {0}; + static nbgl_layoutTagValue_t pair = {0}; + uint8_t nbContents = 0; + uint32_t buf_size = SHARED_BUFFER_SIZE / 2; -static void reviewContinue(void) { snprintf(g_stax_shared_buffer, - sizeof(g_stax_shared_buffer), - "Reject %s", - (confirm_type == PARAMETER_CONFIRMATION) ? "parameter" : "selector"); - nbgl_useCaseRegularReview(0, - 2, - g_stax_shared_buffer, - NULL, - displayTransactionPage, - reviewChoice); -} - -static void buildScreen(void) { - snprintf(g_stax_shared_buffer, - sizeof(g_stax_shared_buffer), + buf_size, "Verify %s", (confirm_type == PARAMETER_CONFIRMATION) ? "parameter" : "selector"); - nbgl_useCaseReviewStart(get_app_icon(true), - g_stax_shared_buffer, - NULL, - REJECT_BUTTON, - reviewContinue, - reviewReject); + // Finish text: replace "Verify" by "Confirm" and add questionmark + snprintf(g_stax_shared_buffer + buf_size, + buf_size, + "Confirm %s", + (confirm_type == PARAMETER_CONFIRMATION) ? "parameter" : "selector"); + + pair.item = (confirm_type == PARAMETER_CONFIRMATION) ? "Parameter" : "Selector"; + pair.value = strings.tmp.tmp; + + // Title page + contentsList[nbContents].type = CENTERED_INFO; + contentsList[nbContents].content.centeredInfo.text1 = g_stax_shared_buffer; + contentsList[nbContents].content.centeredInfo.icon = get_app_icon(true); + contentsList[nbContents].content.centeredInfo.style = LARGE_CASE_INFO; + nbContents++; + + // Values to be reviewed + contentsList[nbContents].type = TAG_VALUE_LIST; + contentsList[nbContents].content.tagValueList.pairs = &pair; + contentsList[nbContents].content.tagValueList.nbPairs = 1; + nbContents++; + + // Approval screen + contentsList[nbContents].type = INFO_LONG_PRESS; + contentsList[nbContents].content.infoLongPress.text = g_stax_shared_buffer + buf_size; + contentsList[nbContents].content.infoLongPress.icon = get_app_icon(true); + contentsList[nbContents].content.infoLongPress.longPressText = "Hold to confirm"; + contentsList[nbContents].content.infoLongPress.longPressToken = TOKEN_APPROVE; + contentsList[nbContents].content.infoLongPress.tuneId = NB_TUNES; + contentsList[nbContents].contentActionCallback = long_press_cb; + nbContents++; + + contents.callbackCallNeeded = false; + contents.contentsList = contentsList; + contents.nbContents = nbContents; + + nbgl_useCaseGenericReview(&contents, REJECT_BUTTON, reviewReject); } void ui_confirm_parameter(void) { - confirm_type = PARAMETER_CONFIRMATION; - buildScreen(); + buildScreen(PARAMETER_CONFIRMATION); } void ui_confirm_selector(void) { - confirm_type = SELECTOR_CONFIRMATION; - buildScreen(); + buildScreen(SELECTOR_CONFIRMATION); } diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_0/00001.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_0/00001.png index fd645cd..a86ceb0 100644 Binary files a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_0/00001.png and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_0/00001.png differ diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00001.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00001.png index 26225e2..5b07865 100644 Binary files a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00001.png and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00001.png differ diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00002.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00002.png index 180800c..12d3fb1 100644 Binary files a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00002.png and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00002.png differ diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00003.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00003.png index 66c411c..37063fd 100644 Binary files a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00003.png and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00003.png differ diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00004.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00004.png new file mode 100644 index 0000000..66c411c Binary files /dev/null and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_1/00004.png differ diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00001.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00001.png index 37021a0..6f079b7 100644 Binary files a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00001.png and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00001.png differ diff --git a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00002.png b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00002.png index 662dfa5..a283d78 100644 Binary files a/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00002.png and b/tests/ragger/snapshots/nanos/test_sign_parameter_selector/step_2/00002.png differ diff --git a/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_0/00001.png b/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_0/00001.png index cfc623a..293eb07 100644 Binary files a/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_0/00001.png and b/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_0/00001.png differ diff --git a/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_1/00001.png b/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_1/00001.png index 1ecbddd..953ecc7 100644 Binary files a/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_1/00001.png and b/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_1/00001.png differ diff --git a/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_2/00001.png b/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_2/00001.png index b05bbb4..6fd3a5e 100644 Binary files a/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_2/00001.png and b/tests/ragger/snapshots/nanosp/test_sign_parameter_selector/step_2/00001.png differ diff --git a/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_0/00001.png b/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_0/00001.png index cfc623a..293eb07 100644 Binary files a/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_0/00001.png and b/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_0/00001.png differ diff --git a/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_1/00001.png b/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_1/00001.png index 1ecbddd..953ecc7 100644 Binary files a/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_1/00001.png and b/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_1/00001.png differ diff --git a/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_2/00001.png b/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_2/00001.png index b05bbb4..6fd3a5e 100644 Binary files a/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_2/00001.png and b/tests/ragger/snapshots/nanox/test_sign_parameter_selector/step_2/00001.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00000.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00000.png index bd589a9..25b9d1e 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00000.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00000.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00001.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00001.png index c4f8fc0..7c87ed0 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00001.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00001.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00002.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00002.png index dfccf36..888518c 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00002.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_0/00002.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00000.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00000.png index 22e1f93..e4a279a 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00000.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00000.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00001.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00001.png index 197a516..a28f949 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00001.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00001.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00002.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00002.png index 98b5a0b..cdad77c 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00002.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_1/00002.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00000.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00000.png index 22e1f93..e4a279a 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00000.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00000.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00001.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00001.png index b549dd9..9c42e08 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00001.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00001.png differ diff --git a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00002.png b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00002.png index 98b5a0b..cdad77c 100644 Binary files a/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00002.png and b/tests/ragger/snapshots/stax/test_sign_parameter_selector/step_2/00002.png differ