Skip to content
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
7 changes: 4 additions & 3 deletions lib_nbgl/include/nbgl_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ typedef enum {
* to be able to build a screen to display these additions (for alias)
*/
typedef struct {
const char *fullValue; ///< full string of the value when used as an alias
const char *explanation; ///< string displayed in gray, explaing where the alias comes from
///< only used if aliasType is @ref NO_ALIAS_TYPE
const char *fullValue; ///< full string of the value when used as an alias
const char *aliasSubName; ///< string displayed under alias and in details view
const char *explanation; ///< string displayed in gray, explaing where the alias comes from
///< only used if aliasType is @ref NO_ALIAS_TYPE
const char *title; ///< if not NULL and aliasType is @ref QR_CODE_ALIAS, is used as title of
///< the QR Code
const char
Expand Down
23 changes: 19 additions & 4 deletions lib_nbgl/include/nbgl_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ extern "C" {
#error Undefined target
#endif // TARGETS

#define TAG_VALUE_INTERVALE 4
#define VALUE_ICON_INTERVALE 12

#define AVAILABLE_WIDTH (SCREEN_WIDTH - 2 * BORDER_MARGIN)

// not really used
Expand All @@ -143,6 +146,8 @@ extern "C" {

#define SPINNER_FIXED 0xFF ///< position to use for a "fixed" spinner

#define NB_MAX_DESCRIPTIONS 3 ///< max number of descriptions in @ref nbgl_layoutTextContent_t

/**********************
* TYPEDEFS
**********************/
Expand Down Expand Up @@ -262,6 +267,19 @@ typedef struct {
tune_index_e tuneId; ///< if not @ref NBGL_NO_TUNE, a tune will be played
} nbgl_layoutBar_t;

/**
* @brief This structure contains info for Text content, to be set with @ref
* nbgl_layoutAddTextContent
*
*/
typedef struct {
const char *title; ///< main text (in large bold font)
const char *info; ///< description at bottom (in small gray)
const char *descriptions[NB_MAX_DESCRIPTIONS]; ///< array of descriptions under main text (in
///< small regular font)
uint8_t nbDescriptions; ///< number of used descriptions in above array
} nbgl_layoutTextContent_t;

/**
* @brief Deprecated, kept for retro compatibility
*
Expand Down Expand Up @@ -680,10 +698,7 @@ int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout
const nbgl_layoutHorizontalButtons_t *info);
int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list);
int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text, bool grayedOut);
int nbgl_layoutAddTextContent(nbgl_layout_t *layout,
const char *title,
const char *description,
const char *info);
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, nbgl_layoutTextContent_t *content);
int nbgl_layoutAddSeparationLine(nbgl_layout_t *layout);

int nbgl_layoutAddButton(nbgl_layout_t *layout, const nbgl_layoutButton_t *buttonInfo);
Expand Down
82 changes: 53 additions & 29 deletions lib_nbgl/src/nbgl_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#define INTER_PARAGRAPHS_MARGIN 40
#define PRE_TITLE_MARGIN 24
#define PRE_DESCRIPTION_MARGIN 16
#define INTER_DESCRIPTIONS_MARGIN 16
#define PRE_FIRST_ROW_MARGIN 32
#define INTER_ROWS_MARGIN 16
#define QR_PRE_TEXT_MARGIN 24
Expand Down Expand Up @@ -88,6 +89,7 @@
#define INTER_PARAGRAPHS_MARGIN 24
#define PRE_TITLE_MARGIN 16
#define PRE_DESCRIPTION_MARGIN 24
#define INTER_DESCRIPTIONS_MARGIN 24
#define PRE_FIRST_ROW_MARGIN 32
#define INTER_ROWS_MARGIN 24
#define QR_PRE_TEXT_MARGIN 24
Expand Down Expand Up @@ -119,6 +121,7 @@
#define INTER_PARAGRAPHS_MARGIN 16
#define PRE_TITLE_MARGIN 16
#define PRE_DESCRIPTION_MARGIN 12
#define INTER_DESCRIPTIONS_MARGIN 12
#define PRE_FIRST_ROW_MARGIN 24
#define INTER_ROWS_MARGIN 12
#define QR_PRE_TEXT_MARGIN 16
Expand Down Expand Up @@ -1532,29 +1535,25 @@ int nbgl_layoutAddLargeCaseText(nbgl_layout_t *layout, const char *text, bool gr
* - a last one at the bottom of the container, in gray, with info param
*
* @param layout the current layout
* @param title main text (in large bold font)
* @param description description under main text (in small regular font)
* @param info description at bottom (in small gray)
* @param content structure describing the content to add
* @return height of the control if OK
*/
int nbgl_layoutAddTextContent(nbgl_layout_t *layout,
const char *title,
const char *description,
const char *info)
int nbgl_layoutAddTextContent(nbgl_layout_t *layout, nbgl_layoutTextContent_t *content)
{
nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
nbgl_text_area_t *textArea;
uint8_t i;

LOG_DEBUG(LAYOUT_LOGGER, "nbgl_layoutAddTextContent():\n");
if (layout == NULL) {
return -1;
}

// create title
if (title != NULL) {
if (content->title != NULL) {
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
textArea->textColor = BLACK;
textArea->text = PIC(title);
textArea->text = PIC(content->title);
textArea->textAlignment = MID_LEFT;
textArea->fontId = LARGE_MEDIUM_FONT;
textArea->style = NO_STYLE;
Expand All @@ -1569,11 +1568,11 @@ int nbgl_layoutAddTextContent(nbgl_layout_t *layout,
layoutAddObject(layoutInt, (nbgl_obj_t *) textArea);
}

// create description
if (description != NULL) {
// create descriptions
for (i = 0; i < content->nbDescriptions; i++) {
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
textArea->textColor = BLACK;
textArea->text = PIC(description);
textArea->text = PIC(content->descriptions[i]);
textArea->fontId = SMALL_REGULAR_FONT;
textArea->style = NO_STYLE;
textArea->wrapping = true;
Expand All @@ -1583,16 +1582,17 @@ int nbgl_layoutAddTextContent(nbgl_layout_t *layout,
textArea->textAlignment = MID_LEFT;
textArea->obj.alignment = NO_ALIGNMENT;
textArea->obj.alignmentMarginX = BORDER_MARGIN;
textArea->obj.alignmentMarginY = PRE_DESCRIPTION_MARGIN;
textArea->obj.alignmentMarginY
= (i == 0) ? PRE_DESCRIPTION_MARGIN : INTER_DESCRIPTIONS_MARGIN;
// set this new obj as child of main container
layoutAddObject(layoutInt, (nbgl_obj_t *) textArea);
}

// create info on the bottom
if (info != NULL) {
if (content->info != NULL) {
textArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
textArea->textColor = LIGHT_TEXT_COLOR;
textArea->text = PIC(info);
textArea->text = PIC(content->info);
textArea->fontId = SMALL_REGULAR_FONT;
textArea->style = NO_STYLE;
textArea->wrapping = true;
Expand Down Expand Up @@ -2063,8 +2063,6 @@ int nbgl_layoutAddHorizontalButtons(nbgl_layout_t *layout
int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueList_t *list)
{
nbgl_layoutInternal_t *layoutInt = (nbgl_layoutInternal_t *) layout;
nbgl_text_area_t *itemTextArea;
nbgl_text_area_t *valueTextArea;
nbgl_container_t *container;
uint8_t i;

Expand All @@ -2077,7 +2075,11 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL
const nbgl_layoutTagValue_t *pair;
uint16_t fullHeight = 0;
const nbgl_icon_details_t *valueIcon = NULL;
nbgl_text_area_t *itemTextArea;
nbgl_text_area_t *valueTextArea;
uint8_t nbChildren = 2;

// Retrieve pair
if (list->pairs != NULL) {
pair = &list->pairs[i];
}
Expand All @@ -2087,9 +2089,16 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL

container = (nbgl_container_t *) nbgl_objPoolGet(CONTAINER, layoutInt->layer);

// get container children (max 3 if a valueIcon, otherwise 2)
container->children
= nbgl_containerPoolGet((pair->valueIcon != NULL) ? 3 : 2, layoutInt->layer);
// tune container number of children (max 4 if a valueIcon and aliasSubName)
if (pair->valueIcon != NULL) {
nbChildren++;
// if it's a alias with a subName, add a child
if ((pair->aliasValue) && (pair->extension->aliasSubName)) {
nbChildren++;
}
}
// get container children
container->children = nbgl_containerPoolGet(nbChildren, layoutInt->layer);

itemTextArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
valueTextArea = (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
Expand All @@ -2103,11 +2112,6 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL
itemTextArea->obj.area.width = AVAILABLE_WIDTH;
itemTextArea->obj.area.height = nbgl_getTextHeightInWidth(
itemTextArea->fontId, itemTextArea->text, AVAILABLE_WIDTH, itemTextArea->wrapping);
itemTextArea->style = NO_STYLE;
itemTextArea->obj.alignment = NO_ALIGNMENT;
itemTextArea->obj.alignmentMarginX = 0;
itemTextArea->obj.alignmentMarginY = 0;
itemTextArea->obj.alignTo = NULL;
container->children[container->nbChildren] = (nbgl_obj_t *) itemTextArea;
container->nbChildren++;

Expand Down Expand Up @@ -2136,7 +2140,8 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL
valueIcon = PIC(pair->valueIcon);
}
// decrease the available width for value text
valueTextArea->obj.area.width = AVAILABLE_WIDTH - valueIcon->width - 12;
valueTextArea->obj.area.width
= AVAILABLE_WIDTH - valueIcon->width - VALUE_ICON_INTERVALE;
}

// handle the nbMaxLinesForValue parameter, used to automatically keep only
Expand All @@ -2153,9 +2158,8 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL
}
const nbgl_font_t *font = nbgl_getFont(valueTextArea->fontId);
valueTextArea->obj.area.height = nbLines * font->line_height;
valueTextArea->style = NO_STYLE;
valueTextArea->obj.alignment = BOTTOM_LEFT;
valueTextArea->obj.alignmentMarginY = 4;
valueTextArea->obj.alignmentMarginY = TAG_VALUE_INTERVALE;
valueTextArea->obj.alignTo = (nbgl_obj_t *) itemTextArea;
valueTextArea->wrapping = list->wrapping;
container->children[container->nbChildren] = (nbgl_obj_t *) valueTextArea;
Expand All @@ -2171,14 +2175,34 @@ int nbgl_layoutAddTagValueList(nbgl_layout_t *layout, const nbgl_layoutTagValueL
image->foregroundColor = BLACK;
image->buffer = valueIcon;
image->obj.alignment = RIGHT_TOP;
image->obj.alignmentMarginX = 12;
image->obj.alignmentMarginX = VALUE_ICON_INTERVALE;
image->obj.alignTo = (nbgl_obj_t *) valueTextArea;
// set the container as touchable, not only the image
container->obj.touchMask = (1 << TOUCHED);
container->obj.touchId = VALUE_BUTTON_1_ID + i;

container->children[container->nbChildren] = (nbgl_obj_t *) image;
container->nbChildren++;

// if an aliasSubName is provided, display it under value
if ((pair->aliasValue) && (pair->extension->aliasSubName)) {
nbgl_text_area_t *textArea
= (nbgl_text_area_t *) nbgl_objPoolGet(TEXT_AREA, layoutInt->layer);
textArea->textColor = BLACK;
textArea->text = PIC(pair->extension->aliasSubName);
textArea->textAlignment = MID_LEFT;
textArea->nbMaxLines = 1;
textArea->fontId = SMALL_REGULAR_FONT;
textArea->obj.area.height = nbgl_getFontLineHeight(textArea->fontId);
textArea->obj.area.width = valueTextArea->obj.area.width;
textArea->obj.alignment = BOTTOM_LEFT;
textArea->obj.alignmentMarginY = TAG_VALUE_INTERVALE;
textArea->obj.alignTo = (nbgl_obj_t *) valueTextArea;
textArea->wrapping = list->wrapping;
container->children[container->nbChildren] = (nbgl_obj_t *) textArea;
container->nbChildren++;
fullHeight += textArea->obj.area.height + textArea->obj.alignmentMarginY;
}
}

container->obj.area.width = AVAILABLE_WIDTH;
Expand Down
27 changes: 18 additions & 9 deletions lib_nbgl/src/nbgl_use_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,19 +1466,23 @@ static void displayFullValuePage(const char *backText,
#endif // NBGL_QRCODE
}
else {
const char *info;
// add full value text
nbgl_layoutTextContent_t content = {0};
content.title = aliasText;
if (extension->aliasType == ENS_ALIAS) {
info = "ENS names are resolved by Ledger backend.";
content.info = "ENS names are resolved by Ledger backend.";
}
else if (extension->aliasType == ADDRESS_BOOK_ALIAS) {
info = "This account label comes from your Address Book in Ledger Wallet.";
else if ((extension->aliasType == ADDRESS_BOOK_ALIAS)
&& (extension->aliasSubName != NULL)) {
content.descriptions[content.nbDescriptions] = extension->aliasSubName;
content.nbDescriptions++;
}
else {
info = extension->explanation;
content.info = extension->explanation;
}
nbgl_layoutAddTextContent(
genericContext.modalLayout, aliasText, extension->fullValue, info);
// add full value text
content.descriptions[content.nbDescriptions] = extension->fullValue;
content.nbDescriptions++;
nbgl_layoutAddTextContent(genericContext.modalLayout, &content);
}
// draw & refresh
nbgl_layoutDraw(genericContext.modalLayout);
Expand Down Expand Up @@ -2002,7 +2006,7 @@ static uint8_t getNbTagValuesInPage(uint8_t nbPairs,
currentHeight += nbgl_getTextHeightInWidth(
SMALL_REGULAR_FONT, pair->item, AVAILABLE_WIDTH, tagValueList->wrapping);
// space between tag and value
currentHeight += 4;
currentHeight += TAG_VALUE_INTERVALE;
// set value font
if (tagValueList->smallCaseForValue) {
value_font = SMALL_REGULAR_FONT;
Expand All @@ -2013,6 +2017,11 @@ static uint8_t getNbTagValuesInPage(uint8_t nbPairs,
// value height
currentHeight += nbgl_getTextHeightInWidth(
value_font, pair->value, AVAILABLE_WIDTH, tagValueList->wrapping);

// potential subAlias text
if ((pair->aliasValue) && (pair->extension->aliasSubName)) {
currentHeight += TAG_VALUE_INTERVALE + nbgl_getFontLineHeight(SMALL_REGULAR_FONT);
}
// nb lines for value
nbLines = nbgl_getTextNbLinesInWidth(
value_font, pair->value, AVAILABLE_WIDTH, tagValueList->wrapping);
Expand Down
53 changes: 53 additions & 0 deletions tests/screenshots/flows/wallet/app-sdk/flow_tx_msg_signing.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,59 @@
},
{
"name": "prelude_sign_3",
"targets": [
{
"app_event": "ETH_ADDR_BOOK_SIGN",
"page": "address_book_1"
}
]
},
{
"name": "address_book_1",
"targets": [
{
"object": "RIGHT_BUTTON",
"page": "address_book_2"
}
]
},
{
"name": "address_book_2",
"targets": [
{
"object": "VALUE_BUTTON_1",
"page": "address_book_2.1"
},
{
"object": "VALUE_BUTTON_3",
"page": "address_book_2.2"
},
{
"object": "RIGHT_BUTTON",
"page": "address_book_3"
}
]
},
{
"name": "address_book_2.1",
"targets": [
{
"object": "BACK_BUTTON",
"page": "address_book_2"
}
]
},
{
"name": "address_book_2.2",
"targets": [
{
"object": "BACK_BUTTON",
"page": "address_book_2"
}
]
},
{
"name": "address_book_3",
"targets": [
]
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading