19#include "os_helpers.h"
30typedef struct ReviewContext_s {
34 const char *reviewTitle;
35 const char *reviewSubTitle;
36 const char *finishTitle;
41 uint8_t dataDirection;
42 uint8_t currentTagValueIndex;
44 uint16_t currentExtensionPage;
45 uint16_t nbExtensionPages;
46 const nbgl_contentValueExt_t *extension;
48 const char *aliasValue;
52typedef struct ChoiceContext_s {
56 const char *subMessage;
57 const char *confirmText;
58 const char *cancelText;
63typedef struct ConfirmContext_s {
65 const char *subMessage;
66 const char *confirmText;
67 const char *cancelText;
72typedef struct ContentContext_s {
74 nbgl_genericContents_t genericContents;
75 const char *rejectText;
81typedef struct HomeContext_s {
85 const nbgl_genericContents_t *settingContents;
87 const nbgl_homeAction_t *homeAction;
91typedef struct ActionContext_s {
96typedef struct KeypadContext_s {
100 uint8_t pinMaxDigits;
110typedef struct KeyboardContext_s {
111 nbgl_layoutKeyboardContent_t content;
113 uint16_t entryMaxLen;
115 uint8_t keyboardIndex;
128 GENERIC_REVIEW_USE_CASE,
129 ADDRESS_REVIEW_USE_CASE,
130 STREAMING_START_REVIEW_USE_CASE,
131 STREAMING_CONTINUE_REVIEW_USE_CASE,
132 STREAMING_FINISH_REVIEW_USE_CASE,
146typedef struct UseCaseContext_s {
151 uint8_t firstPairPage;
156 ReviewContext_t review;
157 ChoiceContext_t choice;
158 ConfirmContext_t confirm;
160 ContentContext_t content;
162 KeypadContext_t keypad;
165 KeyboardContext_t keyboard;
167 ActionContext_t action;
171typedef struct PageContent_s {
176 const nbgl_contentValueExt_t *extension;
183 uint8_t nbMaxLinesForSubText;
186typedef struct ReviewWithWarningContext_s {
191 const char *reviewTitle;
192 const char *reviewSubTitle;
193 const char *finishTitle;
194 const nbgl_warning_t *warning;
196 uint8_t securityReportLevel;
199 uint8_t nbWarningPages;
200 uint8_t firstWarningPage;
201 uint8_t barDetailIdx;
202} ReviewWithWarningContext_t;
213static UseCaseContext_t context;
215static ReviewWithWarningContext_t reviewWithWarnCtx;
236static void displaySpinner(
const char *text);
238static void startUseCaseHome(
void);
239static void startUseCaseInfo(
void);
240static void startUseCaseSettings(
void);
241static void startUseCaseSettingsAtPage(uint8_t initSettingPage);
242static void startUseCaseContent(
void);
244static void statusTickerCallback(
void);
247static void displayWarningStep(
void);
262 return (tagValueList->
pairs != NULL)
263 || (((uint16_t) tagValueList->
startIndex + tagValueList->
nbPairs) <= (UINT8_MAX + 1));
285 return (infoList != NULL) && (infoList->
nbInfos > 0);
289 return (aliasList != NULL) && (aliasList->
nbPairs > 0)
290 && checkTagValueList(aliasList,
false);
301 if (tagValueList->
nbPairs == 0) {
304 if (tagValueList->
pairs == NULL) {
305 if ((tagValueList->
callback == NULL) || !isTagValueListValid(tagValueList)) {
309 else if (!checkAliases) {
312 for (uint8_t i = 0; i < tagValueList->
nbPairs; i++) {
315 if (tagValueList->
pairs != NULL) {
316 pair = PIC(&tagValueList->
pairs[i]);
321 if ((pair == NULL) || (checkAliases && !isAliasDetailsComplete(pair))) {
333 return checkTagValueList(tagValueList,
true);
351 switch (content->
type) {
359 return UINT8_MAX + 1;
365 return UINT8_MAX + 1;
389 if (contentIdx >= genericContents->
nbContents) {
395 if (content == NULL) {
401 if (context.content.navCallback) {
402 if (context.content.navCallback(contentIdx, &pageContent) ==
true) {
405 switch (content->
type) {
454 uint8_t *elemContentIdx,
459 uint16_t nbPages = 0;
460 uint16_t elemNbPages = 0;
462 switch (context.type) {
463 case SETTINGS_USE_CASE:
465 case GENERIC_SETTINGS:
466 genericContents = context.home.settingContents;
468 case CONTENT_USE_CASE:
469 case GENERIC_REVIEW_USE_CASE:
470 genericContents = &context.content.genericContents;
475 for (
unsigned int i = 0; i < genericContents->
nbContents; i++) {
476 p_content = getContentAtIdx(genericContents, i, content);
477 elemNbPages = getContentNbElement(p_content);
478 if (nbPages + elemNbPages > elemIdx) {
479 *elemContentIdx = context.currentPage - nbPages;
482 nbPages += elemNbPages;
488static const char *getChoiceName(uint8_t choiceIndex)
498 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
499 if (p_content == NULL) {
501 "getChoiceName(): p_content is NULL for page %d\n",
502 context.currentPage);
505 switch (p_content->
type) {
508 names = (
char **) PIC(contentChoices->
names);
513 names = (
char **) PIC(contentBars->
barTexts);
514 nbValues = contentBars->
nbBars;
520 if (choiceIndex >= nbValues) {
524 return (
const char *) PIC(names[choiceIndex]);
527static void onChoiceSelected(uint8_t choiceIndex)
536 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
537 if (p_content == NULL) {
539 "onChoiceSelected(): p_content is NULL for page %d\n",
540 context.currentPage);
543 switch (p_content->
type) {
546 if (choiceIndex < contentChoices->nbChoices) {
547 token = contentChoices->
token;
552 if (choiceIndex < contentBars->nbBars) {
553 token = ((
const uint8_t *) PIC(contentBars->
tokens))[choiceIndex];
566 actionCallback(token, choiceIndex, context.currentPage);
569 if (context.content.controlsCallback != NULL) {
570 context.content.controlsCallback(token, choiceIndex);
578 if ((context.type == GENERIC_SETTINGS) && (context.home.quitCallback != NULL)) {
579 context.home.quitCallback();
582 if (context.type == SETTINGS_USE_CASE) {
586 if (context.content.quitCallback != NULL) {
587 context.content.quitCallback();
597 bool *isCenteredInfo,
598 uint8_t *nbMaxLinesForValue)
603 if (tagValueList->
pairs != NULL) {
604 pair = PIC(&tagValueList->
pairs[index]);
612 memset(&emptyPair, 0,
sizeof(emptyPair));
614 emptyPair.
value =
"";
619 *value = pair->
value;
624 *isCenteredInfo =
true;
630 if (nbMaxLinesForValue != NULL) {
636static void onReviewAccept(
void)
638 if (context.review.onChoice) {
639 context.review.onChoice(
true);
643static void onReviewReject(
void)
645 if (context.review.onChoice) {
646 context.review.onChoice(
false);
650static void onChoiceAccept(
void)
652 if (context.choice.onChoice) {
653 context.choice.onChoice(
true);
657static void onChoiceReject(
void)
659 if (context.choice.onChoice) {
660 context.choice.onChoice(
false);
664static void onConfirmAccept(
void)
666 if (context.confirm.currentStep) {
669 if (context.confirm.onConfirm) {
670 context.confirm.onConfirm();
674static void onConfirmReject(
void)
676 if (context.confirm.currentStep) {
683static void onSwitchAction(
void)
690 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
693 "onSwitchAction(): p_content is NULL or not a switches list for page %d\n",
694 context.currentPage);
699 switch (context.type) {
700 case SETTINGS_USE_CASE:
702 case GENERIC_SETTINGS:
705 case CONTENT_USE_CASE:
706 case GENERIC_REVIEW_USE_CASE:
714 actionCallback(contentSwitch->
token,
716 context.currentPage);
718 else if (context.content.controlsCallback != NULL) {
719 context.content.controlsCallback(contentSwitch->
token, 0);
728 uint8_t nbMaxLinesForSubTxt,
731 ForcedType_t forcedType,
743 .tickerIntervale = 0,
749 if ((context.type == STREAMING_CONTINUE_REVIEW_USE_CASE)
750 && (context.review.skipCallback != NULL) && (context.review.nbDataSets > 1)) {
753 if ((context.type == STATUS_USE_CASE) || (context.type == SPINNER_USE_CASE)) {
756 if ((context.type == CONFIRM_USE_CASE) && (context.confirm.currentStep != NULL)) {
761 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
763 switch (p_content->
type) {
785 else if ((icon == NULL) && (forcedType != FORCE_CENTERED_INFO)) {
787 if (subTxt != NULL) {
788 style = (forcedType == FORCE_BUTTON) ? BUTTON_INFO : BOLD_TEXT1_INFO;
791 style = REGULAR_INFO;
794 pos, onActionCallback, p_ticker, txt, subTxt, style, modal, nbMaxLinesForSubTxt);
801 info.bottomIcon = bottomIcon;
802 if ((subTxt != NULL) || (context.stepCallback != NULL) || context.forceAction) {
803 info.
style = BOLD_TEXT1_INFO;
806 info.
style = REGULAR_INFO;
810 if (context.type == CONFIRM_USE_CASE) {
811 context.confirm.currentStep = newStep;
817 const char *description,
826 switchInfo.
text = title;
827 switchInfo.
subText = description;
840 if (context.currentPage > 0) {
841 context.currentPage--;
845 else if ((context.type != STREAMING_CONTINUE_REVIEW_USE_CASE)
846 || (context.review.skipCallback == NULL) || (context.review.nbDataSets == 1)) {
853 if (context.currentPage < (
int) (context.nbPages - 1)) {
854 context.currentPage++;
864 if (context.stepCallback != NULL) {
865 context.stepCallback();
867 else if ((context.type == CONTENT_USE_CASE) || (context.type == SETTINGS_USE_CASE)
868 || (context.type == GENERIC_SETTINGS)
869 || (context.type == GENERIC_REVIEW_USE_CASE)) {
870 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
871 if (p_content != NULL) {
872 switch (p_content->
type) {
886 token = ((
const uint8_t *) PIC(
897 if (elemIdx < p_content->content.tagValueConfirm.tagValueList.nbPairs) {
906 bool used_action_callback
908 ContextType_t prev_type = context.type;
909 if (used_action_callback) {
912 actionCallback(token, index, context.currentPage);
914 else if (context.content.controlsCallback != NULL) {
915 context.content.controlsCallback(token, index);
921 if (context.type != prev_type) {
934 if (used_action_callback
952 if (!buttonGenericCallback(event, &
pos)) {
957 context.review.dataDirection =
pos;
959 displayReviewPage(
pos);
971 && (context.currentPage > context.firstPairPage)) {
972 context.currentPage--;
979 && (context.currentPage < (
int) (context.nbPages - 1))
980 && (context.currentPage > context.firstPairPage)) {
981 context.currentPage++;
987 if (context.firstPairPage == 0) {
989 context.review.skipCallback();
993 context.currentPage = context.nbPages - 2;
1002 if (context.firstPairPage == 0) {
1003 displayStreamingReviewPage(
pos);
1006 displayReviewPage(
pos);
1016 context.action.actionCallback();
1025 if (!buttonGenericCallback(event, &
pos)) {
1030 context.review.dataDirection =
pos;
1033 displayStreamingReviewPage(
pos);
1041 if (!buttonGenericCallback(event, &
pos)) {
1045 displaySettingsPage(
pos,
false);
1053 if (!buttonGenericCallback(event, &
pos)) {
1057 displayInfoPage(
pos);
1065 if (!buttonGenericCallback(event, &
pos)) {
1069 displayHomePage(
pos);
1077 if (!buttonGenericCallback(event, &
pos)) {
1081 displayChoicePage(
pos);
1089 if (!buttonGenericCallback(event, &
pos)) {
1093 displayConfirm(
pos);
1102 if (context.stepCallback != NULL) {
1103 context.stepCallback();
1113 if (!buttonGenericCallback(event, &
pos)) {
1117 displayContent(
pos,
false);
1121static void statusTickerCallback(
void)
1123 if (context.stepCallback != NULL) {
1124 context.stepCallback();
1136 if (context.review.currentExtensionPage > 0) {
1137 context.review.currentExtensionPage--;
1143 if (context.review.currentExtensionPage < (context.review.nbExtensionPages - 1)) {
1144 context.review.currentExtensionPage++;
1150 if (context.review.currentExtensionPage == (context.review.nbExtensionPages - 1)) {
1160 displayExtensionStep(
pos);
1169 const char *text = NULL;
1170 const char *subText = NULL;
1171 uint8_t nbMaxLines = 0;
1173 if (context.review.extensionStepCtx != NULL) {
1175 context.review.extensionStepCtx = NULL;
1177 if (context.review.currentExtensionPage < (context.review.nbExtensionPages - 1)) {
1180 const char *aliasHeading = (context.review.extension->title != NULL)
1181 ? context.review.extension->title
1182 : context.review.aliasValue;
1184 if (context.review.currentExtensionPage == 0) {
1191 switch (context.review.extension->aliasType) {
1193 text = aliasHeading;
1194 subText = context.review.extension->fullValue;
1197 bool has_scope = (context.review.extension->aliasSubName != NULL);
1198 bool has_tn = (context.review.extension->explanation != NULL);
1199 uint8_t page = (uint8_t) context.review.currentExtensionPage;
1201 text = aliasHeading;
1202 subText = has_scope ? context.review.extension->aliasSubName
1203 : context.review.extension->fullValue;
1205 else if (has_scope && page == 1) {
1206 text = aliasHeading;
1207 subText = context.review.extension->fullValue;
1210 text = context.review.extension->explanation;
1215 infoList = context.review.extension->infolist;
1216 text = PIC(infoList->
infoTypes[context.review.currentExtensionPage]);
1217 subText = PIC(infoList->
infoContents[context.review.currentExtensionPage]);
1223 bool pairIsCenteredInfo =
false;
1225 tagValueList = context.review.extension->tagValuelist;
1227 getPairData(tagValueList,
1228 (uint8_t) context.review.currentExtensionPage,
1233 &pairIsCenteredInfo,
1236 subText = PIC(subText);
1244 pos, extensionNavigate, NULL, text, subText, BOLD_TEXT1_INFO,
true, nbMaxLines);
1247 else if (context.review.currentExtensionPage == (context.review.nbExtensionPages - 1)) {
1249 info.
icon = &C_icon_back_x;
1250 info.
text1 =
"Back";
1251 info.
style = BOLD_TEXT1_INFO;
1253 context.review.extensionStepCtx
1259static void displayAliasFullValue(
void)
1261 const char *text = NULL;
1262 const char *subText = NULL;
1264 bool isCenteredInfo;
1266 getPairData(context.review.tagValueList,
1267 context.review.currentTagValueIndex,
1270 &context.review.extension,
1274 if (context.review.extension == NULL) {
1277 "displayAliasFullValue: extension nor found for pair %d\n",
1278 context.review.currentTagValueIndex);
1281 context.review.currentExtensionPage = 0;
1282 context.review.extensionStepCtx = NULL;
1283 context.review.aliasValue = (subText != NULL) ? PIC(subText) :
"";
1285 switch (context.review.extension->aliasType) {
1287 context.review.nbExtensionPages = 2;
1290 context.review.nbExtensionPages
1291 = 2 + ((context.review.extension->aliasSubName != NULL) ? 1 : 0)
1292 + ((context.review.extension->explanation != NULL) ? 1 : 0);
1298 uint8_t nbElements = 0;
1301 nbElements = (infoList != NULL) ? infoList->
nbInfos : 0;
1305 = PIC(context.review.extension->tagValuelist);
1306 nbElements = (aliasList != NULL) ? aliasList->
nbPairs : 0;
1308 if (nbElements == 0) {
1313 context.review.nbExtensionPages = (uint16_t) nbElements + 1;
1318 "displayAliasFullValue: unsupported alias type %d\n",
1319 context.review.extension->aliasType);
1325static void getLastPageInfo(
bool approve,
const nbgl_icon_details_t **icon,
const char **text)
1329 *icon = &C_icon_validate_14;
1331 if ((context.type == REVIEW_USE_CASE) && (context.review.finishTitle != NULL)) {
1332 *text = context.review.finishTitle;
1335 *text =
"Confirm contact details";
1338 else if (context.type == ADDRESS_REVIEW_USE_CASE) {
1343 if (context.review.finishTitle != NULL) {
1344 *text = context.review.finishTitle;
1350 *text =
"Accept risk and sign transaction";
1353 *text =
"Sign transaction";
1358 *text =
"Accept risk and sign message";
1361 *text =
"Sign message";
1366 *text =
"Accept risk and sign operation";
1369 *text =
"Sign operation";
1375 context.stepCallback = onReviewAccept;
1379 *icon = &C_icon_crossmark;
1380 if ((context.type == ADDRESS_REVIEW_USE_CASE)
1385 *text =
"Reject transaction";
1388 *text =
"Reject message";
1391 *text =
"Reject operation";
1393 context.stepCallback = onReviewReject;
1400 uint8_t reviewPages = 0;
1401 uint8_t finalPages = 0;
1402 uint8_t pairIndex = 0;
1403 const char *text = NULL;
1404 const char *subText = NULL;
1406 uint8_t currentIndex = 0;
1407 uint8_t titleIndex = 255;
1408 uint8_t subIndex = 255;
1409 uint8_t approveIndex = 255;
1410 uint8_t rejectIndex = 255;
1412 ForcedType_t forcedType = NO_FORCED_TYPE;
1413 uint8_t nbMaxLines = 0;
1415 context.stepCallback = NULL;
1419 titleIndex = currentIndex++;
1421 if (context.review.reviewSubTitle) {
1423 subIndex = currentIndex++;
1426 approveIndex = context.nbPages - 2;
1427 rejectIndex = context.nbPages - 1;
1428 finalPages = approveIndex;
1431 if (context.currentPage >= finalPages) {
1432 if (context.currentPage == approveIndex) {
1434 getLastPageInfo(
true, &icon, &text);
1436 else if (context.currentPage == rejectIndex) {
1438 getLastPageInfo(
false, &icon, &text);
1441 else if (context.currentPage < reviewPages) {
1442 if (context.currentPage == titleIndex) {
1444 icon = context.review.icon;
1445 text = context.review.reviewTitle;
1447 else if (context.currentPage == subIndex) {
1449 text = context.review.reviewSubTitle;
1452 else if ((context.review.address != NULL) && (context.currentPage == reviewPages)) {
1455 subText = context.review.address;
1461 if ((context.operationType &
SKIPPABLE_OPERATION) && (context.review.skipDisplay ==
false)
1462 && ((context.currentPage > reviewPages)
1466 if ((context.review.nbDataSets == 1) || (context.currentPage > 0)) {
1469 info.
icon = &C_Information_circle_14px;
1470 info.
text1 =
"Press right button to continue message or \bpress both to skip\b";
1473 context.review.skipDisplay =
true;
1474 context.firstPairPage = reviewPages;
1477 context.review.skipDisplay =
false;
1478 bool isCenteredInfo =
false;
1479 pairIndex = context.currentPage - reviewPages;
1480 if (context.review.address != NULL) {
1483 getPairData(context.review.tagValueList,
1491 if (extension != NULL) {
1492 context.stepCallback = displayAliasFullValue;
1493 context.review.currentTagValueIndex = pairIndex;
1494 forcedType = FORCE_BUTTON;
1497 if (isCenteredInfo) {
1498 forcedType = FORCE_CENTERED_INFO;
1503 drawStep(
pos, icon, text, subText, nbMaxLines, reviewCallback,
false, forcedType,
false);
1510 const char *text = NULL;
1511 const char *subText = NULL;
1513 uint8_t reviewPages = 0;
1514 uint8_t titleIndex = 255;
1515 uint8_t subIndex = 255;
1517 ForcedType_t forcedType = NO_FORCED_TYPE;
1518 uint8_t nbMaxLines = 0;
1520 context.stepCallback = NULL;
1521 switch (context.type) {
1522 case STREAMING_START_REVIEW_USE_CASE:
1524 titleIndex = reviewPages++;
1525 if (context.review.reviewSubTitle) {
1527 subIndex = reviewPages++;
1530 if (context.currentPage >= reviewPages) {
1535 if (context.currentPage == titleIndex) {
1537 icon = context.review.icon;
1538 text = context.review.reviewTitle;
1540 else if (context.currentPage == subIndex) {
1542 text = context.review.reviewSubTitle;
1546 case STREAMING_CONTINUE_REVIEW_USE_CASE:
1547 if (context.currentPage >= context.review.tagValueList->nbPairs) {
1554 if ((context.review.skipCallback != NULL) && (context.review.skipDisplay ==
false)
1555 && ((context.review.nbDataSets > 1) || (context.currentPage > 0)
1559 if ((context.review.nbDataSets == 1) || (context.currentPage > 0)) {
1562 info.
icon = &C_Information_circle_14px;
1563 info.
text1 =
"Press right button to continue message or \bpress both to skip\b";
1566 context.review.skipDisplay =
true;
1569 context.review.skipDisplay =
false;
1570 bool isCenteredInfo =
false;
1571 getPairData(context.review.tagValueList,
1572 context.currentPage,
1579 if (extension != NULL) {
1582 context.stepCallback = displayAliasFullValue;
1583 context.review.currentTagValueIndex = context.currentPage;
1584 forcedType = FORCE_BUTTON;
1587 if (isCenteredInfo) {
1588 forcedType = FORCE_CENTERED_INFO;
1593 case STREAMING_FINISH_REVIEW_USE_CASE:
1595 if (context.currentPage == 0) {
1597 getLastPageInfo(
true, &icon, &text);
1601 getLastPageInfo(
false, &icon, &text);
1607 pos, icon, text, subText, nbMaxLines, streamingReviewCallback,
false, forcedType,
false);
1614 const char *text = NULL;
1615 const char *subText = NULL;
1618 context.stepCallback = NULL;
1620 if (context.currentPage < (context.nbPages - 1)) {
1622 ((
const char *
const *) PIC(context.home.infosList->infoTypes))[context.currentPage]);
1624 ((
const char *
const *) PIC(context.home.infosList->infoContents))[context.currentPage]);
1627 icon = &C_icon_back_x;
1629 context.stepCallback = startUseCaseHome;
1632 drawStep(
pos, icon, text, subText, 0, infoCallback,
false, FORCE_CENTERED_INFO,
false);
1637static void getContentPage(
bool toogle_state, PageContent_t *contentPage)
1639 uint8_t elemIdx = 0;
1644 char **names = NULL;
1646 char **texts = NULL;
1647 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
1648 if (p_content == NULL) {
1650 "getContentPage(): p_content is NULL for page %d\n",
1651 context.currentPage);
1654 switch (p_content->
type) {
1671 &contentPage->subText,
1672 &contentPage->extension,
1674 &contentPage->isCenteredInfo,
1675 &contentPage->nbMaxLinesForSubText);
1678 if (elemIdx < p_content->content.tagValueConfirm.tagValueList.nbPairs) {
1682 &contentPage->subText,
1683 &contentPage->extension,
1685 &contentPage->isCenteredInfo,
1686 &contentPage->nbMaxLinesForSubText);
1690 contentPage->icon = &C_icon_validate_14;
1691 contentPage->isAction =
true;
1695 contentPage->isSwitch =
true;
1698 contentPage->
text = contentSwitch->
text;
1699 contentPage->state = contentSwitch->
initState;
1703 context.stepCallback = onSwitchAction;
1704 contentPage->subText = contentSwitch->
subText;
1709 contentPage->subText
1718 if (contentChoices->vertical) {
1721 names = (
char **) PIC(contentChoices->
names);
1724 if (contentChoices->title != NULL) {
1725 contentPage->text = PIC(contentChoices->title);
1726 contentPage->subText = (
const char *) PIC(names[elemIdx]);
1728 else if ((context.type == CONTENT_USE_CASE) && (context.content.title != NULL)) {
1729 contentPage->text = PIC(context.content.title);
1730 contentPage->subText = (
const char *) PIC(names[elemIdx]);
1732 else if (((context.type == GENERIC_SETTINGS) || (context.type == SETTINGS_USE_CASE))
1733 && (context.home.appName != NULL)) {
1740 contentPage->text = PIC(context.home.appName);
1741 contentPage->subText = (
const char *) PIC(names[elemIdx]);
1744 contentPage->text = (
const char *) PIC(names[elemIdx]);
1750 if ((contentChoices->selectionIcon != NULL)
1751 && (elemIdx == contentChoices->
initChoice)) {
1752 contentPage->icon = PIC(contentChoices->selectionIcon);
1753 contentPage->bottomIcon =
true;
1758 if (contentBars->vertical) {
1761 texts = (
char **) PIC(contentBars->
barTexts);
1764 if (contentBars->title != NULL) {
1765 contentPage->text = PIC(contentBars->title);
1766 contentPage->subText = PIC(texts[elemIdx]);
1768 else if ((context.type == CONTENT_USE_CASE) && (context.content.title != NULL)) {
1769 contentPage->text = PIC(context.content.title);
1770 contentPage->subText = PIC(texts[elemIdx]);
1772 else if ((context.type == GENERIC_SETTINGS) && (context.home.appName != NULL)) {
1773 contentPage->text = PIC(context.home.appName);
1774 contentPage->subText = PIC(texts[elemIdx]);
1777 contentPage->text = PIC(texts[elemIdx]);
1785 contentPage->icon = &C_icon_down;
1786 contentPage->bottomIcon =
true;
1796 PageContent_t contentPage = {0};
1798 context.stepCallback = NULL;
1800 if (context.currentPage < (context.nbPages - 1)) {
1801 getContentPage(toogle_state, &contentPage);
1804 contentPage.icon = &C_icon_back_x;
1805 contentPage.text =
"Back";
1806 if (context.type == GENERIC_SETTINGS) {
1807 context.stepCallback = context.home.quitCallback;
1810 context.stepCallback = startUseCaseHome;
1814 if (contentPage.isSwitch) {
1816 pos, contentPage.text, contentPage.subText, contentPage.state, settingsCallback,
false);
1822 contentPage.subText,
1823 contentPage.nbMaxLinesForSubText,
1827 contentPage.bottomIcon);
1833static void startUseCaseHome(
void)
1835 switch (context.type) {
1836 case SETTINGS_USE_CASE:
1838 context.currentPage = 1;
1839 if (context.home.homeAction) {
1841 context.currentPage++;
1846 context.currentPage = 1;
1847 if (context.home.homeAction) {
1849 context.currentPage++;
1851 if (context.home.settingContents) {
1853 context.currentPage++;
1858 context.currentPage = 0;
1862 context.type = HOME_USE_CASE;
1863 context.nbPages = 2;
1864 if (context.home.settingContents) {
1867 if (context.home.infosList) {
1870 if (context.home.homeAction) {
1876static void startUseCaseInfo(
void)
1878 context.type = INFO_USE_CASE;
1879 context.nbPages = context.home.infosList->nbInfos + 1;
1880 context.currentPage = 0;
1885static void startUseCaseSettingsAtPage(uint8_t initSettingPage)
1891 if (context.type != GENERIC_SETTINGS) {
1892 context.type = SETTINGS_USE_CASE;
1895 uint16_t nbPages = 1;
1896 for (
unsigned int i = 0; i < context.home.settingContents->nbContents; i++) {
1897 p_content = getContentAtIdx(context.home.settingContents, i, &content);
1898 nbPages += getContentNbElement(p_content);
1899 if (nbPages > UINT8_MAX) {
1900 if (context.type == SETTINGS_USE_CASE) {
1903 else if (context.home.quitCallback != NULL) {
1904 context.home.quitCallback();
1909 context.nbPages = (uint8_t) nbPages;
1910 context.currentPage = initSettingPage;
1915static void startUseCaseSettings(
void)
1917 startUseCaseSettingsAtPage(0);
1920static void startUseCaseContent(
void)
1922 uint8_t contentIdx = 0;
1926 uint16_t nbPages = 1;
1928 for (contentIdx = 0; contentIdx < context.content.genericContents.nbContents; contentIdx++) {
1929 p_content = getContentAtIdx(&context.content.genericContents, contentIdx, &content);
1930 nbPages += getContentNbElement(p_content);
1931 if ((nbPages > UINT8_MAX) || !isContentComplete(p_content)) {
1932 if (context.content.quitCallback != NULL) {
1933 context.content.quitCallback();
1938 context.nbPages = (uint8_t) nbPages;
1941 if (context.currentPage >= context.nbPages) {
1951 const char *text = NULL;
1952 const char *subText = NULL;
1954 uint8_t currentIndex = 0;
1955 uint8_t homeIndex = 255;
1956 uint8_t actionIndex = 255;
1957 uint8_t settingsIndex = 255;
1958 uint8_t infoIndex = 255;
1960 context.stepCallback = NULL;
1963 homeIndex = currentIndex++;
1964 if (context.home.homeAction) {
1965 actionIndex = currentIndex++;
1967 if (context.home.settingContents) {
1968 settingsIndex = currentIndex++;
1970 if (context.home.infosList) {
1971 infoIndex = currentIndex++;
1974 if (context.currentPage == homeIndex) {
1976 icon = context.home.appIcon;
1977 if (context.home.tagline != NULL) {
1978 text = context.home.tagline;
1981 text = context.home.appName;
1982 subText =
"app is ready";
1985 else if (context.currentPage == actionIndex) {
1987 icon = context.home.homeAction->icon;
1988 text = PIC(context.home.homeAction->text);
1989 context.stepCallback = context.home.homeAction->callback;
1991 else if (context.currentPage == settingsIndex) {
1993 icon = &C_icon_coggle;
1994 text =
"App settings";
1995 context.stepCallback = startUseCaseSettings;
1997 else if (context.currentPage == infoIndex) {
1999 icon = &C_Information_circle_14px;
2001 context.stepCallback = startUseCaseInfo;
2004 icon = &C_Quit_14px;
2006 context.stepCallback = context.home.quitCallback;
2009 drawStep(
pos, icon, text, subText, 0, homeCallback,
false, NO_FORCED_TYPE,
false);
2022static uint8_t getChoiceNbIntroPages(
void)
2024 uint8_t nbPages = 0;
2027 if ((context.choice.title == NULL) && (context.choice.message == NULL)) {
2030 if (context.choice.icon != NULL) {
2033 if ((context.choice.title != NULL) && (context.choice.message != NULL)) {
2036 if (context.choice.subMessage != NULL) {
2040 return (nbPages > 0) ? nbPages : 1;
2045static const char *getChoiceIntroSubText(uint8_t page)
2050 uint8_t elemPage = 0;
2052 if (context.choice.icon != NULL) {
2053 if (page == elemPage) {
2059 if ((context.choice.title != NULL) && (context.choice.message != NULL)) {
2061 if (page == elemPage) {
2062 return context.choice.message;
2067 return (page == elemPage) ? context.choice.subMessage : NULL;
2073 const char *text = NULL;
2074 const char *subText = NULL;
2077 uint8_t acceptPage = getChoiceNbIntroPages();
2080 uint8_t nbDetailPages = 0;
2082 if ((context.choice.details != NULL) && (context.choice.details->type ==
BAR_LIST_WARNING)) {
2083 nbDetailPages = context.choice.details->barList.nbBars;
2085 context.stepCallback = NULL;
2087 if (context.currentPage < acceptPage) {
2090 text = (context.choice.title != NULL) ? context.choice.title : context.choice.message;
2091 if (context.currentPage == 0) {
2092 icon = context.choice.icon;
2094 subText = getChoiceIntroSubText(context.currentPage);
2096 else if (context.currentPage < (acceptPage + nbDetailPages)) {
2098 uint8_t idx = context.currentPage - acceptPage;
2099 text = (context.choice.details->barList.texts != NULL)
2100 ? context.choice.details->barList.texts[idx]
2102 subText = (context.choice.details->barList.subTexts != NULL)
2103 ? context.choice.details->barList.subTexts[idx]
2106 else if (context.currentPage == (acceptPage + nbDetailPages)) {
2107 icon = &C_icon_validate_14;
2108 text = context.choice.confirmText;
2109 context.stepCallback = onChoiceAccept;
2112 icon = &C_icon_crossmark;
2113 text = context.choice.cancelText;
2114 context.stepCallback = onChoiceReject;
2118 drawStep(
pos, icon, text, subText, 0, genericChoiceCallback,
false, NO_FORCED_TYPE,
false);
2125 const char *text = NULL;
2126 const char *subText = NULL;
2129 context.stepCallback = NULL;
2130 switch (context.currentPage) {
2133 text = context.confirm.message;
2134 subText = context.confirm.subMessage;
2138 icon = &C_icon_validate_14;
2139 text = context.confirm.confirmText;
2140 context.stepCallback = onConfirmAccept;
2144 icon = &C_icon_crossmark;
2145 text = context.confirm.cancelText;
2146 context.stepCallback = onConfirmReject;
2150 drawStep(
pos, icon, text, subText, 0, genericConfirmCallback,
true, NO_FORCED_TYPE,
false);
2157 PageContent_t contentPage = {0};
2158 ForcedType_t forcedType = NO_FORCED_TYPE;
2160 context.stepCallback = NULL;
2162 if (context.currentPage < (context.nbPages - 1)) {
2163 getContentPage(toogle_state, &contentPage);
2164 if (contentPage.isCenteredInfo) {
2165 forcedType = FORCE_CENTERED_INFO;
2167 context.forceAction = contentPage.isAction;
2170 if (context.content.rejectText) {
2171 contentPage.text = context.content.rejectText;
2174 contentPage.text =
"Back";
2176 if (context.type == GENERIC_REVIEW_USE_CASE) {
2177 contentPage.icon = &C_icon_crossmark;
2180 contentPage.icon = &C_icon_back_x;
2182 context.stepCallback = context.content.quitCallback;
2185 if (contentPage.isSwitch) {
2187 pos, contentPage.text, contentPage.subText, contentPage.state, contentCallback,
false);
2193 contentPage.subText,
2194 contentPage.nbMaxLinesForSubText,
2198 contentPage.bottomIcon);
2200 context.forceAction =
false;
2204static void displaySpinner(
const char *text)
2206 drawStep(
SINGLE_STEP, &C_icon_processing, text, NULL, 0, NULL,
false, NO_FORCED_TYPE,
false);
2211static void useCaseReview(ContextType_t type,
2215 const char *reviewTitle,
2216 const char *reviewSubTitle,
2217 const char *finishTitle,
2220 memset(&context, 0,
sizeof(UseCaseContext_t));
2221 context.type = type;
2222 context.operationType = operationType;
2223 context.review.tagValueList = tagValueList;
2224 context.review.reviewTitle = reviewTitle;
2225 context.review.reviewSubTitle = reviewSubTitle;
2226 context.review.finishTitle = finishTitle;
2227 context.review.icon = icon;
2228 context.review.onChoice = choiceCallback;
2229 context.currentPage = 0;
2230 if (tagValueList == NULL) {
2235 uint16_t nbPages = (uint16_t) tagValueList->
nbPairs + 3;
2236 if (reviewSubTitle) {
2239 if ((nbPages <= UINT8_MAX) && isTagValueListComplete(tagValueList)) {
2240 context.nbPages = (uint8_t) nbPages;
2249static void setPinCodeText(
void)
2251 bool enableValidate =
false;
2252 bool enableBackspace =
true;
2255 enableValidate = (context.keypad.pinLen >= context.keypad.pinMinDigits);
2257 enableBackspace = (context.keypad.pinLen > 0) || (context.keypad.backCallback != NULL);
2259 context.keypad.hidden,
2260 context.keypad.pinLen,
2261 (
const char *) context.keypad.pinEntry);
2263 context.keypad.layoutCtx, context.keypad.keypadIndex, enableValidate, enableBackspace);
2269static void keypadCallback(
char touchedKey)
2271 switch (touchedKey) {
2273 if (context.keypad.pinLen > 0) {
2274 context.keypad.pinLen--;
2275 context.keypad.pinEntry[context.keypad.pinLen] = 0;
2277 else if (context.keypad.backCallback != NULL) {
2278 context.keypad.backCallback();
2285 context.keypad.validatePin(context.keypad.pinEntry, context.keypad.pinLen);
2289 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
2290 if (context.keypad.pinLen < context.keypad.pinMaxDigits) {
2291 context.keypad.pinEntry[context.keypad.pinLen] = touchedKey;
2292 context.keypad.pinLen++;
2305 const char **buttons;
2306 int firstButtonToken;
2307 uint8_t nbUsedButtons;
2310 char title[KEYBOARD_MAX_TITLE];
2311} savedKeyboardContext;
2326static void displaySuggestionSelection(
void)
2329 savedKeyboardContext.buttons = context.keyboard.content.suggestionButtons.buttons;
2330 savedKeyboardContext.firstButtonToken
2331 = context.keyboard.content.suggestionButtons.firstButtonToken;
2332 savedKeyboardContext.nbUsedButtons = context.keyboard.content.suggestionButtons.nbUsedButtons;
2333 savedKeyboardContext.onButtonCallback = context.keyboard.onButtonCallback;
2334 savedKeyboardContext.backCallback = context.keyboard.backCallback;
2338 context.keyboard.layoutCtx = NULL;
2340 snprintf(savedKeyboardContext.title,
2341 sizeof(savedKeyboardContext.title),
2343 context.keyboard.content.number);
2347 savedKeyboardContext.backCallback,
2348 suggestionNavCallback,
2349 savedKeyboardContext.onButtonCallback);
2353static void keyboardCallback(
char touchedKey)
2356 size_t textLen = strlen(context.keyboard.entryBuffer);
2357 PRINTF(
"[keyboardCallback] touchedKey: '%c'\n", touchedKey);
2361 context.keyboard.backCallback();
2364 context.keyboard.entryBuffer[--textLen] =
'\0';
2367 context.keyboard.actionCallback();
2370 else if (textLen < context.keyboard.entryMaxLen) {
2373 context.keyboard.entryBuffer[textLen] = touchedKey;
2374 context.keyboard.entryBuffer[++textLen] =
'\0';
2379 context.keyboard.getSuggestButtons(&context.keyboard.content, &mask);
2381 = &context.keyboard.content.suggestionButtons;
2388 bool allCandidatesFit;
2390 allCandidatesFit = (suggestions->
nbCandidates <= NB_MAX_SUGGESTION_BUTTONS);
2393 allCandidatesFit = (suggestions->
nbUsedButtons < NB_MAX_SUGGESTION_BUTTONS);
2396 displaySuggestionSelection();
2400 if (textLen >= context.keyboard.entryMaxLen) {
2405 nbgl_layoutUpdateEnteredText(
2406 context.keyboard.layoutCtx, context.keyboard.textIndex, context.keyboard.entryBuffer);
2412static void launchReviewAfterWarning(
void)
2414 if (reviewWithWarnCtx.type == REVIEW_USE_CASE) {
2415 useCaseReview(reviewWithWarnCtx.type,
2416 reviewWithWarnCtx.operationType,
2417 reviewWithWarnCtx.tagValueList,
2418 reviewWithWarnCtx.icon,
2419 reviewWithWarnCtx.reviewTitle,
2420 reviewWithWarnCtx.reviewSubTitle,
2421 reviewWithWarnCtx.finishTitle,
2422 reviewWithWarnCtx.choiceCallback);
2424 else if (reviewWithWarnCtx.type == STREAMING_START_REVIEW_USE_CASE) {
2434 displayWarningStep();
2439static void displayBarDetailStep(
void)
2442 = &reviewWithWarnCtx.warning->introDetails->barList.details[reviewWithWarnCtx.barDetailIdx];
2449 info.
style = BOLD_TEXT1_INFO;
2465 if (reviewWithWarnCtx.warningPage > 0) {
2466 reviewWithWarnCtx.warningPage--;
2471 if (reviewWithWarnCtx.warningPage < (reviewWithWarnCtx.nbWarningPages - 1)) {
2472 reviewWithWarnCtx.warningPage++;
2474 else if ((reviewWithWarnCtx.warning->predefinedSet == 0)
2475 && (reviewWithWarnCtx.warning->info != NULL)) {
2476 launchReviewAfterWarning();
2483 if (reviewWithWarnCtx.warningPage == reviewWithWarnCtx.firstWarningPage) {
2484 launchReviewAfterWarning();
2487 else if (reviewWithWarnCtx.warningPage == (reviewWithWarnCtx.nbWarningPages - 1)) {
2488 reviewWithWarnCtx.choiceCallback(
false);
2492 else if ((event ==
BUTTON_BOTH_PRESSED) && (reviewWithWarnCtx.warning->introDetails != NULL)
2494 && (reviewWithWarnCtx.warningPage > reviewWithWarnCtx.firstWarningPage)) {
2496 barIdx = reviewWithWarnCtx.warningPage - reviewWithWarnCtx.firstWarningPage - 1;
2497 if ((reviewWithWarnCtx.warning->introDetails->barList.details != NULL)
2498 && (reviewWithWarnCtx.warning->introDetails->barList.details[barIdx].type
2500 reviewWithWarnCtx.barDetailIdx = barIdx;
2501 displayBarDetailStep();
2508 displayWarningStep();
2512static void displayWarningStep(
void)
2517 if ((reviewWithWarnCtx.warning->prelude) && (reviewWithWarnCtx.warningPage == 0)) {
2522 reviewWithWarnCtx.warning->prelude->title,
2523 reviewWithWarnCtx.warning->prelude->description,
2530 if (reviewWithWarnCtx.warningPage == reviewWithWarnCtx.firstWarningPage) {
2532 info.
icon = &C_icon_warning;
2533 info.
text1 =
"Blind signing ahead";
2534 info.
text2 =
"To accept risk, press both buttons";
2535 pos = (reviewWithWarnCtx.firstWarningPage == 0) ?
FIRST_STEP
2539 else if (reviewWithWarnCtx.warningPage == (reviewWithWarnCtx.nbWarningPages - 1)) {
2540 getLastPageInfo(
false, &info.
icon, &info.
text1);
2544 else if ((reviewWithWarnCtx.warning->predefinedSet == 0)
2545 && (reviewWithWarnCtx.warning->info != NULL)) {
2546 if (reviewWithWarnCtx.warningPage == reviewWithWarnCtx.firstWarningPage) {
2547 info.
icon = reviewWithWarnCtx.warning->info->icon;
2548 info.
text1 = reviewWithWarnCtx.warning->info->title;
2549 info.
text2 = reviewWithWarnCtx.warning->info->description;
2550 pos = (reviewWithWarnCtx.firstWarningPage == 0) ?
FIRST_STEP
2554 else if ((reviewWithWarnCtx.warning->introDetails != NULL)
2557 barIdx = reviewWithWarnCtx.warningPage - reviewWithWarnCtx.firstWarningPage - 1;
2558 if (reviewWithWarnCtx.warning->introDetails->barList.icons) {
2559 info.
icon = reviewWithWarnCtx.warning->introDetails->barList.icons[barIdx];
2561 info.
text1 = reviewWithWarnCtx.warning->introDetails->barList.texts[barIdx];
2562 if (reviewWithWarnCtx.warning->introDetails->barList.subTexts) {
2563 info.
text2 = reviewWithWarnCtx.warning->introDetails->barList.subTexts[barIdx];
2567 else if (reviewWithWarnCtx.warningPage == (reviewWithWarnCtx.nbWarningPages - 1)) {
2568 if ((reviewWithWarnCtx.warning->introDetails != NULL)
2570 info.
icon = reviewWithWarnCtx.warning->introDetails->centeredInfo.icon;
2571 info.
text1 = reviewWithWarnCtx.warning->introDetails->centeredInfo.title;
2572 info.
text2 = reviewWithWarnCtx.warning->introDetails->centeredInfo.description;
2585 info.
style = BOLD_TEXT1_INFO;
2591static void displayInitialWarning(
void)
2594 reviewWithWarnCtx.warningPage = 0;
2596 || ((reviewWithWarnCtx.warning->introDetails)
2598 reviewWithWarnCtx.nbWarningPages = 2;
2600 else if ((reviewWithWarnCtx.warning->introDetails)
2602 reviewWithWarnCtx.nbWarningPages
2603 = reviewWithWarnCtx.warning->introDetails->barList.nbBars + 1;
2607 reviewWithWarnCtx.nbWarningPages = 1;
2610 reviewWithWarnCtx.firstWarningPage = 0;
2611 displayWarningStep();
2615static void displayPrelude(
void)
2618 reviewWithWarnCtx.warningPage = 0;
2620 || ((reviewWithWarnCtx.warning->introDetails)
2622 reviewWithWarnCtx.nbWarningPages = 3;
2626 reviewWithWarnCtx.nbWarningPages = 2;
2628 reviewWithWarnCtx.firstWarningPage = 1;
2629 displayWarningStep();
2642 memcpy(&normalizedWarning, warning,
sizeof(normalizedWarning));
2644 return &normalizedWarning;
2665 bool *requireSpecificDisplay)
2668 UNUSED(tagValueList);
2670 *requireSpecificDisplay =
true;
2688 UNUSED(choicesList);
2714 memset(&context, 0,
sizeof(UseCaseContext_t));
2715 context.type = CONTENT_USE_CASE;
2716 context.currentPage = initPage;
2717 context.content.title = title;
2718 context.content.quitCallback = quitCallback;
2719 context.content.navCallback = navCallback;
2720 context.content.controlsCallback = controlsCallback;
2721 context.content.genericContents.callbackCallNeeded =
true;
2722 context.content.genericContents.nbContents = nbPages;
2724 startUseCaseContent();
2743 const char *tagline,
2744 const uint8_t initSettingPage,
2750 memset(&context, 0,
sizeof(UseCaseContext_t));
2751 context.home.appName = appName;
2752 context.home.appIcon = appIcon;
2753 context.home.tagline = tagline;
2754 context.home.settingContents = PIC(settingContents);
2755 context.home.infosList = PIC(infosList);
2756 context.home.homeAction = action;
2757 context.home.quitCallback = quitCallback;
2759 if ((initSettingPage !=
INIT_HOME_PAGE) && (settingContents != NULL)) {
2760 startUseCaseSettingsAtPage(initSettingPage);
2779 if (context.type != HOME_USE_CASE) {
2782 if (context.home.settingContents != NULL) {
2783 startUseCaseSettingsAtPage(initPage);
2785 else if (context.home.infosList != NULL) {
2812 memset(&context, 0,
sizeof(UseCaseContext_t));
2813 context.type = GENERIC_SETTINGS;
2814 context.home.appName = appName;
2815 context.home.settingContents = PIC(settingContents);
2816 context.home.infosList = PIC(infosList);
2817 context.home.quitCallback = quitCallback;
2819 startUseCaseSettingsAtPage(initPage);
2858 const char *reviewTitle,
2859 const char *reviewSubTitle,
2860 const char *finishTitle,
2863 useCaseReview(REVIEW_USE_CASE,
2898 const char *reviewTitle,
2899 const char *reviewSubTitle,
2900 const char *finishTitle,
2906 ContextType_t type = REVIEW_USE_CASE;
2909 if ((warning == NULL)
2929 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
2930 reviewWithWarnCtx.type = type;
2931 reviewWithWarnCtx.operationType = operationType;
2932 reviewWithWarnCtx.tagValueList = tagValueList;
2933 reviewWithWarnCtx.icon = icon;
2934 reviewWithWarnCtx.reviewTitle = reviewTitle;
2935 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
2936 reviewWithWarnCtx.finishTitle = finishTitle;
2937 reviewWithWarnCtx.warning = normalizeWarning(warning);
2938 reviewWithWarnCtx.choiceCallback = choiceCallback;
2940 if (!isWarningSupported(reviewWithWarnCtx.warning)) {
2941 choiceCallback(
false);
2945 if (reviewWithWarnCtx.warning->prelude) {
2950 displayInitialWarning();
2986 const char *reviewTitle,
2987 const char *reviewSubTitle,
2988 const char *finishTitle,
2999 &blindSigningWarning,
3020 const char *reviewTitle,
3021 const char *reviewSubTitle,
3022 const char *finishTitle,
3053 const char *reviewTitle,
3054 const char *reviewSubTitle,
3057 memset(&context, 0,
sizeof(UseCaseContext_t));
3058 context.type = ADDRESS_REVIEW_USE_CASE;
3059 context.review.address = address;
3060 context.review.reviewTitle = reviewTitle;
3061 context.review.reviewSubTitle = reviewSubTitle;
3062 context.review.icon = icon;
3063 context.review.onChoice = choiceCallback;
3064 context.currentPage = 0;
3067 uint16_t nbPages = reviewSubTitle ? 5 : 4;
3068 if (additionalTagValueList) {
3069 context.review.tagValueList = PIC(additionalTagValueList);
3070 nbPages += additionalTagValueList->
nbPairs;
3071 if (!isTagValueListComplete(additionalTagValueList)) {
3072 nbPages = UINT8_MAX + 1;
3076 if (nbPages <= UINT8_MAX) {
3077 context.nbPages = (uint8_t) nbPages;
3094 const char *rejectText,
3097 memset(&context, 0,
sizeof(UseCaseContext_t));
3098 context.type = GENERIC_REVIEW_USE_CASE;
3099 context.content.rejectText = rejectText;
3100 context.content.quitCallback = rejectCallback;
3101 context.content.genericContents.nbContents = contents->
nbContents;
3107 context.content.genericContents.contentsList = PIC(contents->
contentsList);
3110 startUseCaseContent();
3124 memset(&context, 0,
sizeof(UseCaseContext_t));
3125 context.type = STATUS_USE_CASE;
3126 context.stepCallback = quitCallback;
3127 context.currentPage = 0;
3128 context.nbPages = 1;
3135 statusButtonCallback,
3152 switch (reviewStatusType) {
3154 msg =
"Operation signed";
3158 msg =
"Operation rejected";
3162 msg =
"Transaction signed";
3166 msg =
"Transaction rejected";
3170 msg =
"Message signed";
3174 msg =
"Message rejected";
3178 msg =
"Address verified";
3182 msg =
"Address verification cancelled";
3205 const char *reviewTitle,
3206 const char *reviewSubTitle,
3210 streamingOpType = operationType;
3212 memset(&context, 0,
sizeof(UseCaseContext_t));
3213 context.type = STREAMING_START_REVIEW_USE_CASE;
3214 context.operationType = operationType;
3215 context.review.reviewTitle = reviewTitle;
3216 context.review.reviewSubTitle = reviewSubTitle;
3217 context.review.icon = icon;
3218 context.review.onChoice = choiceCallback;
3219 context.currentPage = 0;
3220 context.nbPages = reviewSubTitle ? 3 : 2;
3240 const char *reviewTitle,
3241 const char *reviewSubTitle,
3245 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
3265 const char *reviewTitle,
3266 const char *reviewSubTitle,
3270 memset(&context, 0,
sizeof(UseCaseContext_t));
3271 context.type = STREAMING_START_REVIEW_USE_CASE;
3272 context.operationType = operationType;
3273 context.review.reviewTitle = reviewTitle;
3274 context.review.reviewSubTitle = reviewSubTitle;
3275 context.review.icon = icon;
3276 context.review.onChoice = choiceCallback;
3277 context.currentPage = 0;
3278 context.nbPages = reviewSubTitle ? 3 : 2;
3281 streamingOpType = operationType;
3284 if ((warning == NULL)
3296 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
3298 reviewWithWarnCtx.type = context.type;
3299 reviewWithWarnCtx.operationType = operationType;
3300 reviewWithWarnCtx.icon = icon;
3301 reviewWithWarnCtx.reviewTitle = reviewTitle;
3302 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
3303 reviewWithWarnCtx.choiceCallback = choiceCallback;
3304 reviewWithWarnCtx.warning = normalizeWarning(warning);
3306 if (!isWarningSupported(reviewWithWarnCtx.warning)) {
3307 choiceCallback(
false);
3311 if (reviewWithWarnCtx.warning->prelude) {
3316 displayInitialWarning();
3340 uint8_t curNbDataSets = context.review.nbDataSets;
3342 memset(&context, 0,
sizeof(UseCaseContext_t));
3343 context.type = STREAMING_CONTINUE_REVIEW_USE_CASE;
3344 context.operationType = streamingOpType;
3345 context.review.tagValueList = tagValueList;
3346 context.review.onChoice = choiceCallback;
3347 context.currentPage = 0;
3348 context.review.skipCallback = skipCallback;
3349 context.review.nbDataSets = curNbDataSets + 1;
3351 if (tagValueList == NULL) {
3355 uint16_t nbPages = (uint16_t) tagValueList->
nbPairs + 1;
3356 if ((nbPages <= UINT8_MAX) && isTagValueListComplete(tagValueList)) {
3357 context.nbPages = (uint8_t) nbPages;
3384 memset(&context, 0,
sizeof(UseCaseContext_t));
3385 context.type = STREAMING_FINISH_REVIEW_USE_CASE;
3386 context.operationType = streamingOpType;
3387 context.review.onChoice = choiceCallback;
3388 context.review.finishTitle = finishTitle;
3389 context.currentPage = 0;
3390 context.nbPages = 2;
3402 memset(&context, 0,
sizeof(UseCaseContext_t));
3403 context.type = SPINNER_USE_CASE;
3404 context.currentPage = 0;
3405 context.nbPages = 1;
3407 displaySpinner(text);
3423 const char *message,
3424 const char *subMessage,
3425 const char *confirmText,
3426 const char *cancelText,
3430 icon, message, subMessage, confirmText, cancelText, NULL, callback);
3437 const char *message,
3438 const char *subMessage,
3439 const char *confirmText,
3440 const char *cancelText,
3444 memset(&context, 0,
sizeof(UseCaseContext_t));
3445 context.type = CHOICE_USE_CASE;
3446 context.choice.icon = icon;
3447 context.choice.title = title;
3448 context.choice.message = message;
3449 context.choice.subMessage = subMessage;
3450 context.choice.confirmText = confirmText;
3451 context.choice.cancelText = cancelText;
3452 context.choice.onChoice = callback;
3453 context.choice.details = details;
3454 context.currentPage = 0;
3455 uint16_t nbPages = 2 + getChoiceNbIntroPages();
3456 if (details != NULL) {
3463 if (nbPages <= UINT8_MAX) {
3464 context.nbPages = (uint8_t) nbPages;
3487 const char *message,
3488 const char *subMessage,
3489 const char *confirmText,
3490 const char *cancelText,
3494 startChoice(icon, NULL, message, subMessage, confirmText, cancelText, details, callback);
3502 const char *message,
3503 const char *subMessage,
3504 const char *confirmText,
3505 const char *cancelText,
3510 startChoice(centerIcon, title, message, subMessage, confirmText, cancelText, details, callback);
3527 const char *subMessage,
3528 const char *confirmText,
3529 const char *cancelText,
3532 memset(&context, 0,
sizeof(UseCaseContext_t));
3533 context.type = CONFIRM_USE_CASE;
3534 context.confirm.message = message;
3535 context.confirm.subMessage = subMessage;
3536 context.confirm.confirmText = confirmText;
3537 context.confirm.cancelText = cancelText;
3538 context.confirm.onConfirm = callback;
3539 context.currentPage = 0;
3540 context.nbPages = 1 + 2;
3555 const char *message,
3556 const char *actionText,
3564 memset(&context, 0,
sizeof(UseCaseContext_t));
3565 context.type = ACTION_USE_CASE;
3566 context.action.actionCallback = callback;
3568 centeredInfo.
icon = icon;
3569 centeredInfo.
text1 = message;
3570 centeredInfo.
style = BOLD_TEXT1_INFO;
3606 "nbgl_useCaseKeypad(): digits out of range (%d/%d > %d)\n",
3614 memset(&context, 0,
sizeof(UseCaseContext_t));
3615 context.type = KEYPAD_USE_CASE;
3616 context.currentPage = 0;
3617 context.nbPages = 1;
3618 context.keypad.validatePin = validatePinCallback;
3619 context.keypad.backCallback = backCallback;
3620 context.keypad.pinMinDigits = minDigits;
3621 context.keypad.pinMaxDigits = maxDigits;
3622 context.keypad.hidden = hidden;
3629 USE_CASE_LOGGER,
"nbgl_useCaseKeypad(): layout setup failed (status=%d)\n", status);
3632 context.keypad.keypadIndex = status;
3637 USE_CASE_LOGGER,
"nbgl_useCaseKeypad(): layout setup failed (status=%d)\n", status);
3642 if (context.keypad.backCallback != NULL) {
3684 .mode = params->
mode,
3696 memset(&context, 0,
sizeof(UseCaseContext_t));
3697 context.type = KEYBOARD_USE_CASE;
3698 context.currentPage = 0;
3699 context.nbPages = 1;
3700 context.keyboard.entryBuffer = PIC(params->
entryBuffer);
3701 context.keyboard.entryMaxLen = params->
entryMaxLen;
3702 context.keyboard.entryBuffer[0] =
'\0';
3704 context.keyboard.content.type = params->
type;
3707 context.keyboard.backCallback = PIC(backCallback);
3709 switch (params->
type) {
3716 context.keyboard.getSuggestButtons
3738 USE_CASE_LOGGER,
"nbgl_useCaseKeyboard(): layout setup failed (status=%d)\n", status);
3741 context.keyboard.keyboardIndex = status;
3744 status = nbgl_layoutAddEnteredText(context.keyboard.layoutCtx,
"",
true);
3747 USE_CASE_LOGGER,
"nbgl_useCaseKeyboard(): layout setup failed (status=%d)\n", status);
3750 context.keyboard.textIndex = status;
3752 nbgl_layoutAddNavigation(context.keyboard.layoutCtx, &navInfo);
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
struct nbgl_contentTagValueList_s nbgl_contentTagValueList_t
This structure contains a list of [tag,value] pairs.
@ CHOICES_LIST
list of choices through radio buttons
@ CENTERED_INFO
a centered info
@ SWITCHES_LIST
list of switches with descriptions
@ 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
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
struct nbgl_contentInfoList_s nbgl_contentInfoList_t
This structure contains data to build a INFOS_LIST content.
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
void(* nbgl_stepCallback_t)(void)
prototype of function to be called when a step is using a callback on "double-key" action
struct nbgl_pageContent_s nbgl_pageContent_t
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent).
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.
@ HORIZONTAL_NAV
'<' and '>' are displayed, to navigate between pages and steps
@ LEFT_ARROW
left arrow is used
@ RIGHT_ARROW
right arrow is used
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_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...
nbgl_contentSwitch_t nbgl_layoutSwitch_t
Deprecated, kept for retro compatibility.
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
void * nbgl_layout_t
type shared externally
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.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
struct nbgl_layoutDescription_s nbgl_layoutDescription_t
Structure containing all information when creating a layout. This structure must be passed as argumen...
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet().
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_contentCenteredInfo_t nbgl_layoutCenteredInfo_t
Deprecated, kept for retro compatibility.
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
#define KEYPAD_MAX_DIGITS
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
struct PACKED__ nbgl_screenTickerConfiguration_s nbgl_screenTickerConfiguration_t
struct to configure a screen layer
void nbgl_screenRedraw(void)
void(* nbgl_stepButtonCallback_t)(nbgl_step_t stepCtx, nbgl_buttonEvent_t event)
prototype of function to be called when buttons are touched on a screen
#define GET_POS_OF_STEP(_step, _nb_steps)
nbgl_step_t nbgl_stepDrawSwitch(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutSwitch_t *switchInfo, bool modal)
void * nbgl_step_t
type shared externally
uint8_t nbgl_stepPosition_t
this type is a bitfield containing:
@ NEITHER_FIRST_NOR_LAST_STEP
neither first nor last in a multiple steps flow
@ SINGLE_STEP
single step flow
@ LAST_STEP
last in a multiple steps flow
@ FIRST_STEP
first in a multiple steps flow
nbgl_step_t nbgl_stepDrawMenuList(nbgl_stepMenuListCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutMenuList_t *list, bool modal)
#define ACTION_ON_ANY_BUTTON
When action callback applies only on both button press.
int nbgl_stepRelease(nbgl_step_t step)
#define FORWARD_DIRECTION
When the flow is navigated from last to first step.
nbgl_step_t nbgl_stepDrawText(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal)
nbgl_step_t nbgl_stepDrawCenteredInfo(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutCenteredInfo_t *info, bool modal)
#define BACKWARD_DIRECTION
When action callback applies on any button press.
Internal functions of NBGL step layer.
nbgl_step_t stepDrawText(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal, uint8_t nbMaxLinesForSubText)
nbgl_state_t
to represent a boolean state.
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
@ 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
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)
struct nbgl_genericDetails_s nbgl_genericDetails_t
The necessary parameters to build the page(s) displayed when the top-right button is touched in intro...
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)
#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)
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)
bool nbgl_useCaseShowInfoAndSettings(uint8_t initPage)
void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t quitCallback)
@ W3C_THREAT_DETECTED_WARN
Web3 Checks: Threat detected (see reportRisk field).
@ 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).
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)
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_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 ADDRESS_BOOK_OPERATION
This is to use in nbgl_operationType_t when the operation is related to "AddressBook" to adapt wordin...
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 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.
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)
uint8_t nbBars
number of elements in barTexts and tokens array
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 * text2
second text (can be null)
const char * text1
first text (can be null)
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
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
const char *const * infoContents
array of contents of infos (in black)
const char *const * infoTypes
array of types of infos (in black/bold)
uint8_t nbInfos
number of elements in infoTypes and infoContents array
This structure contains a list of names to build a list of radio buttons (on the right part of screen...
uint8_t token
the token that will be used as argument of the callback
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
uint8_t token
the token that will be used as argument of the callback (unused on Nano)
nbgl_state_t initState
initial state of the switch
const char * subText
description under main text (NULL terminated, single line, may be null)
const char * confirmationText
text of the confirmation button, if NULL "It matches" is used
uint8_t confirmationToken
the token used as argument of the onActionCallback
nbgl_contentTagValueList_t tagValueList
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
This structure contains a [tag,value] pair and possible extensions.
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
uint8_t nbMaxLinesForValue
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 ...
nbgl_contentValueAliasType_t aliasType
type of alias
const struct nbgl_contentTagValueList_s * tagValuelist
if aliasType is TAG_VALUE_LIST_ALIAS
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
uint8_t nbBars
number of touchable bars
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
nbgl_genericBarList_t barList
touchable bars list, if type == BAR_LIST_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.
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
nbgl_layoutKeyboardContentType_t type
type of content
const char * title
centered title explaining the screen
char * entryBuffer
already entered text
This structure contains info to build a keyboard with nbgl_layoutAddKeyboard().
This structure contains info to build a navigation bar at the bottom of the screen.
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type
nbgl_contentSwitchesList_t switchesList
SWITCHES_LIST type
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
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
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...
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 * reviewDetails
const nbgl_contentCenter_t * info
parameters to build the intro warning page, if not using pre-defined
nbgl_contentInfoList_t infosList
INFOS_LIST 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_contentSwitchesList_t switchesList
SWITCHES_LIST type
nbgl_contentInfoButton_t infoButton
INFO_BUTTON type
nbgl_contentRadioChoice_t choicesList
CHOICES_LIST type
static nbgl_touchStatePosition_t pos