Port transaction review steps to 'nbgl_useCaseGenericReview' in ui_display_privacy.c
This commit is contained in:
@@ -1,69 +1,73 @@
|
|||||||
#include "common_ui.h"
|
#include "common_ui.h"
|
||||||
#include "ui_signing.h"
|
#include "ui_signing.h"
|
||||||
#include "ui_nbgl.h"
|
#include "ui_nbgl.h"
|
||||||
#include "ui_callbacks.h"
|
|
||||||
#include "nbgl_use_case.h"
|
#include "nbgl_use_case.h"
|
||||||
#include "network.h"
|
#include "nbgl_content.h"
|
||||||
|
|
||||||
static nbgl_layoutTagValue_t pairs[2];
|
enum {
|
||||||
static char *review_string;
|
TOKEN_APPROVE = FIRST_USER_TOKEN,
|
||||||
|
};
|
||||||
|
|
||||||
static void reviewReject(void) {
|
static void reviewReject(void) {
|
||||||
io_seproxyhal_touch_privacy_cancel(NULL);
|
io_seproxyhal_touch_privacy_cancel(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void confirmTransation(void) {
|
static void long_press_cb(int token, uint8_t index, int page) {
|
||||||
io_seproxyhal_touch_privacy_ok(NULL);
|
UNUSED(index);
|
||||||
}
|
UNUSED(page);
|
||||||
|
if (token == TOKEN_APPROVE) {
|
||||||
static void reviewChoice(bool confirm) {
|
io_seproxyhal_touch_privacy_ok(NULL);
|
||||||
if (confirm) {
|
|
||||||
confirmTransation();
|
|
||||||
} else {
|
|
||||||
reviewReject();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
|
static void buildFirstPage(const char *review_string) {
|
||||||
if (page == 0) {
|
static nbgl_genericContents_t contents = {0};
|
||||||
pairs[0].item = "Address";
|
static nbgl_content_t contentsList[3] = {0};
|
||||||
pairs[0].value = strings.common.fullAddress;
|
static nbgl_layoutTagValue_t pairs[2] = {0};
|
||||||
pairs[1].item = "Key";
|
uint8_t nbContents = 0;
|
||||||
pairs[1].value = strings.common.fullAmount;
|
uint8_t nbPairs = 0;
|
||||||
|
|
||||||
content->type = TAG_VALUE_LIST;
|
pairs[nbPairs].item = "Address";
|
||||||
content->tagValueList.nbPairs = 2;
|
pairs[nbPairs].value = strings.common.fullAddress;
|
||||||
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
|
nbPairs++;
|
||||||
} else if (page == 1) {
|
pairs[nbPairs].item = "Key";
|
||||||
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
|
pairs[nbPairs].value = strings.common.fullAmount;
|
||||||
content->infoLongPress.text = review_string;
|
nbPairs++;
|
||||||
content->infoLongPress.longPressText = "Hold to approve";
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// valid page so return true
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reviewContinue(void) {
|
// Title page
|
||||||
nbgl_useCaseRegularReview(0, 2, REJECT_BUTTON, NULL, displayTransactionPage, reviewChoice);
|
contentsList[nbContents].type = CENTERED_INFO;
|
||||||
}
|
contentsList[nbContents].content.centeredInfo.text1 = review_string;
|
||||||
|
contentsList[nbContents].content.centeredInfo.icon = get_app_icon(true);
|
||||||
|
contentsList[nbContents].content.centeredInfo.style = LARGE_CASE_INFO;
|
||||||
|
nbContents++;
|
||||||
|
|
||||||
static void buildFirstPage(void) {
|
// Values to be reviewed
|
||||||
nbgl_useCaseReviewStart(get_app_icon(true),
|
contentsList[nbContents].type = TAG_VALUE_LIST;
|
||||||
review_string,
|
contentsList[nbContents].content.tagValueList.pairs = pairs;
|
||||||
NULL,
|
contentsList[nbContents].content.tagValueList.nbPairs = nbPairs;
|
||||||
REJECT_BUTTON,
|
nbContents++;
|
||||||
reviewContinue,
|
|
||||||
reviewReject);
|
// Approval screen
|
||||||
|
contentsList[nbContents].type = INFO_LONG_PRESS;
|
||||||
|
contentsList[nbContents].content.infoLongPress.text = review_string;
|
||||||
|
contentsList[nbContents].content.infoLongPress.icon = get_app_icon(true);
|
||||||
|
contentsList[nbContents].content.infoLongPress.longPressText = "Hold to approve";
|
||||||
|
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_display_privacy_public_key(void) {
|
void ui_display_privacy_public_key(void) {
|
||||||
review_string = (char *) "Provide public\nprivacy key";
|
buildFirstPage("Provide public\nprivacy key");
|
||||||
buildFirstPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_display_privacy_shared_secret(void) {
|
void ui_display_privacy_shared_secret(void) {
|
||||||
review_string = (char *) "Provide public\nsecret key";
|
buildFirstPage("Provide public\nsecret key");
|
||||||
buildFirstPage();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user