Skip to content

Commit

Permalink
Create a QR Code type of modal window for Tag/Value alias
Browse files Browse the repository at this point in the history
  • Loading branch information
nroggeman-ledger committed Oct 14, 2024
1 parent 81fad31 commit 18ed5f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
8 changes: 5 additions & 3 deletions lib_nbgl/include/nbgl_content.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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;

Expand Down
30 changes: 19 additions & 11 deletions lib_nbgl/src/nbgl_use_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,28 +1146,36 @@ 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.";
}
else if (pair->extension->aliasType == ADDRESS_BOOK_ALIAS) {
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();
Expand Down

0 comments on commit 18ed5f0

Please sign in to comment.