diff --git a/lib_nbgl/include/nbgl_content.h b/lib_nbgl/include/nbgl_content.h index 5dcbb47d2..ee68f265f 100644 --- a/lib_nbgl/include/nbgl_content.h +++ b/lib_nbgl/include/nbgl_content.h @@ -123,8 +123,10 @@ typedef struct { * */ typedef enum { - ENS_ALIAS = 0, ///< alias comes from ENS - ADDRESS_BOOK_ALIAS ///< alias comes from Address Book + NO_ALIAS_TYPE = 0, + ENS_ALIAS, ///< alias comes from ENS + ADDRESS_BOOK_ALIAS, ///< alias comes from Address Book + QR_CODE_ALIAS ///< alias is an address to be displayed as a QR Code } nbgl_contentValueAliasType_t; /** @@ -134,7 +136,7 @@ typedef enum { 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 - ///< if NULL, a default explanation is provided, depending of the type + ///< only used if aliasType is @ref NO_ALIAS_TYPE nbgl_contentValueAliasType_t aliasType; ///< type of alias } nbgl_contentValueExt_t; diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index 0f3ae0e7e..e331f8a85 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -1146,12 +1146,24 @@ static void displayFullValuePage(const nbgl_contentTagValue_t *pair) .backAndText.token = 0, .backAndText.tuneId = TUNE_TAP_CASUAL, .backAndText.text = PIC(pair->item)}; - const char *info; - genericContext.modalLayout = nbgl_layoutGet(&layoutDescription); + genericContext.modalLayout = nbgl_layoutGet(&layoutDescription); // add header with the tag part of the pair, to go back nbgl_layoutAddHeader(genericContext.modalLayout, &headerDesc); - // add full value text - if (pair->extension->explanation == NULL) { + // add either QR Code or full value text + if (pair->extension->aliasType == QR_CODE_ALIAS) { +#ifdef NBGL_QRCODE + nbgl_layoutQRCode_t qrCode = {.url = pair->extension->fullValue, + .text1 = pair->extension->fullValue, + .text2 = pair->extension->explanation, + .centered = true, + .offsetY = 0}; + + nbgl_layoutAddQRCode(genericContext.modalLayout, &qrCode); +#endif // NBGL_QRCODE + } + else { + const char *info; + // add full value text if (pair->extension->aliasType == ENS_ALIAS) { info = "ENS names are resolved by Ledger backend."; } @@ -1159,15 +1171,11 @@ static void displayFullValuePage(const nbgl_contentTagValue_t *pair) info = "This account label comes from your Address Book in Ledger Live."; } else { - info = ""; + info = pair->extension->explanation; } + nbgl_layoutAddTextContent( + genericContext.modalLayout, pair->value, pair->extension->fullValue, info); } - else { - info = pair->extension->explanation; - } - nbgl_layoutAddTextContent( - genericContext.modalLayout, pair->value, pair->extension->fullValue, info); - // draw & refresh nbgl_layoutDraw(genericContext.modalLayout); nbgl_refresh();