Port transaction review steps to 'nbgl_useCaseGenericReview' in 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);
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 380 B |
|
Before Width: | Height: | Size: 454 B After Width: | Height: | Size: 445 B |
|
Before Width: | Height: | Size: 478 B After Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 322 B |
|
After Width: | Height: | Size: 341 B |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 347 B After Width: | Height: | Size: 365 B |
|
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 402 B |
|
Before Width: | Height: | Size: 667 B After Width: | Height: | Size: 689 B |
|
Before Width: | Height: | Size: 501 B After Width: | Height: | Size: 520 B |
|
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 402 B |
|
Before Width: | Height: | Size: 667 B After Width: | Height: | Size: 689 B |
|
Before Width: | Height: | Size: 501 B After Width: | Height: | Size: 520 B |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 8.5 KiB |