Skip to content

Commit 932cec3

Browse files
Fix switches list height computation in NBGL Use Case
1 parent 9181bc7 commit 932cec3

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

lib_nbgl/doc/nbgl_use_case.dox

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ static const nbgl_warningDetails_t warningIntroDetails = {
577577
.type = BAR_LIST_WARNING,
578578
.barList.nbBars = 2,
579579
.barList.icons = barListIcons,
580-
.texts = barListTexts,
581-
.subTexts = barListSubTexts,
580+
.barList.texts = barListTexts,
581+
.barList.subTexts = barListSubTexts,
582582
.barList.details = barListIntroDetails
583583
};
584584

@@ -588,8 +588,8 @@ static const nbgl_warningDetails_t warningReviewDetails = {
588588
.type = BAR_LIST_WARNING,
589589
.barList.nbBars = 2,
590590
.barList.icons = barListIcons,
591-
.texts = barListTexts,
592-
.subTexts = barListSubTexts,
591+
.barList.texts = barListTexts,
592+
.barList.subTexts = barListSubTexts,
593593
.barList.details = barListReviewDetails
594594
};
595595

lib_nbgl/src/nbgl_use_case.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,19 +3022,20 @@ uint8_t nbgl_useCaseGetNbSwitchesInPage(uint8_t nbSwit
30223022
nbgl_contentSwitch_t *switchArray = (nbgl_contentSwitch_t *) PIC(switchesList->switches);
30233023

30243024
while (nbSwitchesInPage < nbSwitches) {
3025-
// The text string must be a 1 liner and its height is LIST_ITEM_MIN_TEXT_HEIGHT
3026-
currentHeight += LIST_ITEM_MIN_TEXT_HEIGHT + LIST_ITEM_PRE_HEADING;
3027-
3028-
if (switchArray[startIndex + nbSwitchesInPage].subText) {
3025+
nbgl_contentSwitch_t *curSwitch = &switchArray[startIndex + nbSwitchesInPage];
3026+
// The text string is either a 1 liner and its height is LIST_ITEM_MIN_TEXT_HEIGHT
3027+
// or we use its height directly
3028+
uint16_t textHeight = MAX(
3029+
LIST_ITEM_MIN_TEXT_HEIGHT,
3030+
nbgl_getTextHeightInWidth(SMALL_BOLD_FONT, curSwitch->text, AVAILABLE_WIDTH, true));
3031+
currentHeight += textHeight + 2 * LIST_ITEM_PRE_HEADING;
3032+
3033+
if (curSwitch->subText) {
30293034
currentHeight += LIST_ITEM_HEADING_SUB_TEXT;
30303035

30313036
// sub-text height
3032-
currentHeight
3033-
+= nbgl_getTextHeightInWidth(SMALL_REGULAR_FONT,
3034-
switchArray[startIndex + nbSwitchesInPage].subText,
3035-
AVAILABLE_WIDTH,
3036-
true);
3037-
currentHeight += LIST_ITEM_PRE_HEADING; // under the sub-text
3037+
currentHeight += nbgl_getTextHeightInWidth(
3038+
SMALL_REGULAR_FONT, curSwitch->subText, AVAILABLE_WIDTH, true);
30383039
}
30393040
// if height is over the limit
30403041
if (currentHeight >= (INFOS_AREA_HEIGHT - navHeight)) {
@@ -3901,9 +3902,10 @@ void nbgl_useCaseAdvancedReview(nbgl_operationType_t operationType,
39013902
reviewWithWarnCtx.choiceCallback = choiceCallback;
39023903

39033904
// display the initial warning only of a risk/threat or blind signing
3904-
if (!(reviewWithWarnCtx.warning->predefinedSet & (1 << W3C_THREAT_DETECTED_WARN))
3905-
&& !(reviewWithWarnCtx.warning->predefinedSet & (1 << W3C_RISK_DETECTED_WARN))
3906-
&& !(reviewWithWarnCtx.warning->predefinedSet & (1 << BLIND_SIGNING_WARN))) {
3905+
if ((!(reviewWithWarnCtx.warning->predefinedSet & (1 << W3C_THREAT_DETECTED_WARN))
3906+
&& !(reviewWithWarnCtx.warning->predefinedSet & (1 << W3C_RISK_DETECTED_WARN))
3907+
&& !(reviewWithWarnCtx.warning->predefinedSet & (1 << BLIND_SIGNING_WARN)))
3908+
&& (warning->introDetails == NULL)) {
39073909
useCaseReview(operationType,
39083910
tagValueList,
39093911
icon,

0 commit comments

Comments
 (0)