Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbgl: Add force_page_start to nbgl_layoutTagValue_t #520

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,14 @@ typedef struct {
* @brief This structure contains a [tag,value] pair
*/
typedef struct {
const char *item; ///< string giving the tag name
const char *value; ///< string giving the value name
const char *item; ///< string giving the tag name
const char *value; ///< string giving the value name
#ifdef SCREEN_SIZE_WALLET
const nbgl_icon_details_t *valueIcon; ///< a buffer containing the 32px 1BPP icon for icon on
///< right of value (can be NULL)
int8_t force_page_start : 1; ///< if set to 1, the tag will be displayed at the top of a new
///< review page
#endif
} nbgl_layoutTagValue_t;

/**
Expand Down
28 changes: 16 additions & 12 deletions lib_nbgl/src/nbgl_use_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,27 +721,31 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPair

*tooLongToFit = false;
while (nbPairsInPage < nbPairs) {
const char *item;
const char *value;
nbgl_layoutTagValue_t *callback_result;
nbgl_font_id_e value_font;
const nbgl_layoutTagValue_t *pair;
nbgl_font_id_e value_font;

// margin between pairs
if (nbPairsInPage > 0) {
currentHeight += 12;
}
// fetch tag/value pair strings.
if (tagValueList->pairs != NULL) {
value = tagValueList->pairs[startIndex + nbPairsInPage].value;
item = tagValueList->pairs[startIndex + nbPairsInPage].item;
pair = &tagValueList->pairs[startIndex + nbPairsInPage];
}
else {
callback_result = tagValueList->callback(startIndex + nbPairsInPage);
value = callback_result->value;
item = callback_result->item;
pair = tagValueList->callback(startIndex + nbPairsInPage);
}

if (pair->force_page_start && nbPairsInPage > 0) {
// This pair must be at the top of a page
break;
}

// tag height
currentHeight += nbgl_getTextHeightInWidth(
SMALL_REGULAR_FONT, item, SCREEN_WIDTH - 2 * BORDER_MARGIN, tagValueList->wrapping);
currentHeight += nbgl_getTextHeightInWidth(SMALL_REGULAR_FONT,
pair->item,
SCREEN_WIDTH - 2 * BORDER_MARGIN,
tagValueList->wrapping);
// space between tag and value
currentHeight += 4;
// set value font
Expand All @@ -753,7 +757,7 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPair
}
// value height
currentHeight += nbgl_getTextHeightInWidth(
value_font, value, SCREEN_WIDTH - 2 * BORDER_MARGIN, tagValueList->wrapping);
value_font, pair->value, SCREEN_WIDTH - 2 * BORDER_MARGIN, tagValueList->wrapping);
if (currentHeight >= TAG_VALUE_AREA_HEIGHT) {
break;
}
Expand Down
Loading