16#include "os_io_seph_ux.h"
19#include "os_helpers.h"
26#define PAGE_NB_ELEMENTS_BITS 3
27#define GET_PAGE_NB_ELEMENTS(pageData) ((pageData) &0x07)
28#define SET_PAGE_NB_ELEMENTS(nbElements) ((nbElements) &0x07)
30#define PAGE_FLAG_BITS 1
31#define GET_PAGE_FLAG(pageData) (((pageData) &0x08) >> 3)
32#define SET_PAGE_FLAG(flag) (((flag) &0x01) << 3)
34#define PAGE_DATA_BITS (PAGE_NB_ELEMENTS_BITS + PAGE_FLAG_BITS)
35#define PAGES_PER_UINT8 (8 / PAGE_DATA_BITS)
36#define SET_PAGE_DATA(pageIdx, pageData) \
37 (pagesData[pageIdx / PAGES_PER_UINT8] = pageData \
38 << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS))
40#define MAX_PAGE_NB 256
41#define MAX_MODAL_PAGE_NB 32
44#define STARTING_CONTENT localContentsList[0]
45#define FINISHING_CONTENT localContentsList[1]
48#define QRCODE_NB_MAX_LINES 3
50#define QRCODE_REDUCED_ADDR_LEN 128
53#define ADDR_VERIF_NB_PAIRS 3
56#define sharedContext genericContext.sharedCtx
57#define keypadContext sharedContext.keypad
58#define keyboardContext sharedContext.keyboard
59#define reviewWithWarnCtx sharedContext.reviewWithWarning
60#define choiceWithDetailsCtx sharedContext.choiceWithDetails
63#define W3C_DESCRIPTION_MAX_LEN 128
76 ADDRESS_QRCODE_BUTTON_TOKEN,
89 QUIT_TIPBOX_MODAL_TOKEN,
92 DISMISS_WARNING_TOKEN,
93 DISMISS_DETAILS_TOKEN,
95 KEYBOARD_BUTTON_TOKEN,
109typedef struct DetailsContext_s {
112 uint8_t currentPairIdx;
116 const char *nextPageStart;
119typedef struct AddressConfirmationContext_s {
123} AddressConfirmationContext_t;
126typedef struct KeypadContext_s {
129 uint8_t pinMinDigits;
130 uint8_t pinMaxDigits;
138typedef struct KeyboardContext_s {
149typedef struct ReviewWithWarningContext_s {
154 const char *reviewTitle;
155 const char *reviewSubTitle;
156 const char *finishTitle;
161 uint8_t securityReportLevel;
163} ReviewWithWarningContext_t;
165typedef struct ChoiceWithDetailsContext_s {
170} ChoiceWithDetailsContext_t;
174 SHARE_CTX_REVIEW_WITH_WARNING,
175 SHARE_CTX_CHOICE_WITH_DETAILS,
176} SharedContextUsage_t;
183 KeypadContext_t keypad;
186 KeyboardContext_t keyboard;
188 ReviewWithWarningContext_t reviewWithWarning;
189 ChoiceWithDetailsContext_t choiceWithDetails;
191 SharedContextUsage_t usage;
195 USE_CASE_GENERIC = 0,
197} GenericContextType_t;
200 GenericContextType_t type;
201 uint8_t spinnerPosition;
203 int8_t currentContentIdx;
204 uint8_t currentContentElementNb;
205 uint8_t currentElementIdx;
206 bool hasStartingContent;
207 bool hasFinishingContent;
208 const char *detailsItem;
209 const char *detailsvalue;
210 bool detailsWrapping;
211 bool validWarningCtx;
221 SharedContext_t sharedCtx;
232} nbgl_homeAndSettingsContext_t;
237} nbgl_reviewContext_t;
245} nbgl_reviewStreamingContext_t;
248 nbgl_homeAndSettingsContext_t homeAndSettings;
249 nbgl_reviewContext_t review;
250 nbgl_reviewStreamingContext_t reviewStreaming;
251} nbgl_BundleNavContext_t;
257} SecurityReportItem_t;
264static char tmpString[W3C_DESCRIPTION_MAX_LEN];
281static const char *pageTitle;
284#define activeTipBox genericContext.tipBox
288static NavType_t navType;
290static DetailsContext_t detailsContext;
293static AddressConfirmationContext_t addressConfirmationContext;
296static GenericContext_t genericContext;
298 localContentsList[3];
299static uint8_t genericContextPagesInfo[MAX_PAGE_NB / PAGES_PER_UINT8];
300static uint8_t modalContextPagesInfo[MAX_MODAL_PAGE_NB / PAGES_PER_UINT8];
303static nbgl_BundleNavContext_t bundleNavContext;
306static const uint8_t nbMaxElementsPerContentType[] = {
323 .icon = &WARNING_ICON,
324 .text =
"Blind signing required",
325 .subText =
"This transaction's details are not fully verifiable. If "
326 "you sign, you could lose all your assets."
329 .icon = &WARNING_ICON,
330 .text =
"Transaction Check unavailable",
334 .icon = &WARNING_ICON,
335 .text =
"Risk detected",
336 .subText =
"This transaction was scanned as risky by Web3 Checks."
339 .icon = &WARNING_ICON,
340 .text =
"Critical threat",
341 .subText =
"This transaction was scanned as malicious by Web3 Checks."
345 .text =
"No threat detected",
346 .subText =
"Transaction Check didn't find any threat, but always "
347 "review transaction details carefully."
357static char reducedAddress[QRCODE_REDUCED_ADDR_LEN];
363static void displayReviewPage(uint8_t page,
bool forceFullRefresh);
364static void displayDetailsPage(uint8_t page,
bool forceFullRefresh);
365static void displayTagValueListModalPage(uint8_t pageIdx,
bool forceFullRefresh);
366static void displayFullValuePage(
const char *backText,
367 const char *aliasText,
369static void displayInfosListModal(
const char *modalTitle,
373static void displaySettingsPage(uint8_t page,
bool forceFullRefresh);
374static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh);
375static void pageCallback(
int token, uint8_t index);
377static uint8_t getNbInfosInPage(uint8_t nbInfos,
381static uint8_t getNbSwitchesInPage(uint8_t nbSwitches,
385static uint8_t getNbBarsInPage(uint8_t nbBars,
390static void displayAddressQRCode(
void);
392static void modalLayoutTouchCallback(
int token, uint8_t index);
393static void displaySkipWarning(
void);
395static void bundleNavStartHome(
void);
396static void bundleNavStartSettingsAtPage(uint8_t initSettingPage);
397static void bundleNavStartSettings(
void);
399static void bundleNavReviewStreamingChoice(
bool confirm);
401static void displaySecurityReport(uint32_t set);
403static void displayInitialWarning(
void);
407 const char *reviewTitle,
408 const char *reviewSubTitle,
409 const char *finishTitle,
413 bool playNotifSound);
416 const char *reviewTitle,
417 const char *reviewSubTitle,
419 bool playNotifSound);
420static void useCaseHomeExt(
const char *appName,
427static void displayDetails(
const char *tag,
const char *value,
bool wrapping);
429static void reset_callbacks_and_context(
void)
436 onContentAction = NULL;
438 memset(&genericContext, 0,
sizeof(genericContext));
442static void genericContextSetPageInfo(uint8_t pageIdx, uint8_t nbElements,
bool flag)
444 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements) + SET_PAGE_FLAG(flag);
446 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
447 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
448 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
449 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
453static void genericContextGetPageInfo(uint8_t pageIdx, uint8_t *nbElements,
bool *flag)
455 uint8_t pageData = genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
456 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
457 if (nbElements != NULL) {
458 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
461 *flag = GET_PAGE_FLAG(pageData);
466static void modalContextSetPageInfo(uint8_t pageIdx, uint8_t nbElements)
468 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements);
470 modalContextPagesInfo[pageIdx / PAGES_PER_UINT8]
471 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
472 modalContextPagesInfo[pageIdx / PAGES_PER_UINT8]
473 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
477static void modalContextGetPageInfo(uint8_t pageIdx, uint8_t *nbElements)
479 uint8_t pageData = modalContextPagesInfo[pageIdx / PAGES_PER_UINT8]
480 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
481 if (nbElements != NULL) {
482 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
489 switch (content->
type) {
513 if (contentIdx < 0 || contentIdx >= genericContents->
nbContents) {
530static void prepareNavInfo(
bool isReview, uint8_t nbPages,
const char *rejectText)
532 memset(&navInfo, 0,
sizeof(navInfo));
535 navInfo.
tuneId = TUNE_TAP_CASUAL;
539 if (isReview ==
false) {
548 = ((navType == STREAMING_NAV) && (nbPages < 2)) ?
false : true;
555 const char *reviewTitle,
556 const char *reviewSubTitle)
558 contentCenter->
icon = icon;
559 contentCenter->
title = reviewTitle;
561 contentCenter->
subText =
"Swipe to review";
564 contentCenter->
padding =
false;
570 if (finishTitle != NULL) {
575 return "Sign transaction";
577 return "Sign message";
579 return "Sign operation";
586 const char *finishTitle)
588 infoLongPress->
text = getFinishTitle(operationType, finishTitle);
589 infoLongPress->
icon = icon;
597 const char *finishTitle)
599 infoButton->
text = getFinishTitle(operationType, finishTitle);
600 infoButton->
icon = icon;
620static void pageModalCallback(
int token, uint8_t index)
624 if (token == INFOS_TIP_BOX_TOKEN) {
626 displayFullValuePage(activeTipBox.infos.infoTypes[index],
627 activeTipBox.infos.infoContents[index],
628 &activeTipBox.infos.infoExtensions[index]);
631 else if (token == INFO_ALIAS_TOKEN) {
633 displayFullValuePage(genericContext.currentInfos->infoTypes[index],
634 genericContext.currentInfos->infoContents[index],
635 &genericContext.currentInfos->infoExtensions[index]);
639 modalPageContext = NULL;
640 if (token == NAV_TOKEN) {
647 displayDetailsPage(index,
false);
650 if (token == MODAL_NAV_TOKEN) {
657 displayTagValueListModalPage(index,
false);
660 else if (token == QUIT_TOKEN) {
665 else if (token == QUIT_TIPBOX_MODAL_TOKEN) {
667 if (reviewWithWarnCtx.securityReportLevel == 2) {
668 reviewWithWarnCtx.securityReportLevel = 1;
669 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
677 else if (token == SKIP_TOKEN) {
688 else if (token == CHOICE_TOKEN) {
690 if (onModalConfirm != NULL) {
692 onModalConfirm = NULL;
704static void pageCallback(
int token, uint8_t index)
707 if (token == QUIT_TOKEN) {
708 if (onQuit != NULL) {
712 else if (token == CONTINUE_TOKEN) {
713 if (onContinue != NULL) {
717 else if (token == CHOICE_TOKEN) {
718 if (onChoice != NULL) {
719 onChoice((index == 0) ?
true : false);
722 else if (token == ACTION_BUTTON_TOKEN) {
723 if ((index == 0) && (onAction != NULL)) {
726 else if ((index == 1) && (onQuit != NULL)) {
731 else if (token == ADDRESS_QRCODE_BUTTON_TOKEN) {
732 displayAddressQRCode();
735 else if (token == CONFIRM_TOKEN) {
736 if (onChoice != NULL) {
740 else if (token == REJECT_TOKEN) {
741 if (onChoice != NULL) {
745 else if (token == DETAILS_BUTTON_TOKEN) {
746 displayDetails(genericContext.detailsItem,
747 genericContext.detailsvalue,
748 genericContext.detailsWrapping);
750 else if (token == NAV_TOKEN) {
752 if (onQuit != NULL) {
757 if (navType == GENERIC_NAV || navType == STREAMING_NAV) {
758 displayGenericContextPage(index,
false);
760 else if (navType == REVIEW_NAV) {
761 displayReviewPage(index,
false);
764 displaySettingsPage(index,
false);
768 else if (token == NEXT_TOKEN) {
770 displayReviewPage(navInfo.
activePage + 1,
false);
773 displayGenericContextPage(navInfo.
activePage + 1,
false);
776 else if (token == BACK_TOKEN) {
778 displayReviewPage(navInfo.
activePage - 1,
true);
781 displayGenericContextPage(navInfo.
activePage - 1,
false);
784 else if (token == SKIP_TOKEN) {
786 displaySkipWarning();
788 else if (token == VALUE_ALIAS_TOKEN) {
791 if (genericContext.currentPairs != NULL) {
792 pair = &genericContext.currentPairs[genericContext.currentElementIdx + index];
795 pair = genericContext.currentCallback(genericContext.currentElementIdx + index);
799 else if (token == BLIND_WARNING_TOKEN) {
800 reviewWithWarnCtx.isIntro =
false;
801 reviewWithWarnCtx.warning = NULL;
804 else if (token == WARNING_BUTTON_TOKEN) {
806 reviewWithWarnCtx.securityReportLevel = 1;
808 if (reviewWithWarnCtx.warning->predefinedSet) {
809 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
813 if (reviewWithWarnCtx.isIntro) {
814 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->introDetails);
817 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->reviewDetails);
821 else if (token == TIP_BOX_TOKEN) {
823 if (genericContext.validWarningCtx && (reviewWithWarnCtx.warning->predefinedSet != 0)) {
824 reviewWithWarnCtx.securityReportLevel = 1;
825 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
828 displayInfosListModal(activeTipBox.modalTitle, &activeTipBox.infos,
false);
832 if (onContentAction != NULL) {
833 onContentAction(token, index, navInfo.
activePage);
835 if (onControls != NULL) {
836 onControls(token, index);
842static void tickerCallback(
void)
845 if (onQuit != NULL) {
851static void displaySettingsPage(uint8_t page,
bool forceFullRefresh)
859 if (onNav(page, &content) ==
false) {
864 content.
title = pageTitle;
867 content.
tuneId = TUNE_TAP_CASUAL;
872 if (forceFullRefresh) {
881static void displayReviewPage(uint8_t page,
bool forceFullRefresh)
894 if (onNav(navInfo.
activePage, &content) ==
false) {
899 content.
title = NULL;
901 content.
tuneId = TUNE_TAP_CASUAL;
929 if (forceFullRefresh) {
939static const nbgl_content_t *genericContextComputeNextPageParams(uint8_t pageIdx,
941 uint8_t *p_nbElementsInNextPage,
944 int8_t nextContentIdx = genericContext.currentContentIdx;
945 int16_t nextElementIdx = genericContext.currentElementIdx;
946 uint8_t nbElementsInNextPage;
949 genericContextGetPageInfo(pageIdx, &nbElementsInNextPage, p_flag);
950 *p_nbElementsInNextPage = nbElementsInNextPage;
955 uint8_t nbElementsInCurrentPage;
957 genericContextGetPageInfo(navInfo.
activePage, &nbElementsInCurrentPage, NULL);
958 nextElementIdx += nbElementsInCurrentPage;
963 if ((nextElementIdx >= genericContext.currentContentElementNb)
964 && (genericContext.currentContentElementNb > 0)) {
974 nextElementIdx -= nbElementsInNextPage;
980 if (nextElementIdx < 0) {
982 nextElementIdx = -nbElementsInNextPage;
988 if ((nextContentIdx == -1) && (genericContext.hasStartingContent)) {
989 p_content = &STARTING_CONTENT;
991 else if ((nextContentIdx == genericContext.genericContents.nbContents)
992 && (genericContext.hasFinishingContent)) {
993 p_content = &FINISHING_CONTENT;
996 p_content = getContentAtIdx(&genericContext.genericContents, nextContentIdx, content);
998 if (p_content == NULL) {
1013 if ((nextContentIdx != genericContext.currentContentIdx)
1014 || (genericContext.currentContentElementNb == 0)) {
1015 genericContext.currentContentIdx = nextContentIdx;
1016 genericContext.currentContentElementNb = getContentNbElement(p_content);
1018 if (nextElementIdx < 0) {
1019 nextElementIdx = genericContext.currentContentElementNb + nextElementIdx;
1024 if ((nextElementIdx < 0) || (nextElementIdx >= genericContext.currentContentElementNb)) {
1026 "Invalid element index %d / %d\n",
1028 genericContext.currentContentElementNb);
1033 genericContext.currentElementIdx = nextElementIdx;
1041static bool genericContextPreparePageContent(
const nbgl_content_t *p_content,
1042 uint8_t nbElementsInPage,
1046 uint8_t nextElementIdx = genericContext.currentElementIdx;
1048 pageContent->
title = pageTitle;
1051 pageContent->
tuneId = TUNE_TAP_CASUAL;
1053 pageContent->
type = p_content->
type;
1054 switch (pageContent->
type) {
1106 p_tagValueList = NULL;
1118 genericContext.detailsItem = pair->
item;
1119 genericContext.detailsvalue = pair->
value;
1124 if (p_tagValueList != NULL) {
1125 p_tagValueList->
nbPairs = nbElementsInPage;
1128 p_tagValueList->
pairs
1131 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1133 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1139 p_tagValueList->
pairs = NULL;
1143 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1147 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1163 if ((nextElementIdx + nbElementsInPage)
1179 p_tagValueList->
nbPairs = nbElementsInPage;
1180 p_tagValueList->
pairs
1183 for (uint8_t i = 0; i < nbElementsInPage; i++) {
1185 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
1190 genericContext.currentPairs = p_tagValueList->
pairs;
1191 genericContext.currentCallback = p_tagValueList->
callback;
1215 < nextElementIdx + nbElementsInPage)) {
1235 bool isFirstOrLastPage
1239 = (navType == STREAMING_NAV)
1240 ? bundleNavContext.reviewStreaming.operationType
1241 : ((navType == GENERIC_NAV) ? bundleNavContext.review.operationType : 0);
1244 if (isFirstOrLastPage
1256 = (operationType &
BLIND_OPERATION) ? BLIND_WARNING_TOKEN : WARNING_BUTTON_TOKEN;
1263static void displayGenericContextPage(uint8_t pageIdx,
bool forceFullRefresh)
1267 uint8_t nbElementsInPage;
1271 if (navType == STREAMING_NAV) {
1273 if (bundleNavContext.reviewStreaming.skipCallback != NULL) {
1274 bundleNavContext.reviewStreaming.skipCallback();
1278 else if (pageIdx >= bundleNavContext.reviewStreaming.stepPageNb) {
1279 bundleNavReviewStreamingChoice(
true);
1286 pageIdx = navInfo.
nbPages - 1;
1292 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1297 for (
int i = navInfo.
activePage + 1; i <= pageIdx; i++) {
1298 p_content = genericContextComputeNextPageParams(i, &content, &nbElementsInPage, &flag);
1308 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1311 if (p_content == NULL) {
1315 if ((navType != STREAMING_NAV)
1318 if ((pageIdx > 0) && (pageIdx < (navInfo.
nbPages - 1))) {
1330 if (!genericContextPreparePageContent(p_content, nbElementsInPage, flag, &pageContent)) {
1336 if (forceFullRefresh) {
1345static const char *getDetailsPageAt(uint8_t detailsPage)
1348 const char *currentChar = detailsContext.value;
1349 while (page < detailsPage) {
1359 detailsContext.wrapping);
1361 if (currentChar[len] ==
'\n') {
1364 else if (detailsContext.wrapping ==
false) {
1367 currentChar = currentChar + len;
1375static void displayDetailsPage(uint8_t detailsPage,
bool forceFullRefresh)
1379 .nbPages = detailsContext.nbPages,
1381 .quitToken = QUIT_TOKEN,
1382 .navWithButtons.navToken = NAV_TOKEN,
1383 .navWithButtons.quitButton =
true,
1384 .navWithButtons.backButton =
true,
1385 .navWithButtons.quitText = NULL,
1386 .progressIndicator =
false,
1387 .tuneId = TUNE_TAP_CASUAL};
1389 .topRightIcon = NULL,
1390 .tagValueList.nbPairs = 1,
1391 .tagValueList.pairs = ¤tPair,
1392 .tagValueList.smallCaseForValue =
true,
1393 .tagValueList.wrapping = detailsContext.wrapping};
1395 if (modalPageContext != NULL) {
1398 currentPair.
item = detailsContext.tag;
1400 if (detailsPage <= detailsContext.currentPage) {
1402 currentPair.
value = getDetailsPageAt(detailsPage);
1403 forceFullRefresh =
true;
1407 currentPair.
value = detailsContext.nextPageStart;
1409 detailsContext.currentPage = detailsPage;
1420 detailsContext.wrapping);
1423 if (currentPair.
value[len] ==
'\n') {
1426 else if (!detailsContext.wrapping) {
1431 detailsContext.nextPageStart = currentPair.
value + len;
1437 detailsContext.nextPageStart = NULL;
1446 if (forceFullRefresh) {
1455static void displayFullValuePage(
const char *backText,
1456 const char *aliasText,
1459 const char *modalTitle
1460 = (extension->
backText != NULL) ? PIC(extension->
backText) : PIC(backText);
1462 genericContext.currentInfos = extension->
infolist;
1463 displayInfosListModal(modalTitle, extension->
infolist,
true);
1466 genericContext.currentTagValues = extension->
tagValuelist;
1471 .withLeftBorder =
true,
1472 .onActionCallback = &modalLayoutTouchCallback,
1473 .tapActionText = NULL};
1475 .separationLine =
false,
1476 .backAndText.token = 0,
1477 .backAndText.tuneId = TUNE_TAP_CASUAL,
1478 .backAndText.text = modalTitle};
1487 .text1 = (extension->
title != NULL) ? extension->
title : extension->fullValue,
1488 .text2 = extension->explanation,
1497 content.
title = aliasText;
1499 content.
info =
"ENS names are resolved by Ledger backend.";
1527static void displayInfosListModal(
const char *modalTitle,
1534 .quitToken = QUIT_TIPBOX_MODAL_TOKEN,
1535 .navWithButtons.navToken = NAV_TOKEN,
1536 .navWithButtons.quitButton =
false,
1537 .navWithButtons.backButton =
true,
1538 .navWithButtons.quitText = NULL,
1539 .progressIndicator =
false,
1540 .tuneId = TUNE_TAP_CASUAL};
1543 .topRightIcon = NULL,
1544 .infosList.nbInfos = infos->
nbInfos,
1546 .infosList.infoTypes = infos->
infoTypes,
1549 .infosList.token = fromReview ? INFO_ALIAS_TOKEN : INFOS_TIP_BOX_TOKEN,
1550 .
title = modalTitle,
1551 .titleToken = QUIT_TIPBOX_MODAL_TOKEN,
1552 .tuneId = TUNE_TAP_CASUAL};
1554 if (modalPageContext != NULL) {
1563static void displayTagValueListModalPage(uint8_t pageIdx,
bool forceFullRefresh)
1566 .nbPages = detailsContext.nbPages,
1568 .quitToken = QUIT_TOKEN,
1569 .navWithButtons.navToken = MODAL_NAV_TOKEN,
1570 .navWithButtons.quitButton =
true,
1571 .navWithButtons.backButton =
true,
1572 .navWithButtons.quitText = NULL,
1573 .progressIndicator =
false,
1574 .tuneId = TUNE_TAP_CASUAL};
1576 .topRightIcon = NULL,
1577 .tagValueList.smallCaseForValue =
true,
1578 .tagValueList.wrapping = detailsContext.wrapping};
1579 uint8_t nbElementsInPage;
1582 if (detailsContext.currentPage <= pageIdx) {
1583 modalContextGetPageInfo(pageIdx, &nbElementsInPage);
1587 modalContextGetPageInfo(pageIdx + 1, &nbElementsInPage);
1588 detailsContext.currentPairIdx -= nbElementsInPage;
1589 modalContextGetPageInfo(pageIdx, &nbElementsInPage);
1590 detailsContext.currentPairIdx -= nbElementsInPage;
1592 detailsContext.currentPage = pageIdx;
1595 = &genericContext.currentTagValues->pairs[detailsContext.currentPairIdx];
1597 detailsContext.currentPairIdx += nbElementsInPage;
1603 if (modalPageContext != NULL) {
1608 if (forceFullRefresh) {
1617static void displayAddressQRCode(
void)
1621 .withLeftBorder =
true,
1622 .onActionCallback = &modalLayoutTouchCallback,
1623 .tapActionText = NULL};
1625 .
type =
HEADER_EMPTY, .separationLine =
false, .emptySpace.height = SMALL_CENTERING_HEADER};
1631 addressConfirmationContext.modalLayout =
nbgl_layoutGet(&layoutDescription);
1636 addressConfirmationContext.tagValuePairs[0].value,
1640 if (nbLines <= QRCODE_NB_MAX_LINES) {
1641 qrCode.
text2 = addressConfirmationContext.tagValuePairs[0].value;
1646 addressConfirmationContext.tagValuePairs[0].value,
1648 QRCODE_NB_MAX_LINES,
1650 QRCODE_REDUCED_ADDR_LEN);
1651 qrCode.
text2 = reducedAddress;
1657 addressConfirmationContext.modalLayout,
"Close", DISMISS_QR_TOKEN, TUNE_TAP_CASUAL);
1665static void modalLayoutTouchCallback(
int token, uint8_t index)
1668 if (token == DISMISS_QR_TOKEN) {
1671 addressConfirmationContext.modalLayout = NULL;
1674 else if (token == DISMISS_WARNING_TOKEN) {
1678 if (reviewWithWarnCtx.securityReportLevel <= 1) {
1679 reviewWithWarnCtx.modalLayout = NULL;
1684 reviewWithWarnCtx.securityReportLevel = 1;
1686 if (reviewWithWarnCtx.warning->predefinedSet) {
1687 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1692 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1693 : reviewWithWarnCtx.warning->reviewDetails;
1694 displayCustomizedSecurityReport(details);
1699 else if (token == DISMISS_DETAILS_TOKEN) {
1703 if (choiceWithDetailsCtx.level <= 1) {
1704 choiceWithDetailsCtx.modalLayout = NULL;
1709 choiceWithDetailsCtx.level = 1;
1710 choiceWithDetailsCtx.modalLayout
1711 = displayModalDetails(choiceWithDetailsCtx.details, DISMISS_DETAILS_TOKEN);
1714 else if ((token >= FIRST_WARN_BAR_TOKEN) && (token <= LAST_WARN_BAR_TOKEN)) {
1715 if (sharedContext.usage == SHARE_CTX_REVIEW_WITH_WARNING) {
1718 reviewWithWarnCtx.securityReportLevel = 2;
1720 if (reviewWithWarnCtx.warning->predefinedSet) {
1721 displaySecurityReport(1 << (token - FIRST_WARN_BAR_TOKEN));
1726 = (reviewWithWarnCtx.isIntro) ? reviewWithWarnCtx.warning->introDetails
1727 : reviewWithWarnCtx.warning->reviewDetails;
1729 displayCustomizedSecurityReport(
1734 else if (sharedContext.usage == SHARE_CTX_CHOICE_WITH_DETAILS) {
1736 = &choiceWithDetailsCtx.details->
barList.
details[token - FIRST_WARN_BAR_TOKEN];
1740 choiceWithDetailsCtx.level = 2;
1741 choiceWithDetailsCtx.modalLayout
1742 = displayModalDetails(details, DISMISS_DETAILS_TOKEN);
1750 genericContext.modalLayout = NULL;
1757static void layoutTouchCallback(
int token, uint8_t index)
1760 if (token == WARNING_CHOICE_TOKEN) {
1762 reviewWithWarnCtx.choiceCallback(
false);
1765 reviewWithWarnCtx.isIntro =
false;
1766 if (reviewWithWarnCtx.isStreaming) {
1767 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
1768 reviewWithWarnCtx.icon,
1769 reviewWithWarnCtx.reviewTitle,
1770 reviewWithWarnCtx.reviewSubTitle,
1771 reviewWithWarnCtx.choiceCallback,
1775 useCaseReview(reviewWithWarnCtx.operationType,
1776 reviewWithWarnCtx.tagValueList,
1777 reviewWithWarnCtx.icon,
1778 reviewWithWarnCtx.reviewTitle,
1779 reviewWithWarnCtx.reviewSubTitle,
1780 reviewWithWarnCtx.finishTitle,
1782 reviewWithWarnCtx.choiceCallback,
1789 else if (token == WARNING_BUTTON_TOKEN) {
1791 reviewWithWarnCtx.securityReportLevel = 1;
1793 if (reviewWithWarnCtx.warning->predefinedSet) {
1794 displaySecurityReport(reviewWithWarnCtx.warning->predefinedSet);
1799 ? reviewWithWarnCtx.warning->introDetails
1800 : reviewWithWarnCtx.warning->reviewDetails;
1801 displayCustomizedSecurityReport(details);
1805 else if (token == CHOICE_DETAILS_TOKEN) {
1806 choiceWithDetailsCtx.level = 1;
1807 choiceWithDetailsCtx.modalLayout
1808 = displayModalDetails(choiceWithDetailsCtx.details, DISMISS_DETAILS_TOKEN);
1811 else if (token == PRELUDE_CHOICE_TOKEN) {
1813 displayCustomizedSecurityReport(reviewWithWarnCtx.warning->prelude->details);
1817 displayInitialWarning();
1820 reviewWithWarnCtx.isIntro =
false;
1821 if (reviewWithWarnCtx.isStreaming) {
1822 useCaseReviewStreamingStart(reviewWithWarnCtx.operationType,
1823 reviewWithWarnCtx.icon,
1824 reviewWithWarnCtx.reviewTitle,
1825 reviewWithWarnCtx.reviewSubTitle,
1826 reviewWithWarnCtx.choiceCallback,
1830 useCaseReview(reviewWithWarnCtx.operationType,
1831 reviewWithWarnCtx.tagValueList,
1832 reviewWithWarnCtx.icon,
1833 reviewWithWarnCtx.reviewTitle,
1834 reviewWithWarnCtx.reviewSubTitle,
1835 reviewWithWarnCtx.finishTitle,
1837 reviewWithWarnCtx.choiceCallback,
1845 else if (token == CHOICE_TOKEN) {
1846 if (onChoice != NULL) {
1847 onChoice((index == 0) ?
true : false);
1853static void displaySkipWarning(
void)
1856 .cancelText =
"Go back to review",
1857 .centeredInfo.text1 =
"Skip review?",
1859 =
"If you're sure you don't need to review all fields, you can skip straight to signing.",
1860 .centeredInfo.text3 = NULL,
1862 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
1863 .centeredInfo.offsetY = 0,
1864 .confirmationText =
"Yes, skip",
1865 .confirmationToken = SKIP_TOKEN,
1866 .
tuneId = TUNE_TAP_CASUAL,
1868 if (modalPageContext != NULL) {
1880static void updateKeyPad(
bool add)
1882 bool enableValidate, enableBackspace, enableDigits;
1883 bool redrawKeypad =
false;
1886 enableDigits = (keypadContext.pinLen < keypadContext.pinMaxDigits);
1887 enableValidate = (keypadContext.pinLen >= keypadContext.pinMinDigits);
1888 enableBackspace = (keypadContext.pinLen > 0);
1890 if ((keypadContext.pinLen == keypadContext.pinMinDigits)
1892 (keypadContext.pinLen == keypadContext.pinMaxDigits)
1894 (keypadContext.pinLen == 1)) {
1895 redrawKeypad =
true;
1899 if ((keypadContext.pinLen == 0) ||
1900 (keypadContext.pinLen == (keypadContext.pinMinDigits - 1))
1902 (keypadContext.pinLen
1903 == (keypadContext.pinMaxDigits - 1))) {
1904 redrawKeypad =
true;
1907 if (keypadContext.hidden ==
true) {
1912 keypadContext.layoutCtx,
false, 0, (
const char *) keypadContext.pinEntry);
1916 keypadContext.layoutCtx, 0, enableValidate, enableBackspace, enableDigits);
1919 if ((!add) && (keypadContext.pinLen == 0)) {
1927static void keypadCallback(
char touchedKey)
1929 switch (touchedKey) {
1931 if (keypadContext.pinLen > 0) {
1932 keypadContext.pinLen--;
1933 keypadContext.pinEntry[keypadContext.pinLen] = 0;
1935 updateKeyPad(
false);
1944 keypadContext.onValidatePin(keypadContext.pinEntry, keypadContext.pinLen);
1948 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
1949 if (keypadContext.pinLen < keypadContext.pinMaxDigits) {
1950 keypadContext.pinEntry[keypadContext.pinLen] = touchedKey;
1951 keypadContext.pinLen++;
1959static void keypadGeneric_cb(
int token, uint8_t index)
1962 if (token != BACK_TOKEN) {
1971static void keyboardCallback(
char touchedKey)
1974 size_t textLen = strlen(keyboardContext.entryBuffer);
1980 keyboardContext.entryBuffer[--textLen] =
'\0';
1983 if (textLen >= keyboardContext.entryMaxLen) {
1988 keyboardContext.entryBuffer[textLen] = touchedKey;
1989 keyboardContext.entryBuffer[++textLen] =
'\0';
1994 keyboardContext.getSuggestionButtons(&keyboardContext.keyboardContent, &mask);
1996 else if (textLen >= keyboardContext.entryMaxLen) {
2002 keyboardContext.keyboardIndex,
2005 keyboardContext.casing);
2009static void keyboardGeneric_cb(
int token, uint8_t index)
2016 case KEYBOARD_CROSS_TOKEN:
2018 keyboardContext.entryBuffer[0] =
'a';
2019 keyboardContext.entryBuffer[1] =
'\0';
2022 case KEYBOARD_BUTTON_TOKEN:
2029 && (token >= keyboardContext.keyboardContent.suggestionButtons.firstButtonToken)) {
2030 onControls(token, index);
2051static uint8_t getNbTagValuesInPage(uint8_t nbPairs,
2055 bool hasConfirmationButton,
2056 bool hasDetailsButton,
2057 bool *requireSpecificDisplay)
2059 uint8_t nbPairsInPage = 0;
2060 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2066 maxUsableHeight -= TOUCHABLE_HEADER_BAR_HEIGHT - SMALL_CENTERING_HEADER;
2069 *requireSpecificDisplay =
false;
2070 while (nbPairsInPage < nbPairs) {
2077 if (nbPairsInPage > 0) {
2078 currentHeight += INTER_TAG_VALUE_MARGIN;
2081 if (tagValueList->
pairs != NULL) {
2082 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
2085 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
2094 if (nbPairsInPage > 0) {
2101 *requireSpecificDisplay =
true;
2113 value_font = SMALL_REGULAR_FONT;
2116 value_font = LARGE_MEDIUM_FONT;
2134 effectiveMaxLines = 0;
2136 if ((effectiveMaxLines > 0) && (nbLines > effectiveMaxLines)) {
2137 nbLines = effectiveMaxLines;
2150 if (nbPairsInPage == 0) {
2154 *requireSpecificDisplay =
true;
2165 if (hasConfirmationButton && (nbPairsInPage == nbPairs)) {
2166 maxUsableHeight -= UP_FOOTER_BUTTON_HEIGHT;
2167 if ((currentHeight > maxUsableHeight) && (nbPairsInPage > 1)) {
2172 else if (hasDetailsButton) {
2173 maxUsableHeight -= (SMALL_BUTTON_RADIUS * 2);
2174 if ((currentHeight > maxUsableHeight) && (nbPairsInPage > 1)) {
2178 return nbPairsInPage;
2190static uint8_t getNbTagValuesInDetailsPage(uint8_t nbPairs,
2194 uint8_t nbPairsInPage = 0;
2195 uint16_t currentHeight = PRE_TAG_VALUE_MARGIN;
2198 while (nbPairsInPage < nbPairs) {
2203 if (nbPairsInPage > 0) {
2204 currentHeight += INTER_TAG_VALUE_MARGIN;
2207 if (tagValueList->
pairs != NULL) {
2208 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
2211 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
2225 if (currentHeight >= maxUsableHeight) {
2230 return nbPairsInPage;
2233static uint8_t getNbPagesForContent(
const nbgl_content_t *content,
2234 uint8_t pageIdxStart,
2238 uint8_t nbElements = 0;
2239 uint8_t nbPages = 0;
2240 uint8_t nbElementsInPage;
2241 uint8_t elemIdx = 0;
2244 nbElements = getContentNbElement(content);
2246 while (nbElements > 0) {
2249 bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
2251 nbElementsInPage = getNbTagValuesInPage(nbElements,
2260 nbElementsInPage = getNbTagValuesInPage(nbElements,
2270 = getNbInfosInPage(nbElements, &content->
content.
infosList, elemIdx, hasNav);
2278 = getNbBarsInPage(nbElements, &content->
content.
barsList, elemIdx, hasNav);
2285 nbElementsInPage =
MIN(nbMaxElementsPerContentType[content->
type], nbElements);
2288 elemIdx += nbElementsInPage;
2289 genericContextSetPageInfo(pageIdxStart + nbPages, nbElementsInPage, flag);
2290 nbElements -= nbElementsInPage;
2298 uint8_t pageIdxStart,
2301 uint8_t nbPages = 0;
2305 for (
int i = 0; i < genericContents->
nbContents; i++) {
2306 p_content = getContentAtIdx(genericContents, i, &content);
2307 if (p_content == NULL) {
2310 nbPages += getNbPagesForContent(p_content,
2311 pageIdxStart + nbPages,
2319static void prepareAddressConfirmationPages(
const char *address,
2325 uint8_t nbAddressChunks;
2335 bool addressTruncated = (nbAddressChunks > ADDR_VERIF_NB_PAIRS);
2336 if (addressTruncated) {
2337 nbAddressChunks = ADDR_VERIF_NB_PAIRS;
2340 const char *chunkStart = address;
2341 for (uint8_t i = 0; i < nbAddressChunks; i++) {
2342 addressConfirmationContext.tagValuePairs[i].item =
"Address";
2343 addressConfirmationContext.tagValuePairs[i].value = chunkStart;
2344 addressConfirmationContext.tagValuePairs[i].forcePageStart = (i > 0);
2345 if (i + 1 < nbAddressChunks) {
2357 addressConfirmationContext.nbPairs = nbAddressChunks;
2367 if ((tagValueList != NULL) && (nbAddressChunks == 1)
2368 && (tagValueList->
nbPairs < ADDR_VERIF_NB_PAIRS)) {
2372 for (uint8_t i = 0; i < tagValueList->
nbPairs; i++) {
2373 memcpy(&addressConfirmationContext.tagValuePairs[1 + i],
2374 &tagValueList->
pairs[i],
2376 addressConfirmationContext.nbPairs++;
2380 tmpList.
nbPairs = addressConfirmationContext.nbPairs;
2381 tmpList.
pairs = addressConfirmationContext.tagValuePairs;
2382 addressConfirmationContext.nbPairs = getNbTagValuesInPage(
2383 addressConfirmationContext.nbPairs, &tmpList, 0,
false,
true,
true, &flag);
2385 if (tmpList.
nbPairs > addressConfirmationContext.nbPairs) {
2386 addressConfirmationContext.nbPairs = 1;
2397 tagValueConfirm->
tuneId = TUNE_TAP_CASUAL;
2409 uint8_t extrasPlaced
2410 = (tagValueList != NULL) ? (addressConfirmationContext.nbPairs - nbAddressChunks) : 0;
2411 bool extrasNeedSecondPage = (tagValueList != NULL) && (tagValueList->
nbPairs > extrasPlaced);
2413 if (extrasNeedSecondPage) {
2423 tagValueConfirm->
tuneId = TUNE_TAP_CASUAL;
2435static void bundleNavStartHome(
void)
2437 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2439 useCaseHomeExt(context->appName,
2442 context->settingContents != NULL ?
true : false,
2443 &context->homeAction,
2444 bundleNavStartSettings,
2445 context->quitCallback);
2448static void bundleNavStartSettingsAtPage(uint8_t initSettingPage)
2450 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2454 context->settingContents,
2456 bundleNavStartHome);
2459static void bundleNavStartSettings(
void)
2461 bundleNavStartSettingsAtPage(0);
2464static void bundleNavReviewConfirmRejection(
void)
2466 bundleNavContext.review.choiceCallback(
false);
2473 const char *confirmText;
2478 title =
"Reject transaction?";
2479 confirmText =
"Go back to transaction";
2482 title =
"Reject message?";
2483 confirmText =
"Go back to message";
2486 title =
"Reject operation?";
2487 confirmText =
"Go back to operation";
2494static void bundleNavReviewChoice(
bool confirm)
2497 bundleNavContext.review.choiceCallback(
true);
2500 bundleNavReviewAskRejectionConfirmation(bundleNavContext.review.operationType,
2501 bundleNavReviewConfirmRejection);
2505static void bundleNavReviewStreamingConfirmRejection(
void)
2507 bundleNavContext.reviewStreaming.choiceCallback(
false);
2510static void bundleNavReviewStreamingChoice(
bool confirm)
2513 bundleNavContext.reviewStreaming.choiceCallback(
true);
2516 bundleNavReviewAskRejectionConfirmation(bundleNavContext.reviewStreaming.operationType,
2517 bundleNavReviewStreamingConfirmRejection);
2527 .withLeftBorder =
true,
2528 .onActionCallback = modalLayoutTouchCallback,
2529 .tapActionText = NULL};
2531 .separationLine =
true,
2532 .backAndText.icon = NULL,
2533 .backAndText.tuneId = TUNE_TAP_CASUAL,
2534 .backAndText.token = token};
2556 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2557 bar.
tuneId = TUNE_TAP_CASUAL;
2582static void displaySecurityReport(uint32_t set)
2585 .withLeftBorder =
true,
2586 .onActionCallback = modalLayoutTouchCallback,
2587 .tapActionText = NULL};
2589 .separationLine =
true,
2590 .backAndText.icon = NULL,
2591 .backAndText.tuneId = TUNE_TAP_CASUAL,
2592 .backAndText.token = DISMISS_WARNING_TOKEN};
2596 const char *provider;
2598 reviewWithWarnCtx.modalLayout =
nbgl_layoutGet(&layoutDescription);
2604 if ((reviewWithWarnCtx.securityReportLevel == 1) && (!reviewWithWarnCtx.isIntro)) {
2608 && (reviewWithWarnCtx.warning->predefinedSet & (1 << i))) {
2611 || (reviewWithWarnCtx.warning->providerMessage == NULL)) {
2612 bar.
subText = securityReportItems[i].subText;
2615 bar.
subText = reviewWithWarnCtx.warning->providerMessage;
2617 bar.
text = securityReportItems[i].text;
2620 bar.
token = FIRST_WARN_BAR_TOKEN + i;
2621 bar.
tuneId = TUNE_TAP_CASUAL;
2626 bar.
iconLeft = securityReportItems[i].icon;
2637 if (reviewWithWarnCtx.warning && reviewWithWarnCtx.warning->reportProvider) {
2638 provider = reviewWithWarnCtx.warning->reportProvider;
2641 provider =
"[unknown]";
2647 + W3C_DESCRIPTION_MAX_LEN / 2;
2651 .text1 = reviewWithWarnCtx.warning->reportUrl,
2652 .text2 =
"Scan to view full report",
2657 W3C_DESCRIPTION_MAX_LEN / 2,
2659 reviewWithWarnCtx.warning->reportUrl);
2660 urlLen = strlen(destStr) + 1;
2665 snprintf(destStr + urlLen, W3C_DESCRIPTION_MAX_LEN / 2 - urlLen,
"%s report", provider);
2671 info.
icon = &LARGE_WARNING_ICON;
2672 info.
title =
"This transaction cannot be Clear Signed";
2674 =
"This transaction or message cannot be decoded fully. If you choose to sign, you "
2675 "could be authorizing malicious actions that can drain your wallet.\n\nLearn more: "
2684 info.
icon = &LARGE_WARNING_ICON;
2685 info.
title =
"Transaction Check unavailable";
2687 =
"If you're not using the Ledger Wallet app, Transaction Check might not work. If "
2689 "are using Ledger Wallet, reject the transaction and try again.\n\nGet help at "
2708 reviewWithWarnCtx.modalLayout = displayModalDetails(details, DISMISS_WARNING_TOKEN);
2712static void displayInitialWarning(
void)
2715#ifdef HAVE_PIEZO_SOUND
2716 tune_index_e tune = TUNE_RESERVED;
2721 .token = WARNING_CHOICE_TOKEN,
2722 .topText =
"Back to safety",
2724 .tuneId = TUNE_TAP_CASUAL};
2726 .emptySpace.height = MEDIUM_CENTERING_HEADER};
2730 bool isBlindSigningOnly
2732 reviewWithWarnCtx.isIntro =
true;
2736 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
2739 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2742 isBlindSigningOnly ? &INFO_I_ICON : &QRCODE_ICON,
2743 WARNING_BUTTON_TOKEN,
2746 else if (reviewWithWarnCtx.warning->introTopRightIcon != NULL) {
2748 reviewWithWarnCtx.warning->introTopRightIcon,
2749 WARNING_BUTTON_TOKEN,
2754 if (reviewWithWarnCtx.warning->predefinedSet != 0) {
2757 const char *provider;
2760 info.
icon = &LARGE_WARNING_ICON;
2763 if (isBlindSigningOnly ==
false) {
2764 if (reviewWithWarnCtx.warning->reportProvider) {
2765 provider = reviewWithWarnCtx.warning->reportProvider;
2768 provider =
"[unknown]";
2771 snprintf(tmpString, W3C_DESCRIPTION_MAX_LEN,
"Detected by %s", provider);
2775 if (isBlindSigningOnly) {
2776 info.
title =
"Blind signing ahead";
2779 =
"If you sign this transaction, you could lose your assets. "
2780 "Explore safer alternatives: ledger.com/integrated-apps";
2781 buttonsInfo.
bottomText =
"Accept risk and continue";
2785 =
"This transaction's details are not fully verifiable. If you sign, you could "
2786 "lose all your assets.";
2789#ifdef HAVE_PIEZO_SOUND
2790 tune = TUNE_NEUTRAL;
2794 info.
title =
"Potential risk";
2795 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2799 info.
description = reviewWithWarnCtx.warning->providerMessage;
2801 buttonsInfo.
bottomText =
"Accept risk and continue";
2802#ifdef HAVE_PIEZO_SOUND
2803 tune = TUNE_NEUTRAL;
2807 info.
title =
"Critical threat";
2808 if (reviewWithWarnCtx.warning->providerMessage == NULL) {
2812 info.
description = reviewWithWarnCtx.warning->providerMessage;
2814 buttonsInfo.
bottomText =
"Accept threat and continue";
2815#ifdef HAVE_PIEZO_SOUND
2821 else if (reviewWithWarnCtx.warning->info != NULL) {
2824#ifdef HAVE_PIEZO_SOUND
2825 tune = TUNE_LOOK_AT_ME;
2831#ifdef HAVE_PIEZO_SOUND
2832 if (tune != TUNE_RESERVED) {
2833 os_io_seph_cmd_piezo_play_tune(tune);
2841static void displayPrelude(
void)
2846 = {.
bottomText = reviewWithWarnCtx.warning->prelude->footerText,
2847 .token = PRELUDE_CHOICE_TOKEN,
2848 .topText = reviewWithWarnCtx.warning->prelude->buttonText,
2850 .tuneId = TUNE_TAP_CASUAL};
2852 .emptySpace.height = MEDIUM_CENTERING_HEADER};
2855 reviewWithWarnCtx.isIntro =
true;
2859 reviewWithWarnCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
2866 info.
icon = reviewWithWarnCtx.warning->prelude->icon;
2868 info.
title = reviewWithWarnCtx.warning->prelude->title;
2869 info.
description = reviewWithWarnCtx.warning->prelude->description;
2875#ifdef HAVE_PIEZO_SOUND
2876 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
2885 const char *predefinedTipBoxText = NULL;
2888 if (reviewWithWarnCtx.warning) {
2889 if (reviewWithWarnCtx.warning->predefinedSet & (1 <<
W3C_ISSUE_WARN)) {
2891 predefinedTipBoxText =
"Transaction Check unavailable.\nBlind signing required.";
2894 predefinedTipBoxText =
"Transaction Check unavailable";
2899 predefinedTipBoxText =
"Critical threat detected.\nBlind signing required.";
2902 predefinedTipBoxText =
"Critical threat detected.";
2907 predefinedTipBoxText =
"Potential risk detected.\nBlind signing required.";
2910 predefinedTipBoxText =
"Potential risk detected.";
2915 predefinedTipBoxText
2916 =
"No threat detected by Transaction Check but blind signing required.";
2919 predefinedTipBoxText =
"No threat detected by Transaction Check.";
2923 predefinedTipBoxText =
"Blind signing required.";
2927 if ((tipBox != NULL) || (predefinedTipBoxText != NULL)) {
2929 STARTING_CONTENT.content.extendedCenter.contentCenter.subText = NULL;
2930 if (predefinedTipBoxText != NULL) {
2931 genericContext.validWarningCtx =
true;
2932 STARTING_CONTENT.content.extendedCenter.tipBox.icon = NULL;
2933 STARTING_CONTENT.content.extendedCenter.tipBox.text = predefinedTipBoxText;
2936 STARTING_CONTENT.content.extendedCenter.tipBox.icon = tipBox->
icon;
2937 STARTING_CONTENT.content.extendedCenter.tipBox.text = tipBox->
text;
2939 STARTING_CONTENT.content.extendedCenter.tipBox.token = TIP_BOX_TOKEN;
2940 STARTING_CONTENT.content.extendedCenter.tipBox.tuneId = TUNE_TAP_CASUAL;
2948 const char *reviewTitle,
2949 const char *reviewSubTitle,
2950 const char *finishTitle,
2954 bool playNotifSound)
2956 bundleNavContext.review.operationType = operationType;
2957 bundleNavContext.review.choiceCallback = choiceCallback;
2960 onChoice = bundleNavReviewChoice;
2961 navType = GENERIC_NAV;
2964 genericContext.genericContents.contentsList = localContentsList;
2965 genericContext.genericContents.nbContents = 3;
2970 prepareReviewFirstPage(
2971 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
2974 initWarningTipBox(tipBox);
2978 memcpy(&localContentsList[1].content.tagValueList,
2986 prepareReviewLightLastPage(
2987 operationType, &localContentsList[2].content.infoButton, icon, finishTitle);
2991 prepareReviewLastPage(
2992 operationType, &localContentsList[2].content.infoLongPress, icon, finishTitle);
2996 uint8_t nbPages = getNbPagesForGenericContents(
2998 prepareNavInfo(
true, nbPages, getRejectReviewText(operationType));
3001 if (playNotifSound) {
3002#ifdef HAVE_PIEZO_SOUND
3003 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3007 displayGenericContextPage(0,
true);
3013 const char *reviewTitle,
3014 const char *reviewSubTitle,
3016 bool playNotifSound)
3018 bundleNavContext.reviewStreaming.operationType = operationType;
3019 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3020 bundleNavContext.reviewStreaming.icon = icon;
3023 onChoice = bundleNavReviewStreamingChoice;
3024 navType = STREAMING_NAV;
3027 genericContext.genericContents.contentsList = localContentsList;
3028 genericContext.genericContents.nbContents = 1;
3033 prepareReviewFirstPage(
3034 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
3037 initWarningTipBox(NULL);
3040 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3047 if (playNotifSound) {
3048#ifdef HAVE_PIEZO_SOUND
3049 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3053 displayGenericContextPage(0,
true);
3072static void useCaseHomeExt(
const char *appName,
3074 const char *tagline,
3081 .centeredInfo.text1 = appName,
3082 .centeredInfo.text3 = NULL,
3084 .centeredInfo.offsetY = 0,
3087 .tapActionText = NULL,
3089 .topRightToken = CONTINUE_TOKEN,
3090 .tuneId = TUNE_TAP_CASUAL};
3091 reset_callbacks_and_context();
3093 if ((homeAction->
text != NULL) || (homeAction->
icon != NULL)) {
3108 if (tagline == NULL) {
3112 "This app enables signing\ntransactions on its network.");
3139 onContinue = topRightCallback;
3140 onQuit = quitCallback;
3154static void displayDetails(
const char *tag,
const char *value,
bool wrapping)
3156 memset(&detailsContext, 0,
sizeof(detailsContext));
3162 detailsContext.tag = tag;
3163 detailsContext.value = value;
3165 detailsContext.currentPage = 0;
3166 detailsContext.wrapping = wrapping;
3168 if (detailsContext.nbPages > 1) {
3169 uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3;
3172 uint8_t nbLinesInLastPage
3178 detailsContext.nbPages++;
3182 displayDetailsPage(0,
true);
3188 uint8_t nbElements = 0;
3189 uint8_t nbElementsInPage;
3190 uint8_t elemIdx = 0;
3193 memset(&detailsContext, 0,
sizeof(detailsContext));
3194 nbElements = tagValues->
nbPairs;
3196 while (nbElements > 0) {
3197 if (detailsContext.nbPages >= MAX_MODAL_PAGE_NB) {
3199 "displayTagValueListModal(): too many pages, truncating at %d\n",
3203 nbElementsInPage = getNbTagValuesInDetailsPage(nbElements, tagValues, elemIdx);
3205 elemIdx += nbElementsInPage;
3206 modalContextSetPageInfo(detailsContext.nbPages, nbElementsInPage);
3207 nbElements -= nbElementsInPage;
3208 detailsContext.nbPages++;
3211 displayTagValueListModalPage(0,
true);
3233 bool *requireSpecificDisplay)
3235 return getNbTagValuesInPage(
3236 nbPairs, tagValueList, startIndex,
false,
false,
false, requireSpecificDisplay);
3248static uint8_t getNbInfosInPage(uint8_t nbInfos,
3253 uint8_t nbInfosInPage = 0;
3254 uint16_t currentHeight = 0;
3255 uint16_t previousHeight = 0;
3256 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3257 const char *
const *infoContents = PIC(infosList->
infoContents);
3259 while (nbInfosInPage < nbInfos) {
3262 += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING + LIST_ITEM_HEADING_SUB_TEXT;
3266 PIC(infoContents[startIndex + nbInfosInPage]),
3273 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3278 previousHeight = currentHeight;
3281 return nbInfosInPage;
3293static uint8_t getNbSwitchesInPage(uint8_t nbSwitches,
3298 uint8_t nbSwitchesInPage = 0;
3299 uint16_t currentHeight = 0;
3300 uint16_t previousHeight = 0;
3301 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3304 while (nbSwitchesInPage < nbSwitches) {
3308 uint16_t textHeight =
MAX(
3309 LIST_ITEM_MIN_TEXT_HEIGHT,
3311 currentHeight += textHeight + 2 * LIST_ITEM_PRE_HEADING;
3314 currentHeight += LIST_ITEM_HEADING_SUB_TEXT;
3324 previousHeight = currentHeight;
3329 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3332 return nbSwitchesInPage;
3344static uint8_t getNbBarsInPage(uint8_t nbBars,
3349 uint8_t nbBarsInPage = 0;
3350 uint16_t currentHeight = 0;
3351 uint16_t previousHeight = 0;
3352 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3357 while (nbBarsInPage < nbBars) {
3358 currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING;
3363 previousHeight = currentHeight;
3368 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3371 return nbBarsInPage;
3388 uint8_t nbChoicesInPage = 0;
3389 uint16_t currentHeight = 0;
3390 uint16_t previousHeight = 0;
3391 uint16_t navHeight = withNav ? SIMPLE_FOOTER_HEIGHT : 0;
3393 UNUSED(choicesList);
3396 while (nbChoicesInPage < nbChoices) {
3397 currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + 2 * LIST_ITEM_PRE_HEADING;
3402 if (!withNav && (previousHeight >= (
INFOS_AREA_HEIGHT - SIMPLE_FOOTER_HEIGHT))) {
3407 previousHeight = currentHeight;
3410 return nbChoicesInPage;
3419 const char *tagline,
3426 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
3449 reset_callbacks_and_context();
3452 onQuit = quitCallback;
3453 onNav = navCallback;
3454 onControls = controlsCallback;
3456 navType = SETTINGS_NAV;
3459 prepareNavInfo(
false, nbPages, NULL);
3461 displaySettingsPage(initPage,
true);
3479 title, initPage, nbPages, quitCallback, navCallback, controlsCallback);
3500 reset_callbacks_and_context();
3503 onQuit = quitCallback;
3504 pageTitle = appName;
3505 navType = GENERIC_NAV;
3507 if (settingContents != NULL) {
3510 if (infosList != NULL) {
3511 genericContext.hasFinishingContent =
true;
3514 memcpy(&FINISHING_CONTENT.content, infosList,
sizeof(
nbgl_content_u));
3518 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3519 if (infosList != NULL) {
3520 nbPages += getNbPagesForContent(&FINISHING_CONTENT, nbPages,
true,
false);
3523 prepareNavInfo(
false, nbPages, NULL);
3525 displayGenericContextPage(initPage,
true);
3564 const char *appName,
3566 const char *tagline,
3574 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
3576 reset_callbacks_and_context();
3578 context->appName = appName;
3579 context->appIcon = appIcon;
3580 context->tagline = tagline;
3581 context->settingContents = settingContents;
3582 context->infosList = infosList;
3583 if (action != NULL) {
3589 context->quitCallback = quitCallback;
3592 bundleNavStartSettingsAtPage(initSettingPage);
3595 bundleNavStartHome();
3609 .tickerIntervale = 0,
3613 reset_callbacks_and_context();
3615 onQuit = quitCallback;
3617#ifdef HAVE_PIEZO_SOUND
3618 os_io_seph_cmd_piezo_play_tune(TUNE_LEDGER_MOMENT);
3621 info.
centeredInfo.
icon = isSuccess ? &CHECK_CIRCLE_ICON : &DENIED_CIRCLE_ICON;
3626 info.
tuneId = TUNE_TAP_CASUAL;
3642 switch (reviewStatusType) {
3644 msg =
"Operation signed";
3648 msg =
"Operation rejected";
3652 msg =
"Transaction signed";
3656 msg =
"Transaction rejected";
3660 msg =
"Message signed";
3664 msg =
"Message rejected";
3668 msg =
"Address verified";
3672 msg =
"Address verification\ncancelled";
3694 const char *message,
3695 const char *subMessage,
3696 const char *confirmText,
3697 const char *cancelText,
3702 if ((confirmText == NULL) || (cancelText == NULL)) {
3706 reset_callbacks_and_context();
3715 info.
tuneId = TUNE_TAP_CASUAL;
3717 onChoice = callback;
3737 const char *message,
3738 const char *subMessage,
3739 const char *confirmText,
3740 const char *cancelText,
3745 (details != NULL) ? &SEARCH_ICON : NULL,
3780 const char *message,
3781 const char *subMessage,
3782 const char *confirmText,
3783 const char *cancelText,
3790 .token = CHOICE_TOKEN,
3791 .topText = confirmText,
3793 .tuneId = TUNE_TAP_CASUAL};
3796 .emptySpace.height = MEDIUM_CENTERING_HEADER};
3799 if ((confirmText == NULL) || (cancelText == NULL)) {
3801 "nbgl_useCaseAdvancedChoiceWithDetails(): confirmText or cancelText is NULL\n");
3805 reset_callbacks_and_context();
3807#ifdef HAVE_PIEZO_SOUND
3808 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3811 onChoice = callback;
3814 sharedContext.usage = SHARE_CTX_CHOICE_WITH_DETAILS;
3815 choiceWithDetailsCtx.layoutCtx =
nbgl_layoutGet(&layoutDescription);
3816 choiceWithDetailsCtx.details = details;
3820 centeredInfo.
icon = centerIcon;
3821 centeredInfo.
title = title;
3823 centeredInfo.
subText = subMessage;
3826 if ((details != NULL) && (headerIcon != NULL)) {
3828 choiceWithDetailsCtx.layoutCtx, headerIcon, CHOICE_DETAILS_TOKEN, TUNE_TAP_CASUAL);
3849 const char *subMessage,
3850 const char *confirmText,
3851 const char *cancelText,
3857 .centeredInfo.text1 = message,
3858 .centeredInfo.text2 = subMessage,
3859 .centeredInfo.text3 = NULL,
3861 .centeredInfo.icon = &IMPORTANT_CIRCLE_ICON,
3862 .centeredInfo.offsetY = 0,
3863 .confirmationText = confirmText,
3864 .confirmationToken = CHOICE_TOKEN,
3865 .tuneId = TUNE_TAP_CASUAL,
3867 onModalConfirm = callback;
3868 if (modalPageContext != NULL) {
3886 const char *message,
3887 const char *actionText,
3892 reset_callbacks_and_context();
3894 onAction = callback;
3896 content.
tuneId = TUNE_TAP_CASUAL;
3919 const char *reviewTitle,
3920 const char *reviewSubTitle,
3921 const char *rejectText,
3926 .footerToken = QUIT_TOKEN,
3927 .tapActionText = NULL,
3928 .isSwipeable =
true,
3929 .tapActionToken = CONTINUE_TOKEN,
3931 .actionButtonText = NULL,
3932 .
tuneId = TUNE_TAP_CASUAL};
3934 reset_callbacks_and_context();
3942 onQuit = rejectCallback;
3943 onContinue = continueCallback;
3945#ifdef HAVE_PIEZO_SOUND
3947 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
3968 const char *rejectText,
3973 reset_callbacks_and_context();
3976 onChoice = callback;
3977 navType = GENERIC_NAV;
3981 genericContext.genericContents.contentsList = localContentsList;
3984 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
3986 memcpy(&localContentsList[offset].content.tagValueList,
3993 memcpy(&localContentsList[offset].content.infoLongPress,
3999 genericContext.genericContents.nbContents = offset;
4002 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4004 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4006 displayGenericContextPage(0,
true);
4024 const char *rejectText,
4029 reset_callbacks_and_context();
4032 onChoice = callback;
4033 navType = GENERIC_NAV;
4036 genericContext.genericContents.contentsList = localContentsList;
4039 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
4041 memcpy(&localContentsList[offset].content.tagValueList,
4055 genericContext.genericContents.nbContents = offset;
4058 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4060 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
4062 displayGenericContextPage(0,
true);
4084 const char *reviewTitle,
4085 const char *reviewSubTitle,
4086 const char *finishTitle,
4089 reset_callbacks_and_context();
4091 useCaseReview(operationType,
4125 const char *reviewTitle,
4126 const char *reviewSubTitle,
4127 const char *finishTitle,
4138 &blindSigningWarning,
4167 const char *reviewTitle,
4168 const char *reviewSubTitle,
4169 const char *finishTitle,
4174 reset_callbacks_and_context();
4177 if (tipBox != NULL) {
4178 memcpy(&activeTipBox, tipBox,
sizeof(activeTipBox));
4181 if ((warning == NULL)
4184 useCaseReview(operationType,
4202 sharedContext.usage = SHARE_CTX_REVIEW_WITH_WARNING;
4203 reviewWithWarnCtx.isStreaming =
false;
4204 reviewWithWarnCtx.operationType = operationType;
4205 reviewWithWarnCtx.tagValueList = tagValueList;
4206 reviewWithWarnCtx.icon = icon;
4207 reviewWithWarnCtx.reviewTitle = reviewTitle;
4208 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
4209 reviewWithWarnCtx.finishTitle = finishTitle;
4210 reviewWithWarnCtx.warning = warning;
4211 reviewWithWarnCtx.choiceCallback = choiceCallback;
4214 if (reviewWithWarnCtx.warning->prelude) {
4219 displayInitialWarning();
4222 useCaseReview(operationType,
4254 const char *reviewTitle,
4255 const char *reviewSubTitle,
4256 const char *finishTitle,
4259 reset_callbacks_and_context();
4261 useCaseReview(operationType,
4282 const char *rejectText,
4285 reset_callbacks_and_context();
4288 onQuit = rejectCallback;
4289 navType = GENERIC_NAV;
4296 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4297 prepareNavInfo(
true, nbPages, rejectText);
4300#ifdef HAVE_PIEZO_SOUND
4302 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4305 displayGenericContextPage(0,
true);
4322 const char *reviewTitle,
4323 const char *reviewSubTitle,
4326 reset_callbacks_and_context();
4328 useCaseReviewStreamingStart(
4329 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4347 const char *reviewTitle,
4348 const char *reviewSubTitle,
4352 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
4372 const char *reviewTitle,
4373 const char *reviewSubTitle,
4377 reset_callbacks_and_context();
4380 if ((warning == NULL)
4383 useCaseReviewStreamingStart(
4384 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4394 sharedContext.usage = SHARE_CTX_REVIEW_WITH_WARNING;
4395 reviewWithWarnCtx.isStreaming =
true;
4396 reviewWithWarnCtx.operationType = operationType;
4397 reviewWithWarnCtx.icon = icon;
4398 reviewWithWarnCtx.reviewTitle = reviewTitle;
4399 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
4400 reviewWithWarnCtx.choiceCallback = choiceCallback;
4401 reviewWithWarnCtx.warning = warning;
4404 if (reviewWithWarnCtx.warning->prelude) {
4409 displayInitialWarning();
4412 useCaseReviewStreamingStart(
4413 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
4436 memset(&genericContext, 0, offsetof(GenericContext_t, sharedCtx));
4438 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
4439 bundleNavContext.reviewStreaming.skipCallback = skipCallback;
4442 onChoice = bundleNavReviewStreamingChoice;
4443 navType = STREAMING_NAV;
4446 genericContext.genericContents.contentsList = localContentsList;
4447 genericContext.genericContents.nbContents = 1;
4456 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
4457 &genericContext.genericContents,
4460 prepareNavInfo(
true,
4462 getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
4470 displayGenericContextPage(0,
true);
4502 memset(&genericContext, 0, offsetof(GenericContext_t, sharedCtx));
4504 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
4507 onChoice = bundleNavReviewStreamingChoice;
4508 navType = STREAMING_NAV;
4511 genericContext.genericContents.contentsList = localContentsList;
4512 genericContext.genericContents.nbContents = 1;
4517 prepareReviewLastPage(bundleNavContext.reviewStreaming.operationType,
4518 &STARTING_CONTENT.content.infoLongPress,
4519 bundleNavContext.reviewStreaming.icon,
4523 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
4524 &genericContext.genericContents,
4527 prepareNavInfo(
true, 1, getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
4529 displayGenericContextPage(0,
true);
4540 reset_callbacks_and_context();
4541 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
4544 onChoice = callback;
4545 navType = GENERIC_NAV;
4548 genericContext.genericContents.contentsList = localContentsList;
4549 genericContext.genericContents.nbContents = (tagValueList == NULL) ? 1 : 2;
4551 prepareAddressConfirmationPages(
4552 address, tagValueList, &STARTING_CONTENT, &localContentsList[1]);
4555 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4557 prepareNavInfo(
true, nbPages,
"Cancel");
4559#ifdef HAVE_PIEZO_SOUND
4561 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4564 displayGenericContextPage(0,
true);
4586 const char *reviewTitle,
4587 const char *reviewSubTitle,
4590 reset_callbacks_and_context();
4593 if (addressConfirmationContext.modalLayout) {
4596 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
4599 onChoice = choiceCallback;
4600 navType = GENERIC_NAV;
4604 genericContext.genericContents.contentsList = localContentsList;
4609 prepareReviewFirstPage(
4610 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
4611 STARTING_CONTENT.content.extendedCenter.contentCenter.subText =
"Swipe to continue";
4614 prepareAddressConfirmationPages(
4615 address, additionalTagValueList, &localContentsList[1], &localContentsList[2]);
4618 genericContext.genericContents.nbContents
4620 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
4622 prepareNavInfo(
true, nbPages,
"Cancel");
4624#ifdef HAVE_PIEZO_SOUND
4626 os_io_seph_cmd_piezo_play_tune(TUNE_LOOK_AT_ME);
4629 displayGenericContextPage(0,
true);
4643 if (genericContext.type != USE_CASE_SPINNER) {
4644 memset(&genericContext, 0,
sizeof(genericContext));
4645 genericContext.type = USE_CASE_SPINNER;
4650 genericContext.backgroundLayout =
nbgl_layoutGet(&layoutDescription);
4653 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4660 genericContext.spinnerPosition++;
4663 genericContext.spinnerPosition = 0;
4666 genericContext.backgroundLayout, text, NULL, genericContext.spinnerPosition);
4670 else if (ret == 2) {
4705 .separationLine =
true,
4706 .backAndText.token = BACK_TOKEN,
4707 .backAndText.tuneId = TUNE_TAP_CASUAL};
4712 "nbgl_useCaseKeypad(): digits out of range (%d/%d > %d)\n",
4719 reset_callbacks_and_context();
4721 memset(&keypadContext, 0,
sizeof(KeypadContext_t));
4724 onQuit = backCallback;
4729 keypadContext.hidden = hidden;
4738 USE_CASE_LOGGER,
"nbgl_useCaseKeypad(): layout setup failed (status=%d)\n", status);
4743 keypadContext.layoutCtx, title, keypadContext.hidden, maxDigits,
"");
4746 USE_CASE_LOGGER,
"nbgl_useCaseKeypad(): layout setup failed (status=%d)\n", status);
4751 keypadContext.onValidatePin = validatePinCallback;
4753 keypadContext.pinMinDigits = minDigits;
4754 keypadContext.pinMaxDigits = maxDigits;
4794 .backAndText.token = BACK_TOKEN,
4795 .backAndText.tuneId = TUNE_TAP_CASUAL};
4798 .mode = params->
mode,
4799 .casing = params->
casing};
4803 reset_callbacks_and_context();
4805 memset(&keyboardContext, 0,
sizeof(KeyboardContext_t));
4808 onQuit = backCallback;
4820 USE_CASE_LOGGER,
"nbgl_useCaseKeyboard(): layout setup failed (status=%d)\n", status);
4823 keyboardContext.keyboardIndex = status;
4824 keyboardContext.casing = params->
casing;
4825 keyboardContext.entryBuffer = PIC(params->
entryBuffer);
4826 keyboardContext.entryMaxLen = params->
entryMaxLen;
4827 keyboardContext.entryBuffer[0] =
'\0';
4830 .type = params->
type,
4831 .title = PIC(params->
title),
4833 .number = params->
number,
4835 .text = keyboardContext.entryBuffer,
4836 .textToken = KEYBOARD_CROSS_TOKEN,
4837 .tuneId = TUNE_TAP_CASUAL,
4839 switch (params->
type) {
4844 .token = KEYBOARD_BUTTON_TOKEN,
4850 keyboardContext.getSuggestionButtons
4861 &keyboardContext.keyboardContent);
4864 USE_CASE_LOGGER,
"nbgl_useCaseKeyboard(): layout setup failed (status=%d)\n", status);
nbgl_contentTagValue_t *(* nbgl_contentTagValueCallback_t)(uint8_t pairIndex)
prototype of tag/value pair retrieval callback
@ ICON_ILLUSTRATION
simple icon
@ LARGE_CASE_INFO
text in BLACK and large case (INTER 32px), subText in black in Inter24px
@ INFO_LONG_PRESS
a centered info and a long press button
@ EXTENDED_CENTER
a centered content and a possible tip-box
@ CHOICES_LIST
list of choices through radio buttons
@ CENTERED_INFO
a centered info
@ SWITCHES_LIST
list of switches with descriptions
@ TAG_VALUE_DETAILS
a tag/value pair and a small button to get details.
@ INFOS_LIST
list of infos with titles
@ TAG_VALUE_CONFIRM
tag/value pairs and a black button/footer to confirm/cancel.
@ TAG_VALUE_LIST
list of tag/value pairs
@ BARS_LIST
list of touchable bars (with > on the right to go to sub-pages)
@ INFO_BUTTON
a centered info and a simple black button
@ INFO_LIST_ALIAS
alias is list of infos
@ ENS_ALIAS
alias comes from ENS
@ ADDRESS_BOOK_ALIAS
alias comes from Address Book
@ QR_CODE_ALIAS
alias is an address to be displayed as a QR Code
void(* nbgl_contentActionCallback_t)(int token, uint8_t index, int page)
prototype of function to be called when an action on a content object occurs
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
uint8_t nbgl_getTextNbPagesInWidth(nbgl_font_id_e fontId, const char *text, uint8_t nbLinesPerPage, uint16_t maxWidth)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
uint8_t nbgl_getFontLineHeight(nbgl_font_id_e fontId)
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
int nbgl_layoutAddContentCenter(nbgl_layout_t *layout, const nbgl_contentCenter_t *info)
Creates an area on the center of the main panel, with a possible icon, and possible texts under it.
int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout, uint8_t index, uint32_t keyMask, bool updateCasing, keyboardCase_t casing)
Updates an existing keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutAddKeyboard(nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInfo)
Creates a keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace, bool enableDigits)
Updates an existing keypad on bottom of the screen, with the given configuration.
int nbgl_layoutAddKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
Adds an area containing a potential title, a text entry and either confirmation or suggestion buttons...
int nbgl_layoutAddSeparationLine(nbgl_layout_t *layout)
adds a separation line on bottom of the last added item
int nbgl_layoutAddQRCode(nbgl_layout_t *layout, const nbgl_layoutQRCode_t *info)
Creates an area on the center of the main panel, with a QRCode, a possible text in black (bold) under...
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
int nbgl_layoutAddTouchableBar(nbgl_layout_t *layout, const nbgl_layoutBar_t *barLayout)
Creates a touchable bar in main panel.
@ WHITE_BACKGROUND
rounded bordered button, with text/icon in black, on white background
@ BLACK_BACKGROUND
rounded bordered button, with text/icon in white, on black background
int nbgl_layoutAddTopRightButton(nbgl_layout_t *layout, const nbgl_icon_details_t *icon, uint8_t token, tune_index_e tuneId)
Creates a Top-right button in the top right corner of the top panel.
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, nbgl_layoutTextContent_t *content)
Creates in the main container three text areas:
void * nbgl_layout_t
type shared externally
@ HEADER_EMPTY
empty space, to have a better vertical centering of centered info
@ HEADER_BACK_AND_TEXT
back key and optional text
int nbgl_layoutUpdateKeyboardContent(nbgl_layout_t *layout, nbgl_layoutKeyboardContent_t *content)
Updates an area containing a potential title, a text entry and either confirmation or suggestion butt...
int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, const char *title, bool hidden, uint8_t nbDigits, const char *text)
Adds an area with a title and a placeholder for hidden digits on top of a keypad, to represent the en...
#define NBGL_INVALID_TOKEN
int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout, bool hidden, uint8_t nbActiveDigits, const char *text)
Updates an existing set of hidden digits, with the given configuration.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddExtendedFooter(nbgl_layout_t *layout, const nbgl_layoutFooter_t *footerDesc)
Creates a touchable area at the footer of the screen, containing various controls,...
@ ROUNDED_AND_FOOTER_STYLE
A black background button on top of a footer.
int nbgl_layoutAddChoiceButtons(nbgl_layout_t *layout, const nbgl_layoutChoiceButtons_t *info)
Creates two buttons to make a choice. Both buttons are mandatory. Both buttons are full width,...
int nbgl_layoutAddSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t initPosition)
Creates a centered (vertically & horizontally) spinner with a text under it.
int nbgl_layoutUpdateSpinner(nbgl_layout_t *layout, const char *text, const char *subText, uint8_t position)
Update an existing spinner (must be the only object of the layout)
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
int nbgl_layoutAddHeader(nbgl_layout_t *layout, const nbgl_layoutHeader_t *headerDesc)
Creates a touchable (or not) area at the header of the screen, containing various controls,...
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
#define TAG_VALUE_INTERVALE
@ FOOTER_EMPTY
empty space, to have a better vertical centering of centered info
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet()
int nbgl_layoutAddFooter(nbgl_layout_t *layout, const char *text, uint8_t token, tune_index_e tuneId)
Creates a touchable text at the footer of the screen, separated with a thin line from the rest of the...
int nbgl_layoutAddKeypad(nbgl_layout_t *layout, keyboardCallback_t callback, bool shuffled)
Adds a keypad on bottom of the screen, with the associated callback.
#define NB_SPINNER_POSITIONS
keyboardCase_t
Letters casing in which to open/set the keyboard.
#define KEYPAD_MAX_DIGITS
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
void nbgl_refreshSpecialWithPostRefresh(nbgl_refresh_mode_t mode, nbgl_post_refresh_t post_refresh)
nbgl_page_t * nbgl_pageDrawGenericContent(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content)
draw a generic content page, with the given content, and if nav parameter is not NULL,...
nbgl_page_t * nbgl_pageDrawInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const nbgl_pageInfoDescription_t *info)
draw a page with a centered info (icon and/or texts) with a touchable footer, in a potential "tapable...
void * nbgl_page_t
type shared externally
@ NAV_WITH_BUTTONS
move forward and backward with buttons in bottom nav bar
nbgl_page_t * nbgl_pageDrawConfirmation(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageConfirmationDescription_t *info)
draw a confirmation page, with a centered info (icon and/or text), a button to confirm and a footer t...
int nbgl_pageRelease(nbgl_page_t *)
Release the page obtained with any of the nbgl_pageDrawXXX() functions.
nbgl_page_t * nbgl_pageDrawGenericContentExt(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_pageNavigationInfo_t *nav, nbgl_pageContent_t *content, bool modal)
draw a generic content page, with the given content, and if nav parameter is not NULL,...
@ QUIT_APP_TEXT
A full width button with "Quit app" text (only for bottom button)
@ INFO_ICON
info (i) icon in the button.
@ NO_BUTTON_STYLE
no button.
@ SETTINGS_ICON
settings (wheel) icon in the button.
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
void nbgl_screenRedraw(void)
@ POST_REFRESH_FORCE_POWER_ON
Force screen power on after refresh.
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
nbgl_refresh_mode_t
different modes of refresh for nbgl_refreshSpecial()
@ BLACK_AND_WHITE_REFRESH
to be used for pure B&W area, when contrast is important
@ FULL_COLOR_CLEAN_REFRESH
to be used for lock screen display (cleaner but longer refresh)
@ BLACK_AND_WHITE_FAST_REFRESH
to be used for pure B&W area, when contrast is not priority
@ FULL_COLOR_PARTIAL_REFRESH
to be used for small partial refresh (radio buttons, switches)
@ FULL_COLOR_REFRESH
to be used for normal refresh
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
DEPRECATED void nbgl_useCaseHome(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, bool withSettings, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback)
#define NB_MAX_LINES_IN_REVIEW
maximum number of lines for value field in review pages
@ NO_TYPE_WARNING
Invalid type (to use for bars leading to nothing)
@ CENTERED_INFO_WARNING
Centered info.
@ BAR_LIST_WARNING
list of touchable bars, to display sub-pages
DEPRECATED void nbgl_useCaseSettings(const char *settingsTitle, uint8_t initPage, uint8_t nbPages, bool touchableTitle, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
void(* nbgl_callback_t)(void)
prototype of generic callback function
#define SKIPPABLE_OPERATION
This is to use in nbgl_operationType_t when the operation is skippable. This is used to add a Skip bu...
void nbgl_useCaseGenericSettings(const char *appName, uint8_t initPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, nbgl_callback_t quitCallback)
uint32_t nbgl_operationType_t
This mask is used to describe the type of operation to review with additional options It is a mask of...
void nbgl_useCaseReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAction(const nbgl_icon_details_t *icon, const char *message, const char *actionText, nbgl_callback_t callback)
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool *requireSpecificDisplay)
void(* nbgl_pinValidCallback_t)(const uint8_t *pin, uint8_t pinLen)
prototype of pin validation callback function
void nbgl_useCaseReviewStreamingStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseHomeAndSettings(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, const uint8_t initSettingPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, const nbgl_homeAction_t *action, nbgl_callback_t quitCallback)
void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
#define RISKY_OPERATION
This is to use in nbgl_operationType_t when the operation is concerned by an internal warning....
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
void nbgl_useCaseNavigableContent(const char *title, uint8_t initPage, uint8_t nbPages, nbgl_callback_t quitCallback, nbgl_navCallback_t navCallback, nbgl_layoutTouchCallback_t controlsCallback)
#define INFOS_AREA_HEIGHT
height available for infos pairs display
@ STRONG_HOME_ACTION
Black button, implicating the main action of the App.
void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
#define NO_THREAT_OPERATION
This is to use in nbgl_operationType_t when the operation is concerned by an internal information....
void nbgl_useCaseChoiceWithDetails(const nbgl_icon_details_t *icon, const char *message, const char *subMessage, const char *confirmText, const char *cancelText, nbgl_warningDetails_t *details, nbgl_choiceCallback_t callback)
void nbgl_useCaseAdvancedChoiceWithDetails(const nbgl_icon_details_t *centerIcon, const nbgl_icon_details_t *headerIcon, const char *title, const char *message, const char *subMessage, const char *confirmText, const char *cancelText, nbgl_warningDetails_t *details, nbgl_choiceCallback_t callback)
void nbgl_useCaseSpinner(const char *text)
void nbgl_useCaseConfirm(const char *message, const char *subMessage, const char *confirmText, const char *rejectText, nbgl_callback_t callback)
#define NB_MAX_LINES_IN_DETAILS
maximum number of lines for value field in details pages
void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *rejectText, nbgl_callback_t continueCallback, nbgl_callback_t rejectCallback)
#define APP_DESCRIPTION_MAX_LEN
Length of buffer used for the default Home tagline.
void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t quitCallback)
@ W3C_THREAT_DETECTED_WARN
Web3 Checks: Threat detected (see reportRisk field)
@ W3C_ISSUE_WARN
Web3 Checks issue (not available)
@ BLIND_SIGNING_WARN
Blind signing.
@ GATED_SIGNING_WARN
Gated signing.
@ W3C_NO_THREAT_WARN
Web3 Checks: No Threat detected.
@ W3C_RISK_DETECTED_WARN
Web3 Checks: Risk detected (see reportRisk field)
DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, nbgl_choiceCallback_t callback, const nbgl_contentTagValueList_t *tagValueList)
void nbgl_useCaseGenericConfiguration(const char *title, uint8_t initPage, const nbgl_genericContents_t *contents, nbgl_callback_t quitCallback)
#define INIT_HOME_PAGE
Value to pass to nbgl_useCaseHomeAndSettings() initSettingPage parameter to initialize the use case o...
void nbgl_useCaseKeypad(const char *title, uint8_t minDigits, uint8_t maxDigits, bool shuffled, bool hidden, nbgl_pinValidCallback_t validatePinCallback, nbgl_callback_t backCallback)
void nbgl_useCaseReviewStreamingContinueExt(const nbgl_contentTagValueList_t *tagValueList, nbgl_choiceCallback_t choiceCallback, nbgl_callback_t skipCallback)
void nbgl_useCaseReviewBlindSigning(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseChoice(const nbgl_icon_details_t *icon, const char *message, const char *subMessage, const char *confirmText, const char *rejectString, nbgl_choiceCallback_t callback)
#define FIRST_USER_TOKEN
when using controls in page content (nbgl_pageContent_t), this is the first token value usable for th...
#define TAG_VALUE_AREA_HEIGHT
height available for tag/value pairs display
#define BLIND_OPERATION
This is to use in nbgl_operationType_t when the operation is "blind" This is used to indicate a warni...
#define TAGLINE_PART1
Default strings used in the Home tagline.
void nbgl_useCaseGenericReview(const nbgl_genericContents_t *contents, const char *rejectText, nbgl_callback_t rejectCallback)
#define STATUS_SCREEN_DURATION
void nbgl_useCaseKeyboard(const nbgl_keyboardParams_t *params, nbgl_callback_t backCallback)
void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, const nbgl_pageInfoLongPress_t *infoLongPress, const char *rejectText, nbgl_choiceCallback_t callback)
void nbgl_useCaseReviewStreamingBlindSigningStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseReviewStreamingContinue(const nbgl_contentTagValueList_t *tagValueList, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseReviewLight(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
uint8_t nbgl_useCaseGetNbChoicesInPage(uint8_t nbChoices, const nbgl_contentRadioChoice_t *choicesList, uint8_t startIndex, bool withNav)
void(* nbgl_keyboardButtonsCallback_t)(nbgl_layoutKeyboardContent_t *content, uint32_t *mask)
prototype of keyboard buttons callback function
#define REAL_TYPE_MASK
Mask to apply on nbgl_operationType_t to extract the base nbgl_opType_t. Bits 0-3 are reserved for th...
void nbgl_useCaseReviewStatus(nbgl_reviewStatusType_t reviewStatusType, nbgl_callback_t quitCallback)
#define LAST_PAGE_FOR_REVIEW
value of page parameter used with navigation callback when "skip" button is touched,...
#define ADDRESS_BOOK_OPERATION
This is to use in nbgl_operationType_t when the operation is related to "Address Book" to adapt wordi...
nbgl_reviewStatusType_t
The different types of review status.
@ STATUS_TYPE_TRANSACTION_REJECTED
@ STATUS_TYPE_ADDRESS_REJECTED
@ STATUS_TYPE_TRANSACTION_SIGNED
@ STATUS_TYPE_OPERATION_REJECTED
@ STATUS_TYPE_OPERATION_SIGNED
@ STATUS_TYPE_ADDRESS_VERIFIED
@ STATUS_TYPE_MESSAGE_SIGNED
@ STATUS_TYPE_MESSAGE_REJECTED
bool(* nbgl_navCallback_t)(uint8_t page, nbgl_pageContent_t *content)
prototype of navigation callback function
#define MAX_APP_NAME_FOR_SDK_TAGLINE
Max supported length of appName used for the default Home tagline.
#define HAS_INITIAL_WARNING(_warning)
void nbgl_useCaseAddressReview(const char *address, const nbgl_contentTagValueList_t *additionalTagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, nbgl_choiceCallback_t choiceCallback)
@ TYPE_TRANSACTION
For operations transferring a coin or taken from an account to another.
@ TYPE_OPERATION
For other types of operation (generic type)
void nbgl_useCaseAdvancedReviewStreamingStart(nbgl_operationType_t operationType, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const nbgl_warning_t *warning, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAdvancedReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, const nbgl_tipBox_t *tipBox, const nbgl_warning_t *warning, nbgl_choiceCallback_t choiceCallback)
This structure contains data to build a BARS_LIST content.
const uint8_t * tokens
array of tokens, one for each bar (nbBars items)
const char *const * barTexts
array of texts for each bar (nbBars items, in black/bold)
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when a bar is touched
uint8_t nbBars
number of elements in barTexts and tokens array
This structure contains info to build a centered (vertically and horizontally) area,...
uint16_t iconHug
vertical margin to apply on top and bottom of the icon
const nbgl_icon_details_t * icon
the icon (can be null)
const char * title
title in black large (can be null)
const char * description
description in black small regular case (can be null)
const char * subText
sub-text in dark gray regular small case
bool padding
if true, apply a padding of 40px at the bottom
const char * smallTitle
sub-title in black small bold case (can be null)
nbgl_contentIllustrationType_t illustrType
const char * text2
second text (can be null)
const char * text1
first text (can be null)
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
int16_t offsetY
vertical shift to apply to this info (if >0, shift to bottom)
const char * text3
third text (can be null)
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
nbgl_contentCenter_t contentCenter
centered content (icon + text(s))
This structure contains data to build a centered info + simple black button content.
const char * buttonText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is touched
This structure contains data to build a INFOS_LIST content.
const char *const * infoContents
array of contents of infos (in black)
const char *const * infoTypes
array of types of infos (in black/bold)
const nbgl_contentValueExt_t * infoExtensions
uint8_t nbInfos
number of elements in infoTypes and infoContents array
This structure contains data to build a centered info + long press button content.
const char * longPressText
text of the long press button
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
const char * text
centered text in large case
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
uint8_t initChoice
index of the current choice
const char *const * names
array of strings giving the choices (nbChoices)
uint8_t nbChoices
number of choices
This structure contains info to build a switch (on the right) with a description (on the left),...
const char * text
main text for the switch
const char * subText
description under main text (NULL terminated, single line, may be null)
This structure contains [item,value] pair(s) and info about a potential "details" button,...
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when details button is touched
const char * confirmationText
text of the confirmation button, if NULL "It matches" is used
uint8_t detailsButtonToken
uint8_t confirmationToken
the token used as argument of the onActionCallback
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
const char * detailsButtonText
this text is used for "details" button (if NULL, no button)
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
const nbgl_icon_details_t * detailsButtonIcon
icon to use in details button
uint8_t detailsButtonToken
const char * detailsButtonText
this text is used for "details" button
nbgl_contentTagValueList_t tagValueList
list of tag/value pairs
This structure contains a list of [tag,value] pairs.
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
nbgl_contentTagValueCallback_t callback
function to call to retrieve a given pair
uint8_t nbMaxLinesForValue
if > 0, set the max number of lines for value field.
bool hideEndOfLastLine
if set to true, replace 3 last chars of last line by "..."
bool wrapping
if set to true, value text will be wrapped on ' ' to avoid cutting words
uint8_t startIndex
index of the first pair to get with callback
nbgl_contentActionCallback_t actionCallback
called when a valueIcon is touched on a given pair
This structure contains a [tag,value] pair and possible extensions.
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
const nbgl_icon_details_t * valueIcon
const char * value
string giving the value name
const char * item
string giving the tag name
uint8_t centeredInfo
if set to 1, the tag will be displayed as a centered info
This structure contains additions to a tag/value pair, to be able to build a screen to display these ...
const char * fullValue
full string of the value when used as an alias
nbgl_contentValueAliasType_t aliasType
type of alias
const struct nbgl_contentTagValueList_s * tagValuelist
if aliasType is TAG_VALUE_LIST_ALIAS
const char * backText
used as title of the popping page, if not NULL, otherwise "item" is used
const char * aliasSubName
string displayed under alias and in details view
const struct nbgl_contentInfoList_s * infolist
if aliasType is INFO_LIST_ALIAS
This structure contains data to build a content.
nbgl_contentActionCallback_t contentActionCallback
callback to be called when an action on an object occurs
nbgl_contentType_t type
type of page content in the content union
const struct nbgl_genericDetails_s * details
array of nbBars structures giving what to display when each bar is touched.
uint8_t nbBars
number of touchable bars
const nbgl_icon_details_t ** icons
array of icons for each bar (nbBars items)
const char *const * subTexts
array of texts for each bar (nbBars items, in black)
const char *const * texts
array of texts for each bar (nbBars items, in black/bold)
uint8_t nbContents
number of contents
const nbgl_content_t * contentsList
array of nbgl_content_t (nbContents items).
nbgl_contentCallback_t contentGetterCallback
function to call to retrieve a given content
The necessary parameters to build the page(s) displayed when the top-right button is touched in intro...
const char * title
text of the page (used to go back)
nbgl_genericBarList_t barList
touchable bars list, if type == BAR_LIST_WARNING
nbgl_layoutQRCode_t qrCode
QR code, if type == QRCODE_WARNING.
nbgl_genericDetailsType_t type
type of content in the page, determining what to use in the following union
nbgl_contentCenter_t centeredInfo
centered info, if type == CENTERED_INFO_WARNING
Structure describing the action button in Home Screen.
const nbgl_icon_details_t * icon
icon to use in action button in Home page
nbgl_callback_t callback
function to call when action button is touched in Home page
const char * text
text to use in action button in Home page
nbgl_homeActionStyle_t style
style of action button
nbgl_keyboardButtonsCallback_t updateButtonsCallback
callback to call when a key is pressed to update suggestions
nbgl_layoutTouchCallback_t onButtonCallback
callback to call when one of the buttons is pressed
const char ** buttons
array of strings for buttons (last ones can be NULL)
int firstButtonToken
first token used for buttons, provided in onButtonCallback
Structure containing all parameters for keyboard use case.
keyboardMode_t mode
keyboard mode to start with
nbgl_kbdSuggestParams_t suggestionParams
nbgl_kbdButtonParams_t confirmationParams
used if type is KEYBOARD_WITH_SUGGESTIONS
bool lettersOnly
if true, only display letter keys and Backspace
uint8_t entryMaxLen
maximum length of text that can be entered
nbgl_layoutKeyboardContentType_t type
type of content
bool numbered
if set to true, the text is preceded on the left by 'number.'
keyboardCase_t casing
keyboard casing mode (lower, upper once or upper locked)
const char * title
centered title explaining the screen
bool obfuscated
if true, entered text and suggestions use the obfuscated font
char * entryBuffer
already entered text
uint8_t number
if numbered is true, number used to build 'number.' text
This structure contains info to build a clickable "bar" with a text and an icon.
const char * text
text (can be NULL)
uint8_t token
the token that will be used as argument of the callback
const char * subText
sub text (can be NULL)
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played
const nbgl_icon_details_t * iconLeft
a buffer containing the 1BPP icon for icon on left (can be NULL)
const nbgl_icon_details_t * iconRight
Structure containing all information when creating a layout. This structure must be passed as argumen...
nbgl_layoutTouchCallback_t onActionCallback
the callback to be called on any action on the layout
This structure contains info to build a keyboard with nbgl_layoutAddKeyboard()
keyboardCallback_t callback
function called when an active key is pressed
This structure contains info to build a keyboard content (controls that are linked to keyboard)
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * url
URL for QR code.
This structure contains info for Text content, to be set with nbgl_layoutAddTextContent().
const char * descriptions[NB_MAX_DESCRIPTIONS]
uint8_t nbDescriptions
number of used descriptions in above array
const char * info
description at bottom (in small gray)
const char * title
main text (in large bold font)
Structure containing all specific information when creating a confirmation page.
const char * cancelText
the text used for cancel action, if NULL a simple X button is used
uint8_t confirmationToken
the token used as argument of the onActionCallback
const char * confirmationText
text of the confirmation button
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button is pressed
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent)
nbgl_contentTagValueDetails_t tagValueDetails
TAG_VALUE_DETAILS type
const char * title
text for the title of the page (if NULL, no title)
uint8_t topRightToken
token used when top-right button (if not NULL) is touched
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when title is touched
nbgl_contentBarsList_t barsList
BARS_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentInfoList_t infosList
INFOS_LIST type
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
const nbgl_icon_details_t * topRightIcon
nbgl_contentType_t type
type of page content in the following union
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
bool isTouchableTitle
if set to true, the title is preceded by <- arrow to go back
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
Structure containing all specific information when creating an information page.
nbgl_layoutButtonStyle_t actionButtonStyle
style of "action" button
const char * actionButtonText
if not NULL an "action" button is set under the centered info
const char * tapActionText
uint8_t bottomButtonsToken
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when button/footer is pressed
const nbgl_icon_details_t * actionButtonIcon
potential icon of "action" button
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
Structure containing all specific information when creating a multi-screens page.
uint8_t nbPages
the number of pages to display (if <2, no navigation bar)
uint8_t quitToken
the token used as argument of the actionCallback when the footer is touched
uint8_t skipToken
if skipText is NULL the token used when right part of footer is touched
nbgl_pageNavigationType_t navType
uint8_t activePage
the index of the page to display at start-up
bool progressIndicator
if set to true, display a progress indicator on top of the page
nbgl_pageNavWithButtons_t navWithButtons
structure used when navigation with buttons
tune_index_e tuneId
if not NBGL_NO_TUNE, a tune will be played when next or back is pressed
bool visiblePageIndicator
if set to true, the page indicator will be visible in navigation
const char * quitText
the text displayed in footer (on the left), used to quit (only on Flex)
bool backButton
if set to true, a back button (<-) is displayed in the nav bar
This structure contains data to build a SWITCHES_LIST content.
uint8_t nbSwitches
number of elements in switches and tokens array
const nbgl_contentSwitch_t * switches
array of switches (nbSwitches items)
The necessary parameters to build a tip-box in first review page and the modal if this tip box is tou...
const char * text
text of the tip-box
const nbgl_icon_details_t * icon
icon of the tip-box
The necessary parameters to build a warning page preceding a review. One can either use predefinedSet...
const nbgl_preludeDetails_t * prelude
if not null, means that the review can start by a prelude
const nbgl_warningDetails_t * introDetails
const nbgl_warningDetails_t * reviewDetails
Union of the different type of contents.
nbgl_contentInfoList_t infosList
INFOS_LIST type
nbgl_contentInfoLongPress_t infoLongPress
INFO_LONG_PRESS type
nbgl_contentTagValueConfirm_t tagValueConfirm
TAG_VALUE_CONFIRM type
nbgl_contentTagValueList_t tagValueList
TAG_VALUE_LIST type
nbgl_contentCenteredInfo_t centeredInfo
CENTERED_INFO type
nbgl_contentBarsList_t barsList
BARS_LIST type
nbgl_contentExtendedCenter_t extendedCenter
EXTENDED_CENTER type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type