18#include "os_helpers.h"
24#define WITH_HORIZONTAL_CHOICES_LIST
25#define WITH_HORIZONTAL_BARS_LIST
31typedef struct ReviewContext_s {
35 const char *reviewTitle;
36 const char *reviewSubTitle;
37 const char *finishTitle;
42 uint8_t dataDirection;
43 uint8_t currentTagValueIndex;
44 uint8_t currentExtensionPage;
45 uint8_t nbExtensionPages;
51typedef struct ChoiceContext_s {
54 const char *subMessage;
55 const char *confirmText;
56 const char *cancelText;
61typedef struct ConfirmContext_s {
63 const char *subMessage;
64 const char *confirmText;
65 const char *cancelText;
70typedef struct ContentContext_s {
73 const char *rejectText;
79typedef struct HomeContext_s {
89typedef struct ActionContext_s {
94typedef struct KeypadContext_s {
108typedef struct KeyboardContext_s {
111 uint16_t entryMaxLen;
113 uint8_t keyboardIndex;
126 GENERIC_REVIEW_USE_CASE,
127 ADDRESS_REVIEW_USE_CASE,
128 STREAMING_START_REVIEW_USE_CASE,
129 STREAMING_CONTINUE_REVIEW_USE_CASE,
130 STREAMING_FINISH_REVIEW_USE_CASE,
144typedef struct UseCaseContext_s {
149 uint8_t firstPairPage;
154 ReviewContext_t review;
155 ChoiceContext_t choice;
156 ConfirmContext_t confirm;
158 ContentContext_t content;
160 KeypadContext_t keypad;
163 KeyboardContext_t keyboard;
165 ActionContext_t action;
169typedef struct PageContent_s {
180typedef struct ReviewWithWarningContext_s {
185 const char *reviewTitle;
186 const char *reviewSubTitle;
187 const char *finishTitle;
190 uint8_t securityReportLevel;
193 uint8_t nbWarningPages;
194 uint8_t firstWarningPage;
195 uint8_t barDetailIdx;
196} ReviewWithWarningContext_t;
207static UseCaseContext_t context;
209static ReviewWithWarningContext_t reviewWithWarnCtx;
227static void displaySpinner(
const char *text);
229static void startUseCaseHome(
void);
230static void startUseCaseInfo(
void);
231static void startUseCaseSettings(
void);
232static void startUseCaseSettingsAtPage(uint8_t initSettingPage);
233static void startUseCaseContent(
void);
235static void statusTickerCallback(
void);
238static void displayWarningStep(
void);
243 switch (content->
type) {
273 if (contentIdx >= genericContents->
nbContents) {
279 if (content == NULL) {
285 if (context.content.navCallback) {
286 if (context.content.navCallback(contentIdx, &pageContent) ==
true) {
289 switch (content->
type) {
338 uint8_t *elemContentIdx,
344 uint8_t elemNbPages = 0;
346 switch (context.type) {
347 case SETTINGS_USE_CASE:
349 case GENERIC_SETTINGS:
350 genericContents = context.home.settingContents;
352 case CONTENT_USE_CASE:
353 case GENERIC_REVIEW_USE_CASE:
354 genericContents = &context.content.genericContents;
359 for (uint i = 0; i < genericContents->
nbContents; i++) {
360 p_content = getContentAtIdx(genericContents, i, content);
361 elemNbPages = getContentNbElement(p_content);
362 if (nbPages + elemNbPages > elemIdx) {
363 *elemContentIdx = context.currentPage - nbPages;
366 nbPages += elemNbPages;
372static const char *getChoiceName(uint8_t choiceIndex)
382 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
383 if (p_content == NULL) {
386 switch (p_content->
type) {
389 names = (
char **) PIC(contentChoices->
names);
394 names = (
char **) PIC(contentBars->
barTexts);
395 nbValues = contentBars->
nbBars;
401 if (choiceIndex >= nbValues) {
405 return (
const char *) PIC(names[choiceIndex]);
408static void onChoiceSelected(uint8_t choiceIndex)
417 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
418 if (p_content == NULL) {
421 switch (p_content->
type) {
424 if (choiceIndex < contentChoices->nbChoices) {
425 token = contentChoices->
token;
430 if (choiceIndex < contentBars->nbBars) {
431 token = contentBars->
tokens[choiceIndex];
438 if ((token != 255) && (context.content.controlsCallback != NULL)) {
439 context.content.controlsCallback(token, 0);
441 else if (context.content.quitCallback != NULL) {
442 context.content.quitCallback();
452 bool *isCenteredInfo)
456 if (tagValueList->
pairs != NULL) {
457 pair = PIC(&tagValueList->
pairs[index]);
460 pair = PIC(tagValueList->
callback(index));
463 *value = pair->
value;
468 *isCenteredInfo =
true;
476static void onReviewAccept(
void)
478 if (context.review.onChoice) {
479 context.review.onChoice(
true);
483static void onReviewReject(
void)
485 if (context.review.onChoice) {
486 context.review.onChoice(
false);
490static void onChoiceAccept(
void)
492 if (context.choice.onChoice) {
493 context.choice.onChoice(
true);
497static void onChoiceReject(
void)
499 if (context.choice.onChoice) {
500 context.choice.onChoice(
false);
504static void onConfirmAccept(
void)
506 if (context.confirm.currentStep) {
509 if (context.confirm.onConfirm) {
510 context.confirm.onConfirm();
514static void onConfirmReject(
void)
516 if (context.confirm.currentStep) {
523static void onSwitchAction(
void)
530 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
536 switch (context.type) {
537 case SETTINGS_USE_CASE:
539 case GENERIC_SETTINGS:
542 case CONTENT_USE_CASE:
543 case GENERIC_REVIEW_USE_CASE:
551 actionCallback(contentSwitch->
token,
553 context.currentPage);
555 else if (context.content.controlsCallback != NULL) {
556 context.content.controlsCallback(contentSwitch->
token, 0);
566 ForcedType_t forcedType)
577 .tickerIntervale = 0,
583 if ((context.type == STREAMING_CONTINUE_REVIEW_USE_CASE)
584 && (context.review.skipCallback != NULL) && (context.review.nbDataSets > 1)) {
587 if ((context.type == STATUS_USE_CASE) || (context.type == SPINNER_USE_CASE)) {
590 if ((context.type == CONFIRM_USE_CASE) && (context.confirm.currentStep != NULL)) {
595 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
597 switch (p_content->
type) {
619 else if ((icon == NULL) && (forcedType != FORCE_CENTERED_INFO)) {
621 if (subTxt != NULL) {
627 newStep =
nbgl_stepDrawText(pos, onActionCallback, p_ticker, txt, subTxt, style, modal);
635 if ((subTxt != NULL) || (context.stepCallback != NULL) || context.forceAction) {
643 if (context.type == CONFIRM_USE_CASE) {
644 context.confirm.currentStep = newStep;
650 const char *description,
659 switchInfo.
text = title;
660 switchInfo.
subText = description;
673 if (context.currentPage > 0) {
674 context.currentPage--;
678 else if ((context.type != STREAMING_CONTINUE_REVIEW_USE_CASE)
679 || (context.review.skipCallback == NULL) || (context.review.nbDataSets == 1)) {
686 if (context.currentPage < (
int) (context.nbPages - 1)) {
687 context.currentPage++;
697 if (context.stepCallback != NULL) {
698 context.stepCallback();
700 else if ((context.type == CONTENT_USE_CASE) || (context.type == SETTINGS_USE_CASE)
701 || (context.type == GENERIC_SETTINGS)
702 || (context.type == GENERIC_REVIEW_USE_CASE)) {
703 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
704 if (p_content != NULL) {
705 switch (p_content->
type) {
720 index = context.currentPage;
725 if (elemIdx < p_content->content.tagValueConfirm.tagValueList.nbPairs) {
737 else if (context.content.controlsCallback != NULL) {
738 context.content.controlsCallback(token, index);
753 if (!buttonGenericCallback(event, &pos)) {
758 context.review.dataDirection = pos;
760 displayReviewPage(pos);
772 && (context.currentPage > context.firstPairPage)) {
773 context.currentPage--;
780 && (context.currentPage < (
int) (context.nbPages - 1))
781 && (context.currentPage > context.firstPairPage)) {
782 context.currentPage++;
788 if (context.firstPairPage == 0) {
790 context.review.skipCallback();
794 context.currentPage = context.nbPages - 2;
803 if (context.firstPairPage == 0) {
804 displayStreamingReviewPage(pos);
807 displayReviewPage(pos);
817 context.action.actionCallback();
826 if (!buttonGenericCallback(event, &pos)) {
831 context.review.dataDirection = pos;
834 displayStreamingReviewPage(pos);
842 if (!buttonGenericCallback(event, &pos)) {
846 displaySettingsPage(pos,
false);
854 if (!buttonGenericCallback(event, &pos)) {
858 displayInfoPage(pos);
866 if (!buttonGenericCallback(event, &pos)) {
870 displayHomePage(pos);
878 if (!buttonGenericCallback(event, &pos)) {
882 displayChoicePage(pos);
890 if (!buttonGenericCallback(event, &pos)) {
903 if (context.stepCallback != NULL) {
904 context.stepCallback();
914 if (!buttonGenericCallback(event, &pos)) {
918 displayContent(pos,
false);
922static void statusTickerCallback(
void)
924 if (context.stepCallback != NULL) {
925 context.stepCallback();
937 if (context.review.currentExtensionPage > 0) {
938 context.review.currentExtensionPage--;
944 if (context.review.currentExtensionPage < (context.review.nbExtensionPages - 1)) {
945 context.review.currentExtensionPage++;
951 if (context.review.currentExtensionPage == (context.review.nbExtensionPages - 1)) {
961 displayExtensionStep(pos);
970 const char *text = NULL;
971 const char *subText = NULL;
973 if (context.review.extensionStepCtx != NULL) {
976 if (context.review.currentExtensionPage < (context.review.nbExtensionPages - 1)) {
977 if (context.review.currentExtensionPage == 0) {
984 switch (context.review.extension->aliasType) {
986 text = context.review.extension->title;
987 subText = context.review.extension->fullValue;
990 bool has_scope = (context.review.extension->aliasSubName != NULL);
991 bool has_tn = (context.review.extension->explanation != NULL);
992 uint8_t page = context.review.currentExtensionPage;
994 text = context.review.extension->title;
995 subText = has_scope ? context.review.extension->aliasSubName
996 : context.review.extension->fullValue;
998 else if (has_scope && page == 1) {
999 text = context.review.extension->title;
1000 subText = context.review.extension->fullValue;
1003 text = context.review.extension->explanation;
1008 infoList = context.review.extension->infolist;
1009 text = PIC(infoList->
infoTypes[context.review.currentExtensionPage]);
1010 subText = PIC(infoList->
infoContents[context.review.currentExtensionPage]);
1013 tagValueList = context.review.extension->tagValuelist;
1014 text = PIC(tagValueList->
pairs[context.review.currentExtensionPage].
item);
1015 subText = PIC(tagValueList->
pairs[context.review.currentExtensionPage].
value);
1025 else if (context.review.currentExtensionPage == (context.review.nbExtensionPages - 1)) {
1027 info.
icon = &C_icon_back_x;
1028 info.
text1 =
"Back";
1031 context.review.extensionStepCtx
1037static void displayAliasFullValue(
void)
1039 const char *text = NULL;
1040 const char *subText = NULL;
1042 bool isCenteredInfo;
1044 getPairData(context.review.tagValueList,
1045 context.review.currentTagValueIndex,
1048 &context.review.extension,
1051 if (context.review.extension == NULL) {
1054 "displayAliasFullValue: extension nor found for pair %d\n",
1055 context.review.currentTagValueIndex);
1058 context.review.currentExtensionPage = 0;
1059 context.review.extensionStepCtx = NULL;
1061 switch (context.review.extension->aliasType) {
1063 context.review.nbExtensionPages = 2;
1066 context.review.nbExtensionPages
1067 = 2 + ((context.review.extension->aliasSubName != NULL) ? 1 : 0)
1068 + ((context.review.extension->explanation != NULL) ? 1 : 0);
1071 context.review.nbExtensionPages = context.review.extension->infolist->nbInfos + 1;
1074 context.review.nbExtensionPages = context.review.extension->tagValuelist->nbPairs + 1;
1078 "displayAliasFullValue: unsupported alias type %d\n",
1079 context.review.extension->aliasType);
1085static void getLastPageInfo(
bool approve,
const nbgl_icon_details_t **icon,
const char **text)
1089 *icon = &C_icon_validate_14;
1091 if ((context.type == REVIEW_USE_CASE) && (context.review.finishTitle != NULL)) {
1092 *text = context.review.finishTitle;
1095 *text =
"Confirm contact details";
1098 else if (context.type == ADDRESS_REVIEW_USE_CASE) {
1103 if (context.review.finishTitle != NULL) {
1104 *text = context.review.finishTitle;
1110 *text =
"Accept risk and sign transaction";
1113 *text =
"Sign transaction";
1118 *text =
"Accept risk and sign message";
1121 *text =
"Sign message";
1126 *text =
"Accept risk and sign operation";
1129 *text =
"Sign operation";
1135 context.stepCallback = onReviewAccept;
1139 *icon = &C_icon_crossmark;
1140 if ((context.type == ADDRESS_REVIEW_USE_CASE)
1145 *text =
"Reject transaction";
1148 *text =
"Reject message";
1151 *text =
"Reject operation";
1153 context.stepCallback = onReviewReject;
1160 uint8_t reviewPages = 0;
1161 uint8_t finalPages = 0;
1162 uint8_t pairIndex = 0;
1163 const char *text = NULL;
1164 const char *subText = NULL;
1166 uint8_t currentIndex = 0;
1167 uint8_t titleIndex = 255;
1168 uint8_t subIndex = 255;
1169 uint8_t approveIndex = 255;
1170 uint8_t rejectIndex = 255;
1172 ForcedType_t forcedType = NO_FORCED_TYPE;
1174 context.stepCallback = NULL;
1178 titleIndex = currentIndex++;
1180 if (context.review.reviewSubTitle) {
1182 subIndex = currentIndex++;
1185 approveIndex = context.nbPages - 2;
1186 rejectIndex = context.nbPages - 1;
1187 finalPages = approveIndex;
1190 if (context.currentPage >= finalPages) {
1191 if (context.currentPage == approveIndex) {
1193 getLastPageInfo(
true, &icon, &text);
1195 else if (context.currentPage == rejectIndex) {
1197 getLastPageInfo(
false, &icon, &text);
1200 else if (context.currentPage < reviewPages) {
1201 if (context.currentPage == titleIndex) {
1203 icon = context.review.icon;
1204 text = context.review.reviewTitle;
1206 else if (context.currentPage == subIndex) {
1208 text = context.review.reviewSubTitle;
1211 else if ((context.review.address != NULL) && (context.currentPage == reviewPages)) {
1214 subText = context.review.address;
1220 if ((context.operationType &
SKIPPABLE_OPERATION) && (context.review.skipDisplay ==
false)
1221 && ((context.currentPage > reviewPages)
1225 if ((context.review.nbDataSets == 1) || (context.currentPage > 0)) {
1228 info.
icon = &C_Information_circle_14px;
1229 info.
text1 =
"Press right button to continue message or \bpress both to skip\b";
1232 context.review.skipDisplay =
true;
1233 context.firstPairPage = reviewPages;
1236 context.review.skipDisplay =
false;
1237 bool isCenteredInfo =
false;
1238 pairIndex = context.currentPage - reviewPages;
1239 if (context.review.address != NULL) {
1242 getPairData(context.review.tagValueList,
1249 if (extension != NULL) {
1250 context.stepCallback = displayAliasFullValue;
1251 context.review.currentTagValueIndex = pairIndex;
1252 forcedType = FORCE_BUTTON;
1255 if (isCenteredInfo) {
1256 forcedType = FORCE_CENTERED_INFO;
1261 drawStep(pos, icon, text, subText, reviewCallback,
false, forcedType);
1268 const char *text = NULL;
1269 const char *subText = NULL;
1271 uint8_t reviewPages = 0;
1272 uint8_t titleIndex = 255;
1273 uint8_t subIndex = 255;
1275 ForcedType_t forcedType = NO_FORCED_TYPE;
1277 context.stepCallback = NULL;
1278 switch (context.type) {
1279 case STREAMING_START_REVIEW_USE_CASE:
1281 titleIndex = reviewPages++;
1282 if (context.review.reviewSubTitle) {
1284 subIndex = reviewPages++;
1287 if (context.currentPage >= reviewPages) {
1292 if (context.currentPage == titleIndex) {
1294 icon = context.review.icon;
1295 text = context.review.reviewTitle;
1297 else if (context.currentPage == subIndex) {
1299 text = context.review.reviewSubTitle;
1303 case STREAMING_CONTINUE_REVIEW_USE_CASE:
1304 if (context.currentPage >= context.review.tagValueList->nbPairs) {
1311 if ((context.review.skipCallback != NULL) && (context.review.skipDisplay ==
false)
1312 && ((context.review.nbDataSets > 1) || (context.currentPage > 0)
1316 if ((context.review.nbDataSets == 1) || (context.currentPage > 0)) {
1319 info.
icon = &C_Information_circle_14px;
1320 info.
text1 =
"Press right button to continue message or \bpress both to skip\b";
1323 context.review.skipDisplay =
true;
1326 context.review.skipDisplay =
false;
1327 bool isCenteredInfo =
false;
1328 getPairData(context.review.tagValueList,
1329 context.currentPage,
1335 if (extension != NULL) {
1336 forcedType = FORCE_BUTTON;
1339 if (isCenteredInfo) {
1340 forcedType = FORCE_CENTERED_INFO;
1345 case STREAMING_FINISH_REVIEW_USE_CASE:
1347 if (context.currentPage == 0) {
1349 getLastPageInfo(
true, &icon, &text);
1353 getLastPageInfo(
false, &icon, &text);
1358 drawStep(pos, icon, text, subText, streamingReviewCallback,
false, forcedType);
1365 const char *text = NULL;
1366 const char *subText = NULL;
1369 context.stepCallback = NULL;
1371 if (context.currentPage < (context.nbPages - 1)) {
1373 ((
const char *
const *) PIC(context.home.infosList->infoTypes))[context.currentPage]);
1375 ((
const char *
const *) PIC(context.home.infosList->infoContents))[context.currentPage]);
1378 icon = &C_icon_back_x;
1380 context.stepCallback = startUseCaseHome;
1383 drawStep(pos, icon, text, subText, infoCallback,
false, FORCE_CENTERED_INFO);
1388static void getContentPage(
bool toogle_state, PageContent_t *contentPage)
1390 uint8_t elemIdx = 0;
1394#ifdef WITH_HORIZONTAL_CHOICES_LIST
1396 char **names = NULL;
1398#ifdef WITH_HORIZONTAL_BARS_LIST
1400 char **texts = NULL;
1402 p_content = getContentElemAtIdx(context.currentPage, &elemIdx, &content);
1403 if (p_content == NULL) {
1406 switch (p_content->
type) {
1420 &contentPage->subText,
1421 &contentPage->extension,
1423 &contentPage->isCenteredInfo);
1426 if (elemIdx < p_content->content.tagValueConfirm.tagValueList.nbPairs) {
1430 &contentPage->subText,
1431 &contentPage->extension,
1433 &contentPage->isCenteredInfo);
1437 contentPage->icon = &C_icon_validate_14;
1438 contentPage->isAction =
true;
1442 contentPage->isSwitch =
true;
1445 contentPage->
text = contentSwitch->
text;
1446 contentPage->state = contentSwitch->
initState;
1450 context.stepCallback = onSwitchAction;
1451 contentPage->subText = contentSwitch->
subText;
1456 contentPage->subText
1460#ifdef WITH_HORIZONTAL_CHOICES_LIST
1462 names = (
char **) PIC(contentChoices->
names);
1463 if ((context.type == CONTENT_USE_CASE) && (context.content.title != NULL)) {
1464 contentPage->text = PIC(context.content.title);
1465 contentPage->subText = (
const char *) PIC(names[elemIdx]);
1467 else if ((context.type == GENERIC_SETTINGS) && (context.home.appName != NULL)) {
1468 contentPage->text = PIC(context.home.appName);
1469 contentPage->subText = (
const char *) PIC(names[elemIdx]);
1472 contentPage->text = (
const char *) PIC(names[elemIdx]);
1477#ifdef WITH_HORIZONTAL_BARS_LIST
1479 texts = (
char **) PIC(contentBars->
barTexts);
1480 if ((context.type == CONTENT_USE_CASE) && (context.content.title != NULL)) {
1481 contentPage->text = PIC(context.content.title);
1482 contentPage->subText = PIC(texts[elemIdx]);
1484 else if ((context.type == GENERIC_SETTINGS) && (context.home.appName != NULL)) {
1485 contentPage->text = PIC(context.home.appName);
1486 contentPage->subText = PIC(texts[elemIdx]);
1489 contentPage->text = PIC(texts[elemIdx]);
1501 PageContent_t contentPage = {0};
1503 context.stepCallback = NULL;
1505 if (context.currentPage < (context.nbPages - 1)) {
1506 getContentPage(toogle_state, &contentPage);
1509 contentPage.icon = &C_icon_back_x;
1510 contentPage.text =
"Back";
1511 if (context.type == GENERIC_SETTINGS) {
1512 context.stepCallback = context.home.quitCallback;
1515 context.stepCallback = startUseCaseHome;
1519 if (contentPage.isSwitch) {
1521 pos, contentPage.text, contentPage.subText, contentPage.state, settingsCallback,
false);
1527 contentPage.subText,
1536static void startUseCaseHome(
void)
1538 switch (context.type) {
1539 case SETTINGS_USE_CASE:
1541 context.currentPage = 1;
1542 if (context.home.homeAction) {
1544 context.currentPage++;
1549 context.currentPage = 1;
1550 if (context.home.homeAction) {
1552 context.currentPage++;
1554 if (context.home.settingContents) {
1556 context.currentPage++;
1561 context.currentPage = 0;
1565 context.type = HOME_USE_CASE;
1566 context.nbPages = 2;
1567 if (context.home.settingContents) {
1570 if (context.home.infosList) {
1573 if (context.home.homeAction) {
1579static void startUseCaseInfo(
void)
1581 context.type = INFO_USE_CASE;
1582 context.nbPages = context.home.infosList->nbInfos + 1;
1583 context.currentPage = 0;
1588static void startUseCaseSettingsAtPage(uint8_t initSettingPage)
1594 if (context.type != GENERIC_SETTINGS) {
1595 context.
type = SETTINGS_USE_CASE;
1598 context.nbPages = 1;
1599 for (uint i = 0; i < context.home.settingContents->nbContents; i++) {
1600 p_content = getContentAtIdx(context.home.settingContents, i, &content);
1601 context.nbPages += getContentNbElement(p_content);
1603 context.currentPage = initSettingPage;
1608static void startUseCaseSettings(
void)
1610 startUseCaseSettingsAtPage(0);
1613static void startUseCaseContent(
void)
1615 uint8_t contentIdx = 0;
1619 context.nbPages = 1;
1621 for (contentIdx = 0; contentIdx < context.content.genericContents.nbContents; contentIdx++) {
1622 p_content = getContentAtIdx(&context.content.genericContents, contentIdx, &content);
1623 context.nbPages += getContentNbElement(p_content);
1627 if (context.currentPage >= context.nbPages) {
1637 const char *text = NULL;
1638 const char *subText = NULL;
1640 uint8_t currentIndex = 0;
1641 uint8_t homeIndex = 255;
1642 uint8_t actionIndex = 255;
1643 uint8_t settingsIndex = 255;
1644 uint8_t infoIndex = 255;
1646 context.stepCallback = NULL;
1649 homeIndex = currentIndex++;
1650 if (context.home.homeAction) {
1651 actionIndex = currentIndex++;
1653 if (context.home.settingContents) {
1654 settingsIndex = currentIndex++;
1656 if (context.home.infosList) {
1657 infoIndex = currentIndex++;
1660 if (context.currentPage == homeIndex) {
1662 icon = context.home.appIcon;
1663 if (context.home.tagline != NULL) {
1664 text = context.home.tagline;
1667 text = context.home.appName;
1668 subText =
"app is ready";
1671 else if (context.currentPage == actionIndex) {
1673 icon = context.home.homeAction->icon;
1674 text = PIC(context.home.homeAction->text);
1675 context.stepCallback = context.home.homeAction->callback;
1677 else if (context.currentPage == settingsIndex) {
1679 icon = &C_icon_coggle;
1680 text =
"App settings";
1681 context.stepCallback = startUseCaseSettings;
1683 else if (context.currentPage == infoIndex) {
1685 icon = &C_Information_circle_14px;
1687 context.stepCallback = startUseCaseInfo;
1690 icon = &C_Quit_14px;
1692 context.stepCallback = context.home.quitCallback;
1695 drawStep(pos, icon, text, subText, homeCallback,
false, NO_FORCED_TYPE);
1702 const char *text = NULL;
1703 const char *subText = NULL;
1708 uint8_t acceptPage = 0;
1711 uint8_t nbDetailPages = 0;
1713 if (context.choice.message != NULL) {
1714 if ((context.choice.icon == NULL) || (context.choice.subMessage == NULL)) {
1721 if ((context.choice.details != NULL) && (context.choice.details->type ==
BAR_LIST_WARNING)) {
1722 nbDetailPages = context.choice.details->barList.nbBars;
1724 context.stepCallback = NULL;
1726 if (context.currentPage < acceptPage) {
1727 if (context.currentPage == 0) {
1728 text = context.choice.message;
1729 if (context.choice.icon != NULL) {
1730 icon = context.choice.icon;
1733 subText = context.choice.subMessage;
1736 else if ((acceptPage == 2) && (context.currentPage == 1)) {
1738 text = context.choice.message;
1739 subText = context.choice.subMessage;
1742 else if (context.currentPage < (acceptPage + nbDetailPages)) {
1744 uint8_t idx = context.currentPage - acceptPage;
1745 text = (context.choice.details->barList.texts != NULL)
1746 ? context.choice.details->barList.texts[idx]
1748 subText = (context.choice.details->barList.subTexts != NULL)
1749 ? context.choice.details->barList.subTexts[idx]
1752 else if (context.currentPage == (acceptPage + nbDetailPages)) {
1753 icon = &C_icon_validate_14;
1754 text = context.choice.confirmText;
1755 context.stepCallback = onChoiceAccept;
1758 icon = &C_icon_crossmark;
1759 text = context.choice.cancelText;
1760 context.stepCallback = onChoiceReject;
1764 drawStep(pos, icon, text, subText, genericChoiceCallback,
false, NO_FORCED_TYPE);
1771 const char *text = NULL;
1772 const char *subText = NULL;
1775 context.stepCallback = NULL;
1776 switch (context.currentPage) {
1779 text = context.confirm.message;
1780 subText = context.confirm.subMessage;
1784 icon = &C_icon_validate_14;
1785 text = context.confirm.confirmText;
1786 context.stepCallback = onConfirmAccept;
1790 icon = &C_icon_crossmark;
1791 text = context.confirm.cancelText;
1792 context.stepCallback = onConfirmReject;
1796 drawStep(pos, icon, text, subText, genericConfirmCallback,
true, NO_FORCED_TYPE);
1803 PageContent_t contentPage = {0};
1804 ForcedType_t forcedType = NO_FORCED_TYPE;
1806 context.stepCallback = NULL;
1808 if (context.currentPage < (context.nbPages - 1)) {
1809 getContentPage(toogle_state, &contentPage);
1810 if (contentPage.isCenteredInfo) {
1811 forcedType = FORCE_CENTERED_INFO;
1813 context.forceAction = contentPage.isAction;
1816 if (context.content.rejectText) {
1817 contentPage.text = context.content.rejectText;
1820 contentPage.text =
"Back";
1822 if (context.type == GENERIC_REVIEW_USE_CASE) {
1823 contentPage.icon = &C_icon_crossmark;
1826 contentPage.icon = &C_icon_back_x;
1828 context.stepCallback = context.content.quitCallback;
1831 if (contentPage.isSwitch) {
1833 pos, contentPage.text, contentPage.subText, contentPage.state, contentCallback,
false);
1839 contentPage.subText,
1844 context.forceAction =
false;
1848static void displaySpinner(
const char *text)
1850 drawStep(
SINGLE_STEP, &C_icon_processing, text, NULL, NULL,
false,
false);
1855static void useCaseReview(ContextType_t type,
1859 const char *reviewTitle,
1860 const char *reviewSubTitle,
1861 const char *finishTitle,
1864 memset(&context, 0,
sizeof(UseCaseContext_t));
1865 context.type = type;
1866 context.operationType = operationType;
1867 context.review.tagValueList = tagValueList;
1868 context.review.reviewTitle = reviewTitle;
1869 context.review.reviewSubTitle = reviewSubTitle;
1870 context.review.finishTitle = finishTitle;
1871 context.review.icon = icon;
1872 context.review.onChoice = choiceCallback;
1873 context.currentPage = 0;
1875 context.nbPages = tagValueList->
nbPairs + 3;
1876 if (reviewSubTitle) {
1884static void setPinCodeText(
void)
1886 bool enableValidate =
false;
1887 bool enableBackspace =
true;
1890 enableValidate = (context.keypad.pinLen >= context.keypad.pinMinDigits);
1892 enableBackspace = (context.keypad.pinLen > 0) || (context.keypad.backCallback != NULL);
1894 context.keypad.hidden,
1895 context.keypad.pinLen,
1896 (
const char *) context.keypad.pinEntry);
1898 context.keypad.layoutCtx, context.keypad.keypadIndex, enableValidate, enableBackspace);
1904static void keypadCallback(
char touchedKey)
1906 switch (touchedKey) {
1908 if (context.keypad.pinLen > 0) {
1909 context.keypad.pinLen--;
1910 context.keypad.pinEntry[context.keypad.pinLen] = 0;
1912 else if (context.keypad.backCallback != NULL) {
1913 context.keypad.backCallback();
1920 context.keypad.validatePin(context.keypad.pinEntry, context.keypad.pinLen);
1924 if ((touchedKey >= 0x30) && (touchedKey < 0x40)) {
1925 if (context.keypad.pinLen < context.keypad.pinMaxDigits) {
1926 context.keypad.pinEntry[context.keypad.pinLen] = touchedKey;
1927 context.keypad.pinLen++;
1940 const char **buttons;
1941 int firstButtonToken;
1942 uint8_t nbUsedButtons;
1946} savedKeyboardContext;
1961static void displaySuggestionSelection(
void)
1964 savedKeyboardContext.buttons = context.keyboard.content.suggestionButtons.buttons;
1965 savedKeyboardContext.firstButtonToken
1966 = context.keyboard.content.suggestionButtons.firstButtonToken;
1967 savedKeyboardContext.nbUsedButtons = context.keyboard.content.suggestionButtons.nbUsedButtons;
1968 savedKeyboardContext.onButtonCallback = context.keyboard.onButtonCallback;
1969 savedKeyboardContext.backCallback = context.keyboard.backCallback;
1973 context.keyboard.layoutCtx = NULL;
1975 snprintf(savedKeyboardContext.title,
1976 sizeof(savedKeyboardContext.title),
1978 context.keyboard.content.number);
1982 savedKeyboardContext.backCallback,
1983 suggestionNavCallback,
1984 savedKeyboardContext.onButtonCallback);
1988static void keyboardCallback(
char touchedKey)
1991 size_t textLen = strlen(context.keyboard.entryBuffer);
1992 PRINTF(
"[keyboardCallback] touchedKey: '%c'\n", touchedKey);
1996 context.keyboard.backCallback();
1999 context.keyboard.entryBuffer[--textLen] =
'\0';
2002 context.keyboard.actionCallback();
2006 context.keyboard.entryBuffer[textLen] = touchedKey;
2007 context.keyboard.entryBuffer[++textLen] =
'\0';
2012 context.keyboard.getSuggestButtons(&context.keyboard.content, &mask);
2013 if ((context.keyboard.content.suggestionButtons.nbUsedButtons > 0)
2014 && (context.keyboard.content.suggestionButtons.nbUsedButtons
2018 displaySuggestionSelection();
2022 else if (textLen >= context.keyboard.entryMaxLen) {
2028 context.keyboard.layoutCtx, context.keyboard.textIndex, context.keyboard.entryBuffer);
2034static void launchReviewAfterWarning(
void)
2036 if (reviewWithWarnCtx.type == REVIEW_USE_CASE) {
2037 useCaseReview(reviewWithWarnCtx.type,
2038 reviewWithWarnCtx.operationType,
2039 reviewWithWarnCtx.tagValueList,
2040 reviewWithWarnCtx.icon,
2041 reviewWithWarnCtx.reviewTitle,
2042 reviewWithWarnCtx.reviewSubTitle,
2043 reviewWithWarnCtx.finishTitle,
2044 reviewWithWarnCtx.choiceCallback);
2046 else if (reviewWithWarnCtx.type == STREAMING_START_REVIEW_USE_CASE) {
2056 displayWarningStep();
2061static void displayBarDetailStep(
void)
2064 = &reviewWithWarnCtx.warning->introDetails->
barList.
details[reviewWithWarnCtx.barDetailIdx];
2087 if (reviewWithWarnCtx.warningPage > 0) {
2088 reviewWithWarnCtx.warningPage--;
2093 if (reviewWithWarnCtx.warningPage < (reviewWithWarnCtx.nbWarningPages - 1)) {
2094 reviewWithWarnCtx.warningPage++;
2096 else if ((reviewWithWarnCtx.warning->predefinedSet == 0)
2097 && (reviewWithWarnCtx.warning->info != NULL)) {
2098 launchReviewAfterWarning();
2105 if (reviewWithWarnCtx.warningPage == reviewWithWarnCtx.firstWarningPage) {
2106 launchReviewAfterWarning();
2109 else if (reviewWithWarnCtx.warningPage == (reviewWithWarnCtx.nbWarningPages - 1)) {
2110 reviewWithWarnCtx.choiceCallback(
false);
2114 else if ((event ==
BUTTON_BOTH_PRESSED) && (reviewWithWarnCtx.warning->introDetails != NULL)
2116 && (reviewWithWarnCtx.warningPage > reviewWithWarnCtx.firstWarningPage)) {
2118 barIdx = reviewWithWarnCtx.warningPage - reviewWithWarnCtx.firstWarningPage - 1;
2119 if ((reviewWithWarnCtx.warning->introDetails->barList.details != NULL)
2120 && (reviewWithWarnCtx.warning->introDetails->barList.details[barIdx].type
2122 reviewWithWarnCtx.barDetailIdx = barIdx;
2123 displayBarDetailStep();
2130 displayWarningStep();
2134static void displayWarningStep(
void)
2139 if ((reviewWithWarnCtx.warning->prelude) && (reviewWithWarnCtx.warningPage == 0)) {
2144 reviewWithWarnCtx.warning->prelude->title,
2145 reviewWithWarnCtx.warning->prelude->description,
2152 if (reviewWithWarnCtx.warningPage == reviewWithWarnCtx.firstWarningPage) {
2154 info.
icon = &C_icon_warning;
2155 info.
text1 =
"Blind signing ahead";
2156 info.
text2 =
"To accept risk, press both buttons";
2157 pos = (reviewWithWarnCtx.firstWarningPage == 0) ?
FIRST_STEP
2161 else if (reviewWithWarnCtx.warningPage == (reviewWithWarnCtx.nbWarningPages - 1)) {
2162 getLastPageInfo(
false, &info.
icon, &info.
text1);
2166 else if ((reviewWithWarnCtx.warning->predefinedSet == 0)
2167 && (reviewWithWarnCtx.warning->info != NULL)) {
2168 if (reviewWithWarnCtx.warningPage == reviewWithWarnCtx.firstWarningPage) {
2169 info.
icon = reviewWithWarnCtx.warning->info->icon;
2170 info.
text1 = reviewWithWarnCtx.warning->info->title;
2171 info.
text2 = reviewWithWarnCtx.warning->info->description;
2172 pos = (reviewWithWarnCtx.firstWarningPage == 0) ?
FIRST_STEP
2176 else if ((reviewWithWarnCtx.warning->introDetails != NULL)
2179 barIdx = reviewWithWarnCtx.warningPage - reviewWithWarnCtx.firstWarningPage - 1;
2180 if (reviewWithWarnCtx.warning->introDetails->barList.icons) {
2181 info.
icon = reviewWithWarnCtx.warning->introDetails->barList.icons[barIdx];
2183 info.
text1 = reviewWithWarnCtx.warning->introDetails->barList.texts[barIdx];
2184 if (reviewWithWarnCtx.warning->introDetails->barList.subTexts) {
2185 info.
text2 = reviewWithWarnCtx.warning->introDetails->barList.subTexts[barIdx];
2189 else if (reviewWithWarnCtx.warningPage == (reviewWithWarnCtx.nbWarningPages - 1)) {
2190 if ((reviewWithWarnCtx.warning->introDetails != NULL)
2192 info.
icon = reviewWithWarnCtx.warning->introDetails->centeredInfo.icon;
2193 info.
text1 = reviewWithWarnCtx.warning->introDetails->centeredInfo.title;
2194 info.
text2 = reviewWithWarnCtx.warning->introDetails->centeredInfo.description;
2213static void displayInitialWarning(
void)
2216 reviewWithWarnCtx.warningPage = 0;
2218 || ((reviewWithWarnCtx.warning->introDetails)
2220 reviewWithWarnCtx.nbWarningPages = 2;
2222 else if ((reviewWithWarnCtx.warning->introDetails)
2224 reviewWithWarnCtx.nbWarningPages
2225 = reviewWithWarnCtx.warning->introDetails->barList.nbBars + 1;
2229 reviewWithWarnCtx.nbWarningPages = 1;
2232 reviewWithWarnCtx.firstWarningPage = 0;
2233 displayWarningStep();
2237static void displayPrelude(
void)
2240 reviewWithWarnCtx.warningPage = 0;
2242 || ((reviewWithWarnCtx.warning->introDetails)
2244 reviewWithWarnCtx.nbWarningPages = 3;
2248 reviewWithWarnCtx.nbWarningPages = 2;
2250 reviewWithWarnCtx.firstWarningPage = 1;
2251 displayWarningStep();
2272 bool *requireSpecificDisplay)
2275 UNUSED(tagValueList);
2277 *requireSpecificDisplay =
true;
2297 bool *requireSpecificDisplay)
2300 UNUSED(tagValueList);
2302 UNUSED(isSkippable);
2303 *requireSpecificDisplay =
true;
2341 UNUSED(switchesList);
2381 UNUSED(choicesList);
2395 uint8_t nbPages = 0;
2396 uint8_t nbPairs = tagValueList->
nbPairs;
2397 uint8_t nbPairsInPage;
2401 while (i < tagValueList->nbPairs) {
2405 nbPairs -= nbPairsInPage;
2431 memset(&context, 0,
sizeof(UseCaseContext_t));
2432 context.type = CONTENT_USE_CASE;
2433 context.currentPage = initPage;
2434 context.content.title = title;
2435 context.content.quitCallback = quitCallback;
2436 context.content.navCallback = navCallback;
2437 context.content.controlsCallback = controlsCallback;
2438 context.content.genericContents.callbackCallNeeded =
true;
2439 context.content.genericContents.nbContents = nbPages;
2441 startUseCaseContent();
2460 const char *tagline,
2461 const uint8_t initSettingPage,
2467 memset(&context, 0,
sizeof(UseCaseContext_t));
2468 context.home.appName = appName;
2469 context.home.appIcon = appIcon;
2470 context.home.tagline = tagline;
2471 context.home.settingContents = PIC(settingContents);
2472 context.home.infosList = PIC(infosList);
2473 context.home.homeAction = action;
2474 context.home.quitCallback = quitCallback;
2476 if ((initSettingPage !=
INIT_HOME_PAGE) && (settingContents != NULL)) {
2477 startUseCaseSettingsAtPage(initSettingPage);
2502 memset(&context, 0,
sizeof(UseCaseContext_t));
2503 context.type = GENERIC_SETTINGS;
2504 context.home.appName = appName;
2505 context.home.settingContents = PIC(settingContents);
2506 context.home.infosList = PIC(infosList);
2507 context.home.quitCallback = quitCallback;
2509 startUseCaseSettingsAtPage(initPage);
2548 const char *reviewTitle,
2549 const char *reviewSubTitle,
2550 const char *finishTitle,
2553 useCaseReview(REVIEW_USE_CASE,
2588 const char *reviewTitle,
2589 const char *reviewSubTitle,
2590 const char *finishTitle,
2596 ContextType_t type = REVIEW_USE_CASE;
2599 if ((warning == NULL)
2619 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
2620 reviewWithWarnCtx.type = type;
2621 reviewWithWarnCtx.operationType = operationType;
2622 reviewWithWarnCtx.tagValueList = tagValueList;
2623 reviewWithWarnCtx.icon = icon;
2624 reviewWithWarnCtx.reviewTitle = reviewTitle;
2625 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
2626 reviewWithWarnCtx.finishTitle = finishTitle;
2627 reviewWithWarnCtx.warning = warning;
2628 reviewWithWarnCtx.choiceCallback = choiceCallback;
2631 if (reviewWithWarnCtx.warning->prelude) {
2636 displayInitialWarning();
2672 const char *reviewTitle,
2673 const char *reviewSubTitle,
2674 const char *finishTitle,
2685 &blindSigningWarning,
2706 const char *reviewTitle,
2707 const char *reviewSubTitle,
2708 const char *finishTitle,
2739 const char *reviewTitle,
2740 const char *reviewSubTitle,
2743 memset(&context, 0,
sizeof(UseCaseContext_t));
2744 context.type = ADDRESS_REVIEW_USE_CASE;
2745 context.review.address = address;
2746 context.review.reviewTitle = reviewTitle;
2747 context.review.reviewSubTitle = reviewSubTitle;
2748 context.review.icon = icon;
2749 context.review.onChoice = choiceCallback;
2750 context.currentPage = 0;
2753 context.nbPages = reviewSubTitle ? 5 : 4;
2754 if (additionalTagValueList) {
2755 context.review.tagValueList = PIC(additionalTagValueList);
2756 context.nbPages += additionalTagValueList->
nbPairs;
2771 const char *rejectText,
2774 memset(&context, 0,
sizeof(UseCaseContext_t));
2775 context.type = GENERIC_REVIEW_USE_CASE;
2776 context.content.rejectText = rejectText;
2777 context.content.quitCallback = rejectCallback;
2778 context.content.genericContents.nbContents = contents->
nbContents;
2784 context.content.genericContents.contentsList = PIC(contents->
contentsList);
2787 startUseCaseContent();
2801 memset(&context, 0,
sizeof(UseCaseContext_t));
2802 context.type = STATUS_USE_CASE;
2803 context.stepCallback = quitCallback;
2804 context.currentPage = 0;
2805 context.nbPages = 1;
2811 statusButtonCallback,
2827 switch (reviewStatusType) {
2829 msg =
"Operation signed";
2833 msg =
"Operation rejected";
2837 msg =
"Transaction signed";
2841 msg =
"Transaction rejected";
2845 msg =
"Message signed";
2849 msg =
"Message rejected";
2853 msg =
"Address verified";
2857 msg =
"Address verification cancelled";
2880 const char *reviewTitle,
2881 const char *reviewSubTitle,
2885 streamingOpType = operationType;
2887 memset(&context, 0,
sizeof(UseCaseContext_t));
2888 context.type = STREAMING_START_REVIEW_USE_CASE;
2889 context.operationType = operationType;
2890 context.review.reviewTitle = reviewTitle;
2891 context.review.reviewSubTitle = reviewSubTitle;
2892 context.review.icon = icon;
2893 context.review.onChoice = choiceCallback;
2894 context.currentPage = 0;
2895 context.nbPages = reviewSubTitle ? 3 : 2;
2915 const char *reviewTitle,
2916 const char *reviewSubTitle,
2920 operationType, icon, reviewTitle, reviewSubTitle, &blindSigningWarning, choiceCallback);
2940 const char *reviewTitle,
2941 const char *reviewSubTitle,
2945 memset(&context, 0,
sizeof(UseCaseContext_t));
2946 context.type = STREAMING_START_REVIEW_USE_CASE;
2947 context.operationType = operationType;
2948 context.review.reviewTitle = reviewTitle;
2949 context.review.reviewSubTitle = reviewSubTitle;
2950 context.review.icon = icon;
2951 context.review.onChoice = choiceCallback;
2952 context.currentPage = 0;
2953 context.nbPages = reviewSubTitle ? 3 : 2;
2956 streamingOpType = operationType;
2959 if ((warning == NULL)
2971 memset(&reviewWithWarnCtx, 0,
sizeof(reviewWithWarnCtx));
2973 reviewWithWarnCtx.type = context.type;
2974 reviewWithWarnCtx.operationType = operationType;
2975 reviewWithWarnCtx.icon = icon;
2976 reviewWithWarnCtx.reviewTitle = reviewTitle;
2977 reviewWithWarnCtx.reviewSubTitle = reviewSubTitle;
2978 reviewWithWarnCtx.choiceCallback = choiceCallback;
2979 reviewWithWarnCtx.warning = warning;
2982 if (reviewWithWarnCtx.warning->prelude) {
2987 displayInitialWarning();
3011 uint8_t curNbDataSets = context.review.nbDataSets;
3013 memset(&context, 0,
sizeof(UseCaseContext_t));
3014 context.type = STREAMING_CONTINUE_REVIEW_USE_CASE;
3015 context.operationType = streamingOpType;
3016 context.review.tagValueList = tagValueList;
3017 context.review.onChoice = choiceCallback;
3018 context.currentPage = 0;
3019 context.nbPages = tagValueList->
nbPairs + 1;
3020 context.review.skipCallback = skipCallback;
3021 context.review.nbDataSets = curNbDataSets + 1;
3045 memset(&context, 0,
sizeof(UseCaseContext_t));
3046 context.type = STREAMING_FINISH_REVIEW_USE_CASE;
3047 context.operationType = streamingOpType;
3048 context.review.onChoice = choiceCallback;
3049 context.review.finishTitle = finishTitle;
3050 context.currentPage = 0;
3051 context.nbPages = 2;
3063 memset(&context, 0,
sizeof(UseCaseContext_t));
3064 context.type = SPINNER_USE_CASE;
3065 context.currentPage = 0;
3066 context.nbPages = 1;
3068 displaySpinner(text);
3084 const char *message,
3085 const char *subMessage,
3086 const char *confirmText,
3087 const char *cancelText,
3091 icon, message, subMessage, confirmText, cancelText, NULL, callback);
3109 const char *message,
3110 const char *subMessage,
3111 const char *confirmText,
3112 const char *cancelText,
3116 memset(&context, 0,
sizeof(UseCaseContext_t));
3117 context.type = CHOICE_USE_CASE;
3118 context.choice.icon = icon;
3119 context.choice.message = message;
3120 context.choice.subMessage = subMessage;
3121 context.choice.confirmText = confirmText;
3122 context.choice.cancelText = cancelText;
3123 context.choice.onChoice = callback;
3124 context.choice.details = details;
3125 context.currentPage = 0;
3126 context.nbPages = 2;
3127 if (message != NULL) {
3130 if ((icon != NULL) && (subMessage != NULL)) {
3134 if (details != NULL) {
3151 const char *message,
3152 const char *subMessage,
3153 const char *confirmText,
3154 const char *cancelText,
3161 centerIcon, title, message, confirmText, cancelText, details, callback);
3178 const char *subMessage,
3179 const char *confirmText,
3180 const char *cancelText,
3183 memset(&context, 0,
sizeof(UseCaseContext_t));
3184 context.type = CONFIRM_USE_CASE;
3185 context.confirm.message = message;
3186 context.confirm.subMessage = subMessage;
3187 context.confirm.confirmText = confirmText;
3188 context.confirm.cancelText = cancelText;
3189 context.confirm.onConfirm = callback;
3190 context.currentPage = 0;
3191 context.nbPages = 1 + 2;
3206 const char *message,
3207 const char *actionText,
3215 memset(&context, 0,
sizeof(UseCaseContext_t));
3216 context.type = ACTION_USE_CASE;
3217 context.action.actionCallback = callback;
3219 centeredInfo.
icon = icon;
3220 centeredInfo.
text1 = message;
3256 memset(&context, 0,
sizeof(KeypadContext_t));
3257 context.type = KEYPAD_USE_CASE;
3258 context.currentPage = 0;
3259 context.nbPages = 1;
3260 context.keypad.validatePin = validatePinCallback;
3261 context.keypad.backCallback = backCallback;
3262 context.keypad.pinMinDigits = minDigits;
3263 context.keypad.pinMaxDigits = maxDigits;
3264 context.keypad.hidden = hidden;
3272 context.keypad.keypadIndex = status;
3280 if (context.keypad.backCallback != NULL) {
3321 .mode = params->
mode,
3327 memset(&context, 0,
sizeof(UseCaseContext_t));
3328 context.type = KEYBOARD_USE_CASE;
3329 context.currentPage = 0;
3330 context.nbPages = 1;
3331 context.keyboard.entryBuffer = PIC(params->
entryBuffer);
3332 context.keyboard.entryMaxLen = params->
entryMaxLen;
3333 context.keyboard.entryBuffer[0] =
'\0';
3335 context.keyboard.content.type = params->
type;
3338 context.keyboard.backCallback = PIC(backCallback);
3340 switch (params->
type) {
3347 context.keyboard.getSuggestButtons
3370 context.keyboard.keyboardIndex = status;
3377 context.keyboard.textIndex = status;
nbgl_contentCenteredInfoStyle_t
possible styles for Centered Info Area
@ BOLD_TEXT1_INFO
bold is used for text1 (but '\b' can switch to regular)
@ BUTTON_INFO
bold is used for text1 and text2 as a white button
@ REGULAR_INFO
both texts regular (but '\b' can switch to bold)
@ 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
#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
void(* nbgl_layoutTouchCallback_t)(int token, uint8_t index)
prototype of function to be called when an object is touched
int nbgl_layoutAddKeyboard(nbgl_layout_t *layout, const nbgl_layoutKbd_t *kbdInfo)
Creates a keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutUpdateKeyboard(nbgl_layout_t *layout, uint8_t index, uint32_t keyMask)
Updates an existing keyboard on bottom of the screen, with the given configuration.
int nbgl_layoutUpdateKeypad(nbgl_layout_t *layout, uint8_t index, bool enableValidate, bool enableBackspace)
Updates an existing keypad on bottom of the screen, with the given configuration.
@ HORIZONTAL_NAV
'<' and '>' are displayed, to navigate between pages and steps
int nbgl_layoutAddKeypadContent(nbgl_layout_t *layout, 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_layoutUpdateEnteredText(nbgl_layout_t *layout, uint8_t index, const char *text)
Updates an existing "text entry" area, created with nbgl_layoutAddEnteredText()
@ LEFT_ARROW
left arrow is used
@ RIGHT_ARROW
right arrow is used
int nbgl_layoutAddNavigation(nbgl_layout_t *layout, nbgl_layoutNavigation_t *info)
Creates navigation arrows on side(s) of the screen.
int nbgl_layoutAddEnteredText(nbgl_layout_t *layout, const char *text, bool lettersOnly)
Adds a "text entry" area under the previously entered object. The max number of really displayable ch...
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...
int nbgl_layoutDraw(nbgl_layout_t *layout)
Applies given layout. The screen will be redrawn.
#define NB_MAX_SUGGESTION_BUTTONS
void * nbgl_layout_t
type shared externally
int nbgl_layoutUpdateKeypadContent(nbgl_layout_t *layout, bool hidden, uint8_t nbActiveDigits, const char *text)
Updates an existing set of hidden digits, with the given configuration.
nbgl_layout_t * nbgl_layoutGet(const nbgl_layoutDescription_t *description)
returns a layout of the given type. The layout is reset
int nbgl_layoutAddKeypad(nbgl_layout_t *layout, keyboardCallback_t callback, const char *text, bool shuffled)
Adds a keypad on bottom of the screen, with the associated callback.
@ KEYBOARD_WITH_BUTTON
text entry area + confirmation button
@ KEYBOARD_WITH_SUGGESTIONS
text entry area + suggestion buttons
int nbgl_layoutRelease(nbgl_layout_t *layout)
Release the layout obtained with nbgl_layoutGet()
#define KEYBOARD_MAX_TITLE
@ 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)
draw a step page with a switch and navigation arrows to navigate to other pages.
void * nbgl_step_t
type shared externally
uint8_t nbgl_stepPosition_t
this type is a bitfield containing:
nbgl_step_t nbgl_stepDrawMenuList(nbgl_stepMenuListCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutMenuList_t *list, bool modal)
draw a step page with a menu list and navigation arrows to parse it. This step must be alone
#define ACTION_ON_ANY_BUTTON
When action callback applies only on both button press.
@ 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
int nbgl_stepRelease(nbgl_step_t step)
Release the step obtained with any of the nbgl_stepDrawXXX() functions.
#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)
draws a text type step, that can be multi-pages, depending of the length of text and subText....
nbgl_step_t nbgl_stepDrawCenteredInfo(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutCenteredInfo_t *info, bool modal)
draw a step with a centered info (icon + text). This is always a single page step
#define BACKWARD_DIRECTION
When action callback applies on any button press.
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
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)
uint32_t nbgl_operationType_t
This mask is used to describe the type of operation to review with additional options It is a mask of...
void nbgl_useCaseReview(nbgl_operationType_t operationType, const nbgl_contentTagValueList_t *tagValueList, const nbgl_icon_details_t *icon, const char *reviewTitle, const char *reviewSubTitle, const char *finishTitle, nbgl_choiceCallback_t choiceCallback)
void nbgl_useCaseAction(const nbgl_icon_details_t *icon, const char *message, const char *actionText, nbgl_callback_t callback)
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs, const nbgl_contentTagValueList_t *tagValueList, uint8_t startIndex, bool *requireSpecificDisplay)
uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList)
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....
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)
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)
void nbgl_useCaseStatus(const char *message, bool isSuccess, nbgl_callback_t quitCallback)
@ BLIND_SIGNING_WARN
Blind signing.
@ W3C_NO_THREAT_WARN
Web3 Checks: No Threat detected.
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 "Address Book" to adapt wordi...
nbgl_reviewStatusType_t
The different types of review status.
@ STATUS_TYPE_TRANSACTION_REJECTED
@ STATUS_TYPE_ADDRESS_REJECTED
@ STATUS_TYPE_TRANSACTION_SIGNED
@ STATUS_TYPE_OPERATION_REJECTED
@ STATUS_TYPE_OPERATION_SIGNED
@ STATUS_TYPE_ADDRESS_VERIFIED
@ STATUS_TYPE_MESSAGE_SIGNED
@ STATUS_TYPE_MESSAGE_REJECTED
bool(* nbgl_navCallback_t)(uint8_t page, nbgl_pageContent_t *content)
prototype of navigation callback function
#define 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)
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
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)
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)
bool onTop
if set to true, align only horizontally
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
This structure contains data to build a INFOS_LIST content.
const char *const * infoContents
array of contents of infos (in black)
const char *const * infoTypes
array of types of infos (in black/bold)
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
This structure contains a list of [tag,value] pairs.
const nbgl_contentTagValue_t * pairs
array of [tag,value] pairs (nbPairs items). If NULL, callback is used instead
nbgl_contentTagValueCallback_t callback
function to call to retrieve a given pair
This structure contains a [tag,value] pair and possible extensions.
const nbgl_contentValueExt_t * extension
if not NULL, gives additional info on value field
const nbgl_icon_details_t * valueIcon
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 ...
This structure contains data to build a content.
nbgl_contentActionCallback_t contentActionCallback
callback to be called when an action on an object occurs
nbgl_contentType_t type
type of page content in the content union
const struct nbgl_genericDetails_s * details
array of nbBars structures giving what to display when each bar is touched.
uint8_t nbBars
number of touchable bars
uint8_t nbContents
number of contents
const nbgl_content_t * contentsList
array of nbgl_content_t (nbContents items).
nbgl_contentCallback_t contentGetterCallback
function to call to retrieve a given content
The necessary parameters to build the page(s) displayed when the top-right button is touched in intro...
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
uint8_t entryMaxLen
maximum length of text that can be entered
nbgl_layoutKeyboardContentType_t type
type of content
const char * title
centered title explaining the screen
char * entryBuffer
already entered text
Structure containing all information when creating a layout. This structure must be passed as argumen...
This structure contains info to build a keyboard with nbgl_layoutAddKeyboard()
keyboardCallback_t callback
function called when an active key is pressed
This structure contains info to build a keyboard content (controls that are linked to keyboard)
This structure contains info to build a navigation bar at the bottom of the screen.
nbgl_layoutNavDirection_t direction
vertical or horizontal navigation
This structure contains data to build a page in multi-pages mode (nbgl_pageDrawGenericContent)
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
This structure contains data to build a SWITCHES_LIST content.
uint8_t nbSwitches
number of elements in switches and tokens array
const nbgl_contentSwitch_t * switches
array of switches (nbSwitches items)
The necessary parameters to build a tip-box in first review page and the modal if this tip box is tou...
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