18 #include "os_helpers.h"
25 #define PAGE_NB_ELEMENTS_BITS 3
26 #define GET_PAGE_NB_ELEMENTS(pageData) ((pageData) &0x07)
27 #define SET_PAGE_NB_ELEMENTS(nbElements) ((nbElements) &0x07)
29 #define PAGE_FLAG_BITS 1
30 #define GET_PAGE_FLAG(pageData) (((pageData) &0x08) >> 3)
31 #define SET_PAGE_FLAG(flag) (((flag) &0x01) << 3)
33 #define PAGE_DATA_BITS (PAGE_NB_ELEMENTS_BITS + PAGE_FLAG_BITS)
34 #define PAGES_PER_UINT8 (8 / PAGE_DATA_BITS)
35 #define SET_PAGE_DATA(pageIdx, pageData) \
36 (pagesData[pageIdx / PAGES_PER_UINT8] = pageData \
37 << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS))
39 #define MAX_PAGE_NB 256
42 #define STARTING_CONTENT localContentsList[0]
43 #define FINISHING_CONTENT localContentsList[1]
46 #define QRCODE_NB_MAX_LINES 3
48 #define QRCODE_REDUCED_ADDR_LEN 128
51 #define keypadContext sharedContext.keypad
52 #define blindSigningContext sharedContext.blindSigning
64 ADDRESS_QRCODE_BUTTON_TOKEN,
83 typedef struct DetailsContext_s {
89 const char *nextPageStart;
92 typedef struct AddressConfirmationContext_s {
95 } AddressConfirmationContext_t;
98 typedef struct KeypadContext_s {
108 typedef struct BlindSigningContext_s {
113 const char *reviewTitle;
114 const char *reviewSubTitle;
115 const char *finishTitle;
119 } BlindSigningContext_t;
125 KeypadContext_t keypad;
127 BlindSigningContext_t blindSigning;
133 uint8_t currentContentElementNb;
135 bool hasStartingContent;
136 bool hasFinishingContent;
137 const char *detailsItem;
138 const char *detailsvalue;
139 bool detailsWrapping;
156 } nbgl_homeAndSettingsContext_t;
161 } nbgl_reviewContext_t;
169 } nbgl_reviewStreamingContext_t;
172 nbgl_homeAndSettingsContext_t homeAndSettings;
173 nbgl_reviewContext_t review;
174 nbgl_reviewStreamingContext_t reviewStreaming;
175 } nbgl_BundleNavContext_t;
202 static const char *pageTitle;
205 static const char *tipBoxModalTitle;
210 static bool forwardNavOnly;
211 static NavType_t navType;
213 static DetailsContext_t detailsContext;
216 static SharedContext_t sharedContext;
219 static AddressConfirmationContext_t addressConfirmationContext;
222 static GenericContext_t genericContext;
224 localContentsList[3];
225 static uint8_t genericContextPagesInfo[MAX_PAGE_NB / PAGES_PER_UINT8];
228 static nbgl_BundleNavContext_t bundleNavContext;
231 static const uint8_t nbMaxElementsPerContentType[] = {
247 static char reducedAddress[QRCODE_REDUCED_ADDR_LEN];
253 static void displayReviewPage(
uint8_t page,
bool forceFullRefresh);
254 static void displayDetailsPage(
uint8_t page,
bool forceFullRefresh);
255 static void displayFullValuePage(
const char *backText,
256 const char *aliasText,
258 static void displayBlindWarning(
void);
259 static void displayTipBoxModal(
void);
260 static void displaySettingsPage(
uint8_t page,
bool forceFullRefresh);
261 static void displayGenericContextPage(
uint8_t pageIdx,
bool forceFullRefresh);
262 static void pageCallback(
int token,
uint8_t index);
264 static void displayAddressQRCode(
void);
265 static void addressLayoutTouchCallbackQR(
int token,
uint8_t index);
267 static void modalLayoutTouchCallback(
int token,
uint8_t index);
268 static void displaySkipWarning(
void);
270 static void bundleNavStartHome(
void);
271 static void bundleNavStartSettingsAtPage(
uint8_t initSettingPage);
272 static void bundleNavStartSettings(
void);
274 static void bundleNavReviewStreamingChoice(
bool confirm);
275 static void blindSigningWarning(
void);
279 const char *reviewTitle,
280 const char *reviewSubTitle,
281 const char *finishTitle,
285 bool playNotifSound);
288 const char *reviewTitle,
289 const char *reviewSubTitle,
291 bool playNotifSound);
292 static void useCaseHomeExt(
const char *appName,
299 static void displayDetails(
const char *tag,
const char *value,
bool wrapping);
301 static void reset_callbacks(
void)
308 onContentAction = NULL;
310 onModalConfirm = NULL;
312 onValidatePin = NULL;
317 static void genericContextSetPageInfo(
uint8_t pageIdx,
uint8_t nbElements,
bool flag)
319 uint8_t pageData = SET_PAGE_NB_ELEMENTS(nbElements) + SET_PAGE_FLAG(flag);
321 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
322 &= ~(0x0F << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS));
323 genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
324 |= pageData << ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
328 static void genericContextGetPageInfo(
uint8_t pageIdx,
uint8_t *nbElements,
bool *flag)
330 uint8_t pageData = genericContextPagesInfo[pageIdx / PAGES_PER_UINT8]
331 >> ((pageIdx % PAGES_PER_UINT8) * PAGE_DATA_BITS);
332 if (nbElements != NULL) {
333 *nbElements = GET_PAGE_NB_ELEMENTS(pageData);
336 *flag = GET_PAGE_FLAG(pageData);
343 switch (content->
type) {
365 if (contentIdx < 0 || contentIdx >= genericContents->
nbContents) {
382 static void prepareNavInfo(
bool isReview,
uint8_t nbPages,
const char *rejectText)
384 memset(&navInfo, 0,
sizeof(navInfo));
387 navInfo.
tuneId = TUNE_TAP_CASUAL;
391 if (isReview ==
false) {
400 = ((navType == STREAMING_NAV) && (nbPages < 2)) ?
false :
true;
407 const char *reviewTitle,
408 const char *reviewSubTitle)
410 contentCenter->
icon = icon;
411 contentCenter->
title = reviewTitle;
413 contentCenter->
subText =
"Swipe to review";
416 contentCenter->
padding =
false;
421 const char *finishTitle)
423 infoLongPress->
text = finishTitle;
424 infoLongPress->
icon = icon;
431 const char *finishTitle)
433 infoButton->
text = finishTitle;
434 infoButton->
icon = icon;
441 UNUSED(operationType);
447 static void pageModalCallback(
int token,
uint8_t index)
451 if (token == INFO_ALIAS_TOKEN) {
453 displayFullValuePage(tipBoxInfoList.
infoTypes[index],
459 modalPageContext = NULL;
460 if (token == NAV_TOKEN) {
467 displayDetailsPage(index,
false);
470 if (token == QUIT_TOKEN) {
475 else if (token == SKIP_TOKEN) {
486 else if (token == CHOICE_TOKEN) {
488 if (onModalConfirm != NULL) {
501 static void pageCallback(
int token,
uint8_t index)
504 if (token == QUIT_TOKEN) {
505 if (onQuit != NULL) {
509 else if (token == CONTINUE_TOKEN) {
510 if (onContinue != NULL) {
514 else if (token == CHOICE_TOKEN) {
515 if (onChoice != NULL) {
516 onChoice((index == 0) ?
true :
false);
519 else if (token == ACTION_BUTTON_TOKEN) {
520 if ((index == 0) && (onAction != NULL)) {
523 else if ((index == 1) && (onQuit != NULL)) {
528 else if (token == ADDRESS_QRCODE_BUTTON_TOKEN) {
529 displayAddressQRCode();
532 else if (token == CONFIRM_TOKEN) {
533 if (onChoice != NULL) {
537 else if (token == REJECT_TOKEN) {
538 if (onChoice != NULL) {
542 else if (token == DETAILS_BUTTON_TOKEN) {
543 displayDetails(genericContext.detailsItem,
544 genericContext.detailsvalue,
545 genericContext.detailsWrapping);
547 else if (token == NAV_TOKEN) {
549 if (onQuit != NULL) {
554 if (navType == GENERIC_NAV || navType == STREAMING_NAV) {
555 displayGenericContextPage(index,
false);
557 else if (navType == REVIEW_NAV) {
558 displayReviewPage(index,
false);
561 displaySettingsPage(index,
false);
565 else if (token == NEXT_TOKEN) {
567 displayReviewPage(navInfo.
activePage + 1,
false);
570 displayGenericContextPage(navInfo.
activePage + 1,
false);
573 else if (token == BACK_TOKEN) {
575 displayReviewPage(navInfo.
activePage - 1,
true);
578 displayGenericContextPage(navInfo.
activePage - 1,
false);
581 else if (token == SKIP_TOKEN) {
583 displaySkipWarning();
585 else if (token == VALUE_ALIAS_TOKEN) {
588 if (genericContext.currentPairs != NULL) {
589 pair = &genericContext.currentPairs[genericContext.currentElementIdx + index];
592 pair = genericContext.currentCallback(genericContext.currentElementIdx + index);
596 else if (token == BLIND_WARNING_TOKEN) {
597 displayBlindWarning();
599 else if (token == TIP_BOX_TOKEN) {
600 displayTipBoxModal();
603 if (onContentAction != NULL) {
604 onContentAction(token, index, navInfo.
activePage);
606 if (onControls != NULL) {
607 onControls(token, index);
613 static void tickerCallback(
void)
616 if (onQuit != NULL) {
622 static void displaySettingsPage(
uint8_t page,
bool forceFullRefresh)
626 if ((onNav == NULL) || (onNav(page, &content) ==
false)) {
631 content.title = pageTitle;
632 content.isTouchableTitle =
true;
633 content.titleToken = QUIT_TOKEN;
634 content.tuneId = TUNE_TAP_CASUAL;
639 if (forceFullRefresh) {
648 static void displayReviewPage(
uint8_t page,
bool forceFullRefresh)
657 if ((onNav == NULL) || (onNav(navInfo.
activePage, &content) ==
false)) {
662 content.title = NULL;
663 content.isTouchableTitle =
false;
664 content.tuneId = TUNE_TAP_CASUAL;
670 content.infoLongPress.longPressToken = CONFIRM_TOKEN;
671 if (forwardNavOnly) {
679 content.tagValueDetails.tagValueList.smallCaseForValue =
false;
685 content.tagValueList.smallCaseForValue =
false;
688 content.tagValueConfirm.tagValueList.smallCaseForValue =
false;
690 content.tagValueConfirm.confirmationToken = CONFIRM_TOKEN;
695 if (forceFullRefresh) {
707 uint8_t *p_nbElementsInNextPage,
710 int8_t nextContentIdx = genericContext.currentContentIdx;
711 int16_t nextElementIdx = genericContext.currentElementIdx;
715 genericContextGetPageInfo(pageIdx, &nbElementsInNextPage, p_flag);
716 *p_nbElementsInNextPage = nbElementsInNextPage;
721 uint8_t nbElementsInCurrentPage;
723 genericContextGetPageInfo(navInfo.
activePage, &nbElementsInCurrentPage, NULL);
724 nextElementIdx += nbElementsInCurrentPage;
729 if ((nextElementIdx >= genericContext.currentContentElementNb)
730 && (genericContext.currentContentElementNb > 0)) {
740 nextElementIdx -= nbElementsInNextPage;
746 if (nextElementIdx < 0) {
748 nextElementIdx = -nbElementsInNextPage;
754 if ((nextContentIdx == -1) && (genericContext.hasStartingContent)) {
755 p_content = &STARTING_CONTENT;
757 else if ((nextContentIdx == genericContext.genericContents.nbContents)
758 && (genericContext.hasFinishingContent)) {
759 p_content = &FINISHING_CONTENT;
762 p_content = getContentAtIdx(&genericContext.genericContents, nextContentIdx, content);
764 if (p_content == NULL) {
779 if ((nextContentIdx != genericContext.currentContentIdx)
780 || (genericContext.currentContentElementNb == 0)) {
781 genericContext.currentContentIdx = nextContentIdx;
782 genericContext.currentContentElementNb = getContentNbElement(p_content);
784 if (nextElementIdx < 0) {
785 nextElementIdx = genericContext.currentContentElementNb + nextElementIdx;
790 if ((nextElementIdx < 0) || (nextElementIdx >= genericContext.currentContentElementNb)) {
792 "Invalid element index %d / %d\n",
794 genericContext.currentContentElementNb);
799 genericContext.currentElementIdx = nextElementIdx;
807 static bool genericContextPreparePageContent(
const nbgl_content_t *p_content,
812 uint8_t nextElementIdx = genericContext.currentElementIdx;
814 pageContent->title = pageTitle;
815 pageContent->isTouchableTitle =
false;
816 pageContent->titleToken = QUIT_TOKEN;
817 pageContent->tuneId = TUNE_TAP_CASUAL;
819 pageContent->type = p_content->
type;
820 switch (pageContent->type) {
822 memcpy(&pageContent->centeredInfo,
824 sizeof(pageContent->centeredInfo));
827 memcpy(&pageContent->extendedCenter,
829 sizeof(pageContent->extendedCenter));
832 memcpy(&pageContent->infoLongPress,
834 sizeof(pageContent->infoLongPress));
838 memcpy(&pageContent->infoButton,
840 sizeof(pageContent->infoButton));
866 prepareReviewFirstPage(&pageContent->extendedCenter.contentCenter,
872 p_tagValueList = NULL;
877 pageContent->tagValueDetails.detailsButtonText =
"More";
878 pageContent->tagValueDetails.detailsButtonIcon = NULL;
879 pageContent->tagValueDetails.detailsButtonToken = DETAILS_BUTTON_TOKEN;
881 p_tagValueList = &pageContent->tagValueDetails.tagValueList;
884 genericContext.detailsItem = pair->
item;
885 genericContext.detailsvalue = pair->
value;
890 if (p_tagValueList != NULL) {
891 p_tagValueList->
nbPairs = nbElementsInPage;
894 p_tagValueList->
pairs
897 for (
uint8_t i = 0; i < nbElementsInPage; i++) {
899 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
905 p_tagValueList->
pairs = NULL;
909 for (
uint8_t i = 0; i < nbElementsInPage; i++) {
913 p_tagValueList->
token = VALUE_ALIAS_TOKEN;
926 memcpy(&pageContent->tagValueConfirm,
928 sizeof(pageContent->tagValueConfirm));
931 pageContent->switchesList.nbSwitches = nbElementsInPage;
932 pageContent->switchesList.switches
936 pageContent->infosList.nbInfos = nbElementsInPage;
937 pageContent->infosList.infoTypes
939 pageContent->infosList.infoContents
943 memcpy(&pageContent->choicesList,
945 sizeof(pageContent->choicesList));
946 pageContent->choicesList.nbChoices = nbElementsInPage;
947 pageContent->choicesList.names
951 < nextElementIdx + nbElementsInPage)) {
952 pageContent->choicesList.initChoice
956 pageContent->choicesList.initChoice = nbElementsInPage;
960 pageContent->barsList.nbBars = nbElementsInPage;
961 pageContent->barsList.barTexts
971 bool isFirstOrLastPage
974 bool isStreamingNavAndBlindOperation
975 = (navType == STREAMING_NAV)
977 bool isGenericNavAndBlindOperation
978 = (navType == GENERIC_NAV) && (bundleNavContext.review.operationType &
BLIND_OPERATION);
981 if (isFirstOrLastPage && (isStreamingNavAndBlindOperation || isGenericNavAndBlindOperation)) {
983 pageContent->topRightToken = BLIND_WARNING_TOKEN;
990 static void displayGenericContextPage(
uint8_t pageIdx,
bool forceFullRefresh)
998 if (navType == STREAMING_NAV) {
1000 if (bundleNavContext.reviewStreaming.skipCallback != NULL) {
1001 bundleNavContext.reviewStreaming.skipCallback();
1005 else if (pageIdx >= bundleNavContext.reviewStreaming.stepPageNb) {
1006 bundleNavReviewStreamingChoice(
true);
1013 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1018 for (
int i = navInfo.
activePage + 1; i <= pageIdx; i++) {
1019 p_content = genericContextComputeNextPageParams(i, &content, &nbElementsInPage, &flag);
1029 = genericContextComputeNextPageParams(pageIdx, &content, &nbElementsInPage, &flag);
1032 if (p_content == NULL) {
1038 if (!genericContextPreparePageContent(p_content, nbElementsInPage, flag, &pageContent)) {
1044 if (forceFullRefresh) {
1053 static const char *getDetailsPageAt(
uint8_t detailsPage)
1056 const char *currentChar = detailsContext.value;
1057 while (page < detailsPage) {
1067 detailsContext.wrapping);
1069 currentChar = currentChar + len;
1077 static void displayDetailsPage(
uint8_t detailsPage,
bool forceFullRefresh)
1081 .nbPages = detailsContext.nbPages,
1083 .quitToken = QUIT_TOKEN,
1084 .navWithButtons.navToken = NAV_TOKEN,
1085 .navWithButtons.quitButton =
true,
1086 .navWithButtons.backButton =
true,
1087 .navWithButtons.quitText = NULL,
1088 .progressIndicator =
false,
1089 .tuneId = TUNE_TAP_CASUAL};
1091 .topRightIcon = NULL,
1092 .tagValueList.nbPairs = 1,
1093 .tagValueList.pairs = ¤tPair,
1094 .tagValueList.smallCaseForValue =
true,
1095 .tagValueList.wrapping = detailsContext.wrapping};
1097 if (modalPageContext != NULL) {
1100 currentPair.
item = detailsContext.tag;
1102 if (detailsPage <= detailsContext.currentPage) {
1104 currentPair.
value = getDetailsPageAt(detailsPage);
1105 forceFullRefresh =
true;
1109 currentPair.
value = detailsContext.nextPageStart;
1111 detailsContext.currentPage = detailsPage;
1122 detailsContext.wrapping);
1125 detailsContext.nextPageStart = currentPair.
value + len;
1131 detailsContext.nextPageStart = NULL;
1132 content.tagValueList.nbMaxLinesForValue = 0;
1140 if (forceFullRefresh) {
1149 static void displayFullValuePage(
const char *backText,
1150 const char *aliasText,
1154 .withLeftBorder =
true,
1155 .onActionCallback = &modalLayoutTouchCallback,
1156 .tapActionText = NULL};
1158 .separationLine =
false,
1159 .backAndText.token = 0,
1160 .backAndText.tuneId = TUNE_TAP_CASUAL,
1161 .backAndText.text = PIC(backText)};
1182 info =
"ENS names are resolved by Ledger backend.";
1185 info =
"This account label comes from your Address Book in Ledger Live.";
1191 genericContext.modalLayout, aliasText, extension->
fullValue, info);
1199 static void displayBlindWarning(
void)
1202 .withLeftBorder =
true,
1203 .onActionCallback = &modalLayoutTouchCallback,
1204 .tapActionText = NULL};
1206 .separationLine =
false,
1207 .backAndText.token = 0,
1208 .backAndText.tuneId = TUNE_TAP_CASUAL,
1209 .backAndText.text = NULL};
1212 centeredInfo.
text1 =
"Security risk detected";
1214 =
"This transaction or message cannot be decoded fully. If you choose to sign, you could "
1215 "be authorizing malicious actions that can drain your wallet.\n\n"
1216 "Learn more: ledger.com/e8";
1230 static void displayTipBoxModal(
void)
1235 .quitToken = QUIT_TOKEN,
1236 .navWithButtons.navToken = NAV_TOKEN,
1237 .navWithButtons.quitButton =
false,
1238 .navWithButtons.backButton =
true,
1239 .navWithButtons.quitText = NULL,
1240 .progressIndicator =
false,
1241 .tuneId = TUNE_TAP_CASUAL};
1243 .topRightIcon = NULL,
1244 .infosList.nbInfos = tipBoxInfoList.
nbInfos,
1246 .infosList.infoTypes = tipBoxInfoList.
infoTypes,
1249 .infosList.token = INFO_ALIAS_TOKEN,
1250 .
title = tipBoxModalTitle,
1251 .titleToken = QUIT_TOKEN,
1252 .tuneId = TUNE_TAP_CASUAL};
1254 if (modalPageContext != NULL) {
1263 static void displayAddressQRCode(
void)
1267 .withLeftBorder =
true,
1268 .onActionCallback = &addressLayoutTouchCallbackQR,
1269 .tapActionText = NULL};
1277 addressConfirmationContext.modalLayout =
nbgl_layoutGet(&layoutDescription);
1282 SMALL_REGULAR_FONT, addressConfirmationContext.tagValuePair.value,
AVAILABLE_WIDTH,
false);
1284 if (nbLines <= QRCODE_NB_MAX_LINES) {
1285 qrCode.
text2 = addressConfirmationContext.tagValuePair.value;
1290 addressConfirmationContext.tagValuePair.value,
1292 QRCODE_NB_MAX_LINES,
1294 QRCODE_REDUCED_ADDR_LEN);
1295 qrCode.
text2 = reducedAddress;
1306 static void addressLayoutTouchCallbackQR(
int token,
uint8_t index)
1313 addressConfirmationContext.modalLayout = NULL;
1320 static void modalLayoutTouchCallback(
int token,
uint8_t index)
1327 genericContext.modalLayout = NULL;
1333 static void displaySkipWarning(
void)
1336 .cancelText =
"Go back to review",
1337 .centeredInfo.text1 =
"Skip review?",
1339 =
"If you're sure you don't need to review all fields, you can skip straight to signing.",
1340 .centeredInfo.text3 = NULL,
1342 .centeredInfo.icon = &C_Important_Circle_64px,
1343 .centeredInfo.offsetY = 0,
1344 .confirmationText =
"Yes, skip",
1345 .confirmationToken = SKIP_TOKEN,
1346 .tuneId = TUNE_TAP_CASUAL,
1348 if (modalPageContext != NULL) {
1360 static void updateKeyPad(
bool add)
1362 bool enableValidate, enableBackspace, enableDigits;
1363 bool redrawKeypad =
false;
1366 enableDigits = (keypadContext.pinLen < keypadContext.pinMaxDigits);
1367 enableValidate = (keypadContext.pinLen >= keypadContext.pinMinDigits);
1368 enableBackspace = (keypadContext.pinLen > 0);
1370 if ((keypadContext.pinLen == keypadContext.pinMinDigits)
1372 (keypadContext.pinLen == keypadContext.pinMaxDigits)
1374 (keypadContext.pinLen == 1)) {
1375 redrawKeypad =
true;
1379 if ((keypadContext.pinLen == 0) ||
1380 (keypadContext.pinLen == (keypadContext.pinMinDigits - 1))
1382 (keypadContext.pinLen
1383 == (keypadContext.pinMaxDigits - 1))) {
1384 redrawKeypad =
true;
1387 if (keypadContext.hidden ==
true) {
1392 keypadContext.layoutCtx,
false, 0, (
const char *) keypadContext.pinEntry);
1396 keypadContext.layoutCtx, 0, enableValidate, enableBackspace, enableDigits);
1399 if ((!add) && (keypadContext.pinLen == 0)) {
1407 static void keypadCallback(
char touchedKey)
1409 switch (touchedKey) {
1411 if (keypadContext.pinLen > 0) {
1412 keypadContext.pinLen--;
1413 keypadContext.pinEntry[keypadContext.pinLen] = 0;
1415 updateKeyPad(
false);
1424 onValidatePin(keypadContext.pinEntry, keypadContext.pinLen);
1428 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
1429 if (keypadContext.pinLen < keypadContext.pinMaxDigits) {
1430 keypadContext.pinEntry[keypadContext.pinLen] = touchedKey;
1431 keypadContext.pinLen++;
1440 static void keypadGenericUseCase(
const char *title,
1446 tune_index_e tuneId,
1452 .separationLine =
true,
1453 .backAndText.token = backToken,
1454 .backAndText.tuneId = tuneId,
1455 .backAndText.text = NULL};
1464 memset(&keypadContext, 0,
sizeof(KeypadContext_t));
1468 layoutDescription.
modal =
false;
1471 keypadContext.hidden = hidden;
1483 keypadContext.layoutCtx, title, keypadContext.hidden, maxDigits,
"");
1490 onValidatePin = validatePinCallback;
1492 keypadContext.pinMinDigits = minDigits;
1493 keypadContext.pinMaxDigits = maxDigits;
1511 nbElements = getContentNbElement(content);
1513 while (nbElements > 0) {
1516 bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
1538 nbElementsInPage =
MIN(nbMaxElementsPerContentType[content->
type], nbElements);
1541 elemIdx += nbElementsInPage;
1542 genericContextSetPageInfo(pageIdxStart + nbPages, nbElementsInPage, flag);
1543 nbElements -= nbElementsInPage;
1558 for (
int i = 0; i < genericContents->
nbContents; i++) {
1559 p_content = getContentAtIdx(genericContents, i, &content);
1560 if (p_content == NULL) {
1563 nbPages += nbgl_useCaseGetNbPagesForContent(p_content,
1564 pageIdxStart + nbPages,
1572 static void prepareAddressConfirmationPages(
const char *address,
1579 addressConfirmationContext.tagValuePair.item =
"Address";
1580 addressConfirmationContext.tagValuePair.value = address;
1589 if (tagValueList != NULL) {
1600 tagValueConfirm->tuneId = TUNE_TAP_CASUAL;
1608 if (tagValueList != NULL) {
1618 if (tagValueList != NULL) {
1626 tagValueConfirm->tuneId = TUNE_TAP_CASUAL;
1631 static void bundleNavStartHome(
void)
1633 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
1635 useCaseHomeExt(context->appName,
1638 context->settingContents != NULL ?
true :
false,
1639 &context->homeAction,
1640 bundleNavStartSettings,
1641 context->quitCallback);
1644 static void bundleNavStartSettingsAtPage(
uint8_t initSettingPage)
1646 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
1650 context->settingContents,
1652 bundleNavStartHome);
1655 static void bundleNavStartSettings(
void)
1657 bundleNavStartSettingsAtPage(0);
1660 static void bundleNavReviewConfirmRejection(
void)
1662 bundleNavContext.review.choiceCallback(
false);
1669 const char *confirmText;
1673 title =
"Reject transaction?";
1674 confirmText =
"Go back to transaction";
1677 title =
"Reject message?";
1678 confirmText =
"Go back to message";
1681 title =
"Reject operation?";
1682 confirmText =
"Go back to operation";
1689 static void bundleNavReviewChoice(
bool confirm)
1692 bundleNavContext.review.choiceCallback(
true);
1695 bundleNavReviewAskRejectionConfirmation(bundleNavContext.review.operationType,
1696 bundleNavReviewConfirmRejection);
1700 static void bundleNavReviewStreamingConfirmRejection(
void)
1702 bundleNavContext.reviewStreaming.choiceCallback(
false);
1705 static void bundleNavReviewStreamingChoice(
bool confirm)
1712 bundleNavContext.reviewStreaming.choiceCallback(
true);
1715 bundleNavReviewAskRejectionConfirmation(bundleNavContext.reviewStreaming.operationType,
1716 bundleNavReviewStreamingConfirmRejection);
1721 static void blindSigningWarningCallback(
bool confirm)
1724 blindSigningContext.choiceCallback(
false);
1727 if (blindSigningContext.isStreaming) {
1728 useCaseReviewStreamingStart(blindSigningContext.operationType,
1729 blindSigningContext.icon,
1730 blindSigningContext.reviewTitle,
1731 blindSigningContext.reviewSubTitle,
1732 blindSigningContext.choiceCallback,
1736 useCaseReview(blindSigningContext.operationType,
1737 blindSigningContext.tagValueList,
1738 blindSigningContext.icon,
1739 blindSigningContext.reviewTitle,
1740 blindSigningContext.reviewSubTitle,
1741 blindSigningContext.finishTitle,
1742 blindSigningContext.tipBox,
1743 blindSigningContext.choiceCallback,
1751 static void blindSigningWarning(
void)
1754 #ifdef HAVE_PIEZO_SOUND
1755 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
1758 "Blind signing ahead",
1759 "The details of this transaction or message are not fully verifiable. If "
1760 "you sign it, you could lose all "
1764 blindSigningWarningCallback);
1771 const char *reviewTitle,
1772 const char *reviewSubTitle,
1773 const char *finishTitle,
1777 bool playNotifSound)
1780 memset(&genericContext, 0,
sizeof(genericContext));
1782 bundleNavContext.review.operationType = operationType;
1783 bundleNavContext.review.choiceCallback = choiceCallback;
1786 onChoice = bundleNavReviewChoice;
1787 navType = GENERIC_NAV;
1790 genericContext.genericContents.contentsList = localContentsList;
1791 genericContext.genericContents.nbContents = 3;
1796 prepareReviewFirstPage(
1797 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
1798 if (tipBox != NULL) {
1800 STARTING_CONTENT.content.extendedCenter.contentCenter.subText = NULL;
1802 STARTING_CONTENT.content.extendedCenter.tipBox.icon = tipBox->
icon;
1803 STARTING_CONTENT.content.extendedCenter.tipBox.text = tipBox->
text;
1804 STARTING_CONTENT.content.extendedCenter.tipBox.token = TIP_BOX_TOKEN;
1805 STARTING_CONTENT.content.extendedCenter.tipBox.tuneId = TUNE_TAP_CASUAL;
1819 memcpy(&localContentsList[1].content.tagValueList,
1827 prepareReviewLightLastPage(&localContentsList[2].content.infoButton, icon, finishTitle);
1831 prepareReviewLastPage(&localContentsList[2].content.infoLongPress, icon, finishTitle);
1835 uint8_t nbPages = getNbPagesForGenericContents(
1837 prepareNavInfo(
true, nbPages, getRejectReviewText(operationType));
1840 if (playNotifSound) {
1841 #ifdef HAVE_PIEZO_SOUND
1842 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
1846 displayGenericContextPage(0,
true);
1852 const char *reviewTitle,
1853 const char *reviewSubTitle,
1855 bool playNotifSound)
1858 memset(&genericContext, 0,
sizeof(genericContext));
1860 bundleNavContext.reviewStreaming.operationType = operationType;
1861 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
1862 bundleNavContext.reviewStreaming.icon = icon;
1865 onChoice = bundleNavReviewStreamingChoice;
1866 navType = STREAMING_NAV;
1869 genericContext.genericContents.contentsList = localContentsList;
1870 genericContext.genericContents.nbContents = 1;
1875 prepareReviewFirstPage(
1876 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
1879 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
1886 if (playNotifSound) {
1887 #ifdef HAVE_PIEZO_SOUND
1888 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
1892 displayGenericContextPage(0,
true);
1911 static void useCaseHomeExt(
const char *appName,
1913 const char *tagline,
1922 .centeredInfo.text1 = appName,
1923 .centeredInfo.text3 = NULL,
1925 .centeredInfo.offsetY = 0,
1928 .tapActionText = NULL,
1930 .topRightToken = CONTINUE_TOKEN,
1931 .tuneId = TUNE_TAP_CASUAL};
1932 if ((homeAction->
text != NULL) || (homeAction->
icon != NULL)) {
1947 if (tagline == NULL) {
1949 snprintf(appDescription,
1951 "This app enables signing\ntransactions on its network.");
1954 snprintf(appDescription,
1966 snprintf(appDescription,
1979 onContinue = topRightCallback;
1980 onQuit = quitCallback;
1994 static void displayDetails(
const char *tag,
const char *value,
bool wrapping)
1996 memset(&detailsContext, 0,
sizeof(detailsContext));
2002 detailsContext.tag = tag;
2003 detailsContext.value = value;
2005 detailsContext.currentPage = 0;
2006 detailsContext.wrapping = wrapping;
2008 if (detailsContext.nbPages > 1) {
2009 uint16_t nbLostChars = (detailsContext.nbPages - 1) * 3;
2018 detailsContext.nbPages++;
2022 displayDetailsPage(0,
true);
2044 bool *requireSpecificDisplay)
2047 nbPairs, tagValueList, startIndex,
false, requireSpecificDisplay);
2067 bool *requireSpecificDisplay)
2083 *requireSpecificDisplay =
false;
2084 while (nbPairsInPage < nbPairs) {
2091 if (nbPairsInPage > 0) {
2093 currentHeight += 12;
2095 currentHeight += 24;
2099 if (tagValueList->
pairs != NULL) {
2100 pair = PIC(&tagValueList->
pairs[startIndex + nbPairsInPage]);
2103 pair = PIC(tagValueList->
callback(startIndex + nbPairsInPage));
2112 if (nbPairsInPage > 0) {
2119 *requireSpecificDisplay =
true;
2131 value_font = SMALL_REGULAR_FONT;
2134 value_font = LARGE_MEDIUM_FONT;
2143 if (nbPairsInPage == 0) {
2147 *requireSpecificDisplay =
true;
2153 return nbPairsInPage;
2174 const char *
const *infoTypes = PIC(infosList->
infoTypes);
2175 const char *
const *infoContents = PIC(infosList->
infoContents);
2177 while (nbInfosInPage < nbInfos) {
2183 SMALL_BOLD_FONT, PIC(infoTypes[startIndex + nbInfosInPage]),
AVAILABLE_WIDTH,
true);
2189 PIC(infoContents[startIndex + nbInfosInPage]),
2202 previousHeight = currentHeight;
2205 return nbInfosInPage;
2228 while (nbSwitchesInPage < nbSwitches) {
2234 switchArray[startIndex + nbSwitchesInPage].text,
2243 switchArray[startIndex + nbSwitchesInPage].subText,
2256 previousHeight = currentHeight;
2259 return nbSwitchesInPage;
2284 while (nbBarsInPage < nbBars) {
2290 previousHeight = currentHeight;
2298 return nbBarsInPage;
2320 UNUSED(choicesList);
2323 while (nbChoicesInPage < nbChoices) {
2334 previousHeight = currentHeight;
2337 return nbChoicesInPage;
2354 while (i < tagValueList->nbPairs) {
2358 nbPairs -= nbPairsInPage;
2370 const char *tagline,
2377 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
2386 const char *tagline,
2388 const char *actionButtonText,
2396 .text = actionButtonText};
2399 appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback);
2425 onQuit = quitCallback;
2426 onNav = navCallback;
2427 onControls = controlsCallback;
2429 navType = SETTINGS_NAV;
2432 prepareNavInfo(
false, nbPages, NULL);
2434 displaySettingsPage(initPage,
true);
2452 title, initPage, nbPages, quitCallback, navCallback, controlsCallback);
2474 memset(&genericContext, 0,
sizeof(genericContext));
2477 onQuit = quitCallback;
2478 pageTitle = appName;
2479 navType = GENERIC_NAV;
2481 if (settingContents != NULL) {
2484 if (infosList != NULL) {
2485 genericContext.hasFinishingContent =
true;
2488 memcpy(&FINISHING_CONTENT.content, infosList,
sizeof(
nbgl_content_u));
2492 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
2493 if (infosList != NULL) {
2494 nbPages += nbgl_useCaseGetNbPagesForContent(&FINISHING_CONTENT, nbPages,
true,
false);
2497 prepareNavInfo(
false, nbPages, NULL);
2499 displayGenericContextPage(initPage,
true);
2538 const char *appName,
2540 const char *tagline,
2548 nbgl_homeAndSettingsContext_t *context = &bundleNavContext.homeAndSettings;
2550 context->appName = appName;
2551 context->appIcon = appIcon;
2552 context->tagline = tagline;
2553 context->settingContents = settingContents;
2554 context->infosList = infosList;
2555 if (action != NULL) {
2561 context->quitCallback = quitCallback;
2564 bundleNavStartSettingsAtPage(initSettingPage);
2567 bundleNavStartHome();
2583 .tickerCallback = &tickerCallback,
2584 .tickerIntervale = 0,
2587 onQuit = quitCallback;
2589 #ifdef HAVE_PIEZO_SOUND
2590 io_seproxyhal_play_tune(TUNE_LEDGER_MOMENT);
2598 .centeredInfo.icon = &C_Denied_Circle_64px,
2600 .centeredInfo.onTop =
false,
2602 .centeredInfo.text1 = message,
2603 .centeredInfo.text2 = NULL,
2604 .centeredInfo.text3 = NULL,
2605 .tapActionText =
"",
2606 .isSwipeable =
false,
2607 .tapActionToken = QUIT_TOKEN,
2609 .actionButtonText = NULL,
2610 .tuneId = TUNE_TAP_CASUAL};
2627 switch (reviewStatusType) {
2629 msg =
"Operation signed";
2633 msg =
"Operation rejected";
2637 msg =
"Transaction signed";
2641 msg =
"Transaction rejected";
2645 msg =
"Message signed";
2649 msg =
"Message rejected";
2653 msg =
"Address verified";
2657 msg =
"Address verification\ncancelled";
2679 const char *message,
2680 const char *subMessage,
2681 const char *confirmText,
2682 const char *cancelText,
2689 .centeredInfo.text2 = subMessage,
2690 .centeredInfo.text3 = NULL,
2692 .centeredInfo.icon = icon,
2693 .centeredInfo.offsetY = 0,
2694 .confirmationText = confirmText,
2695 .confirmationToken = CHOICE_TOKEN,
2696 .tuneId = TUNE_TAP_CASUAL,
2699 if ((confirmText == NULL) || (cancelText == NULL)) {
2702 onChoice = callback;
2721 const char *subMessage,
2722 const char *confirmText,
2723 const char *cancelText,
2729 .centeredInfo.text1 = message,
2730 .centeredInfo.text2 = subMessage,
2731 .centeredInfo.text3 = NULL,
2733 .centeredInfo.icon = &C_Important_Circle_64px,
2734 .centeredInfo.offsetY = 0,
2735 .confirmationText = confirmText,
2736 .confirmationToken = CHOICE_TOKEN,
2737 .tuneId = TUNE_TAP_CASUAL,
2739 onModalConfirm = callback;
2740 if (modalPageContext != NULL) {
2759 const char *reviewTitle,
2760 const char *reviewSubTitle,
2761 const char *rejectText,
2768 .footerToken = QUIT_TOKEN,
2769 .tapActionText = NULL,
2770 .isSwipeable =
true,
2771 .tapActionToken = CONTINUE_TOKEN,
2773 .actionButtonText = NULL,
2774 .tuneId = TUNE_TAP_CASUAL};
2781 onQuit = rejectCallback;
2782 onContinue = continueCallback;
2784 #ifdef HAVE_PIEZO_SOUND
2786 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
2808 const char *rejectText,
2816 onChoice = choiceCallback;
2817 onNav = navCallback;
2818 onControls = buttonCallback;
2819 forwardNavOnly =
false;
2820 navType = REVIEW_NAV;
2824 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
2826 displayReviewPage(initPage,
true);
2843 const char *rejectText,
2849 memset(&genericContext, 0,
sizeof(genericContext));
2852 onChoice = callback;
2853 navType = GENERIC_NAV;
2857 genericContext.genericContents.contentsList = localContentsList;
2860 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
2862 memcpy(&localContentsList[offset].content.tagValueList,
2869 memcpy(&localContentsList[offset].content.infoLongPress,
2875 genericContext.genericContents.nbContents = offset;
2878 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
2880 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
2882 displayGenericContextPage(0,
true);
2900 const char *rejectText,
2906 memset(&genericContext, 0,
sizeof(genericContext));
2909 onChoice = callback;
2910 navType = GENERIC_NAV;
2913 genericContext.genericContents.contentsList = localContentsList;
2916 if (tagValueList != NULL && tagValueList->
nbPairs != 0) {
2918 memcpy(&localContentsList[offset].content.tagValueList,
2932 genericContext.genericContents.nbContents = offset;
2935 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
2937 prepareNavInfo(
true, nbPages, getRejectReviewText(
TYPE_OPERATION));
2939 displayGenericContextPage(0,
true);
2961 const char *reviewTitle,
2962 const char *reviewSubTitle,
2963 const char *finishTitle,
2966 useCaseReview(operationType,
2998 const char *reviewTitle,
2999 const char *reviewSubTitle,
3000 const char *finishTitle,
3004 useCaseReview(operationType,
3038 const char *reviewTitle,
3039 const char *reviewSubTitle,
3040 const char *finishTitle,
3044 memset(&blindSigningContext, 0,
sizeof(blindSigningContext));
3046 blindSigningContext.isStreaming =
false;
3048 blindSigningContext.tagValueList = tagValueList;
3049 blindSigningContext.icon = icon;
3050 blindSigningContext.reviewTitle = reviewTitle;
3051 blindSigningContext.reviewSubTitle = reviewSubTitle;
3052 blindSigningContext.finishTitle = finishTitle;
3053 blindSigningContext.tipBox = tipBox;
3054 blindSigningContext.choiceCallback = choiceCallback;
3056 blindSigningWarning();
3077 const char *reviewTitle,
3078 const char *reviewSubTitle,
3079 const char *finishTitle,
3082 useCaseReview(operationType,
3103 const char *rejectText,
3107 memset(&genericContext, 0,
sizeof(genericContext));
3110 onQuit = rejectCallback;
3111 navType = GENERIC_NAV;
3118 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3119 prepareNavInfo(
true, nbPages, rejectText);
3122 #ifdef HAVE_PIEZO_SOUND
3124 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3127 displayGenericContextPage(0,
true);
3144 const char *reviewTitle,
3145 const char *reviewSubTitle,
3148 useCaseReviewStreamingStart(
3149 operationType, icon, reviewTitle, reviewSubTitle, choiceCallback,
true);
3167 const char *reviewTitle,
3168 const char *reviewSubTitle,
3171 memset(&blindSigningContext, 0,
sizeof(blindSigningContext));
3173 blindSigningContext.isStreaming =
true;
3175 blindSigningContext.icon = icon;
3176 blindSigningContext.reviewTitle = reviewTitle;
3177 blindSigningContext.reviewSubTitle = reviewSubTitle;
3178 blindSigningContext.choiceCallback = choiceCallback;
3180 blindSigningWarning();
3201 memset(&genericContext, 0,
sizeof(genericContext));
3203 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3204 bundleNavContext.reviewStreaming.skipCallback = skipCallback;
3207 onChoice = bundleNavReviewStreamingChoice;
3208 navType = STREAMING_NAV;
3211 genericContext.genericContents.contentsList = localContentsList;
3212 genericContext.genericContents.nbContents = 1;
3221 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3222 &genericContext.genericContents,
3225 prepareNavInfo(
true,
3227 getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
3235 displayGenericContextPage(0,
true);
3266 memset(&genericContext, 0,
sizeof(genericContext));
3268 bundleNavContext.reviewStreaming.choiceCallback = choiceCallback;
3271 onChoice = bundleNavReviewStreamingChoice;
3272 navType = STREAMING_NAV;
3275 genericContext.genericContents.contentsList = localContentsList;
3276 genericContext.genericContents.nbContents = 1;
3281 prepareReviewLastPage(&STARTING_CONTENT.content.infoLongPress,
3282 bundleNavContext.reviewStreaming.icon,
3286 bundleNavContext.reviewStreaming.stepPageNb = getNbPagesForGenericContents(
3287 &genericContext.genericContents,
3290 prepareNavInfo(
true, 1, getRejectReviewText(bundleNavContext.reviewStreaming.operationType));
3292 displayGenericContextPage(0,
true);
3304 memset(&genericContext, 0,
sizeof(genericContext));
3305 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
3308 onChoice = callback;
3309 navType = GENERIC_NAV;
3312 genericContext.genericContents.contentsList = localContentsList;
3313 genericContext.genericContents.nbContents = (tagValueList == NULL) ? 1 : 2;
3315 prepareAddressConfirmationPages(
3316 address, tagValueList, &STARTING_CONTENT, &localContentsList[1]);
3319 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3321 prepareNavInfo(
true, nbPages,
"Cancel");
3323 #ifdef HAVE_PIEZO_SOUND
3325 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3328 displayGenericContextPage(0,
true);
3350 const char *reviewTitle,
3351 const char *reviewSubTitle,
3355 memset(&genericContext, 0,
sizeof(genericContext));
3357 if (addressConfirmationContext.modalLayout) {
3360 memset(&addressConfirmationContext, 0,
sizeof(addressConfirmationContext));
3363 onChoice = choiceCallback;
3364 navType = GENERIC_NAV;
3368 genericContext.genericContents.contentsList = localContentsList;
3369 genericContext.genericContents.nbContents = (additionalTagValueList == NULL) ? 2 : 3;
3374 prepareReviewFirstPage(
3375 &STARTING_CONTENT.content.extendedCenter.contentCenter, icon, reviewTitle, reviewSubTitle);
3376 STARTING_CONTENT.content.extendedCenter.contentCenter.subText =
"Swipe to continue";
3379 prepareAddressConfirmationPages(
3380 address, additionalTagValueList, &localContentsList[1], &localContentsList[2]);
3383 uint8_t nbPages = getNbPagesForGenericContents(&genericContext.genericContents, 0,
false);
3385 prepareNavInfo(
true, nbPages,
"Cancel");
3387 #ifdef HAVE_PIEZO_SOUND
3389 io_seproxyhal_play_tune(TUNE_LOOK_AT_ME);
3392 displayGenericContextPage(0,
true);
3432 tune_index_e tuneId,
3436 keypadGenericUseCase(title,
3443 validatePinCallback,
3470 tune_index_e tuneId,
3474 keypadGenericUseCase(title,
3481 validatePinCallback,
@ LARGE_CASE_INFO
text in BLACK and large case (INTER 32px), subText in black in Inter24px
nbgl_contentTagValue_t *(* nbgl_contentTagValueCallback_t)(uint8_t pairIndex)
prototype of tag/value pair retrieval callback
@ 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
@ 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_DEBUG(__logger,...)
bool nbgl_getTextMaxLenInNbLines(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, uint16_t maxNbLines, uint16_t *len, bool wrapping)
compute the len of the given text (in bytes) fitting in the given maximum nb lines,...
void nbgl_textReduceOnNbLines(nbgl_font_id_e fontId, const char *origText, uint16_t maxWidth, uint8_t nbLines, char *reducedText, uint16_t reducedTextLen)
Create a reduced version of given ASCII text to wrap it on the given max width (in pixels),...
uint16_t nbgl_getTextHeightInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
return the height of the given multiline text, with the given font.
uint16_t nbgl_getTextNbLinesInWidth(nbgl_font_id_e fontId, const char *text, uint16_t maxWidth, bool wrapping)
compute the number of lines of the given text fitting in the given maxWidth
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
#define SIMPLE_FOOTER_HEIGHT
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, const char *title, const char *description, const char *info)
Creates in the main container three text areas:
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.
#define TEXT_SUBTEXT_MARGIN
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_layoutAddCenteredInfo(nbgl_layout_t *layout, const nbgl_layoutCenteredInfo_t *info)
Creates an area on the center of the main panel, with a possible icon/image, a possible text in black...
#define TOUCHABLE_BAR_HEIGHT
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
@ 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
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
#define SMALL_FOOTER_HEIGHT
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...
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.
#define NBGL_NO_PROGRESS_INDICATOR
To be used when a control token shall not be used.
#define POST_SUBTEXT_MARGIN
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,...
#define SMALL_CENTERING_HEADER
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.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
#define TOUCHABLE_HEADER_BAR_HEIGHT
void nbgl_refresh(void)
This functions refreshes the actual screen on display with what has changed since the last refresh.
#define KEYPAD_MAX_DIGITS
void nbgl_refreshSpecial(nbgl_refresh_mode_t mode)
This functions refreshes the actual screen on display with what has changed since the last refresh,...
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_pageDrawSpinner(nbgl_layoutTouchCallback_t onActionCallback, const char *text)
draw a spinner page with the given parameters. The spinner will "rotate" automatically every 800 ms
nbgl_page_t * nbgl_pageDrawLedgerInfo(nbgl_layoutTouchCallback_t onActionCallback, const nbgl_screenTickerConfiguration_t *ticker, const char *text, int tapActionToken)
draw a page with a centered text in large case, with a round check icon
void * nbgl_page_t
type shared externally
@ NAV_WITH_BUTTONS
move forward and backward with buttons in bottom nav bar
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,...
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...
int nbgl_pageRelease(nbgl_page_t *)
Release the page obtained with any of the nbgl_pageDrawXXX() functions.
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...
@ 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)
This function redraws the whole screen on top of stack and its children.
@ 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()
@ 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
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)
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool isSkippable, bool *requireSpecificDisplay)
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.
void nbgl_useCaseGenericSettings(const char *appName, uint8_t initPage, const nbgl_genericContents_t *settingContents, const nbgl_contentInfoList_t *infosList, nbgl_callback_t quitCallback)
void nbgl_useCaseKeypadPIN(const char *title, uint8_t minDigits, uint8_t maxDigits, uint8_t backToken, bool shuffled, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback)
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)
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool *requireSpecificDisplay)
uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList)
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)
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos, const nbgl_contentInfoList_t *infosList, uint8_t startIndex, bool withNav)
void(* nbgl_choiceCallback_t)(bool confirm)
prototype of choice callback function
uint8_t nbgl_useCaseGetNbBarsInPage(uint8_t nbBars, const nbgl_contentBarsList_t *barsList, uint8_t startIndex, bool withNav)
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)
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)
DEPRECATED void nbgl_useCaseHomeExt(const char *appName, const nbgl_icon_details_t *appIcon, const char *tagline, bool withSettings, const char *actionButtonText, nbgl_callback_t actionCallback, nbgl_callback_t topRightCallback, nbgl_callback_t quitCallback)
void nbgl_useCaseKeypadDigits(const char *title, uint8_t minDigits, uint8_t maxDigits, uint8_t backToken, bool shuffled, tune_index_e tuneId, nbgl_pinValidCallback_t validatePinCallback, nbgl_layoutTouchCallback_t actionCallback)
#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)
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_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 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)
void nbgl_useCaseRegularReview(uint8_t initPage, uint8_t nbPages, const char *rejectText, nbgl_layoutTouchCallback_t buttonCallback, nbgl_navCallback_t navCallback, nbgl_choiceCallback_t choiceCallback)
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_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, 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_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,...
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.
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_pinValidCallback_t)(const uint8_t *content, uint8_t page)
prototype of pin validation callback function
uint8_t nbgl_useCaseGetNbSwitchesInPage(uint8_t nbSwitches, const nbgl_contentSwitchesList_t *switchesList, uint8_t startIndex, bool withNav)
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)
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)
This structure contains info to build a centered (vertically and horizontally) area,...
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
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
This structure contains data to build a INFOS_LIST content.
uint8_t nbInfos
number of elements in infoTypes and infoContents array
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
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),...
This structure contains [item,value] pair(s) and info about a potential "details" button,...
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
This structure contains a list of [tag,value] pairs.
nbgl_contentActionCallback_t actionCallback
called when a valueIcon is touched on a given pair
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
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_contentTagValueCallback_t callback
function to call to retrieve a given pair
uint8_t nbMaxLinesForValue
This structure contains a [tag,value] pair.
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
const nbgl_icon_details_t * valueIcon
int8_t centeredInfo
if set to 1, the tag will be displayed as a centered info
const char * value
string giving the value name
const char * item
string giving the tag name
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
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
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
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
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 centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * url
URL for QR code.
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
nbgl_layoutCenteredInfo_t centeredInfo
description of the centered info to be used
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
uint8_t bottomButtonsToken
const nbgl_icon_details_t * actionButtonIcon
potential icon of "action" button
nbgl_pageButtonStyle_t bottomButtonStyle
style to apply to the Bottom 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)
Structure containing all specific information when creating a NBGL step.
The necessary parameters to build a tip-box in first review page and the modal if this tip box is tou...
const nbgl_contentInfoList_t infos
infos pairs displayed in modal.
const char * modalTitle
title given to modal window displayed when tip-box is touched
const char * text
text of the tip-box
nbgl_contentType_t type
type of page content in the following union
const nbgl_icon_details_t * icon
icon of the tip-box
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