diff --git a/lib_nbgl/include/nbgl_use_case.h b/lib_nbgl/include/nbgl_use_case.h index 52dcd3a9c..50af99a9c 100644 --- a/lib_nbgl/include/nbgl_use_case.h +++ b/lib_nbgl/include/nbgl_use_case.h @@ -196,6 +196,14 @@ void nbgl_useCaseReview(nbgl_operationType_t operationType, const char *finishTitle, nbgl_choiceCallback_t choiceCallback); +void nbgl_useCaseReviewLight(nbgl_operationType_t operationType, + const nbgl_layoutTagValueList_t *tagValueList, + const nbgl_icon_details_t *icon, + const char *reviewTitle, + const char *reviewSubTitle, + const char *finishTitle, + nbgl_choiceCallback_t choiceCallback); + void nbgl_useCaseAddressReview(const char *address, const nbgl_layoutTagValueList_t *additionalTagValueList, const nbgl_icon_details_t *icon, diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index e788851c1..24bb062f8 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -368,6 +368,16 @@ static void prepareReviewLastPage(nbgl_contentInfoLongPress_t *infoLongPress, infoLongPress->longPressToken = CONFIRM_TOKEN; } +static void prepareReviewLightLastPage(nbgl_contentInfoButton_t *infoButton, + const nbgl_icon_details_t *icon, + const char *finishTitle) +{ + infoButton->text = finishTitle; + infoButton->icon = icon; + infoButton->buttonText = "Approve"; + infoButton->buttonToken = CONFIRM_TOKEN; +} + static const char *getRejectReviewText(nbgl_operationType_t operationType) { #ifdef TARGET_STAX @@ -2397,6 +2407,63 @@ void nbgl_useCaseReview(nbgl_operationType_t operationType, displayGenericContextPage(0, true); } +/** + * @brief Draws a flow of pages of a light review. A back key is available on top-left of the + * screen, except in first page It is possible to go to next page thanks to "tap to continue". + * @note All tag/value pairs are provided in the API and the number of pages is automatically + * computed, the last page being a short press one + * + * @param operationType type of operation (Operation, Transaction, Message) + * @param tagValueList list of tag/value pairs + * @param icon icon used on first and last review page + * @param reviewTitle string used in the first review page + * @param reviewSubTitle string to set under reviewTitle (can be NULL) + * @param finishTitle string used in the last review page + * @param choiceCallback callback called when operation is accepted (param is true) or rejected + * (param is false) + */ +void nbgl_useCaseReviewLight(nbgl_operationType_t operationType, + const nbgl_layoutTagValueList_t *tagValueList, + const nbgl_icon_details_t *icon, + const char *reviewTitle, + const char *reviewSubTitle, + const char *finishTitle, + nbgl_choiceCallback_t choiceCallback) +{ + reset_callbacks(); + memset(&genericContext, 0, sizeof(genericContext)); + + // memorize context + onChoice = choiceCallback; + navType = GENERIC_NAV; + pageTitle = NULL; + + genericContext.genericContents.contentsList = localContentsList; + genericContext.genericContents.nbContents = 3; + memset(localContentsList, 0, 3 * sizeof(nbgl_content_t)); + + // First a centered info + localContentsList[0].type = CENTERED_INFO; + prepareReviewFirstPage( + &localContentsList[0].content.centeredInfo, icon, reviewTitle, reviewSubTitle); + + // Then the tag/value pairs + localContentsList[1].type = TAG_VALUE_LIST; + memcpy(&localContentsList[1].content.tagValueList, + tagValueList, + sizeof(nbgl_layoutTagValueList_t)); + + // Eventually the long press page + localContentsList[2].type = INFO_BUTTON; + prepareReviewLightLastPage(&localContentsList[2].content.infoButton, icon, finishTitle); + + // compute number of pages & fill navigation structure + uint8_t nbPages = nbgl_useCaseGetNbPagesForGenericContents(&genericContext.genericContents, 0); + prepareNavInfo(true, nbPages, getRejectReviewText(operationType)); + + displayGenericContextPage(0, true); +} + /** * @brief Draws a flow of pages of a review with automatic pagination depending on content * to be displayed that is passed through contents. diff --git a/lib_ux_sync/include/ux_sync.h b/lib_ux_sync/include/ux_sync.h index c03003df5..bba5145f6 100644 --- a/lib_ux_sync/include/ux_sync.h +++ b/lib_ux_sync/include/ux_sync.h @@ -25,6 +25,13 @@ ux_sync_ret_t ux_sync_review(nbgl_operationType_t operationType, const char *reviewSubTitle, const char *finishTitle); +ux_sync_ret_t ux_sync_reviewLight(nbgl_operationType_t operationType, + const nbgl_layoutTagValueList_t *tagValueList, + const nbgl_icon_details_t *icon, + const char *reviewTitle, + const char *reviewSubTitle, + const char *finishTitle); + ux_sync_ret_t ux_sync_addressReview(const char *address, const nbgl_layoutTagValueList_t *additionalTagValueList, const nbgl_icon_details_t *icon, diff --git a/lib_ux_sync/src/ux_sync.c b/lib_ux_sync/src/ux_sync.c index a58691ae0..7a2a50604 100644 --- a/lib_ux_sync/src/ux_sync.c +++ b/lib_ux_sync/src/ux_sync.c @@ -123,6 +123,40 @@ ux_sync_ret_t ux_sync_review(nbgl_operationType_t operationType, return ux_sync_wait(false); } +/** + * @brief Draws a flow of pages of a light review. A back key is available on top-left of the + * screen,except in first page It is possible to go to next page thanks to "tap to continue". + * @note All tag/value pairs are provided in the API and the number of pages is automatically + * computed, the last page being a short press one + * + * @param operationType type of operation (Operation, Transaction, Message) + * @param tagValueList list of tag/value pairs + * @param icon icon used on first and last review page + * @param reviewTitle string used in the first review page + * @param reviewSubTitle string to set under reviewTitle (can be NULL) + * @param finishTitle string used in the last review page + * + * @return ret code: + * - UX_SYNC_RET_APPROVED + * - UX_SYNC_RET_REJECTED + */ +ux_sync_ret_t ux_sync_reviewLight(nbgl_operationType_t operationType, + const nbgl_layoutTagValueList_t *tagValueList, + const nbgl_icon_details_t *icon, + const char *reviewTitle, + const char *reviewSubTitle, + const char *finishTitle) +{ + ux_sync_init(); + nbgl_useCaseReviewLight(operationType, + tagValueList, + icon, + reviewTitle, + reviewSubTitle, + finishTitle, + choice_callback); + return ux_sync_wait(false); +} /** * @brief Draws a flow of pages of an extended address verification page. * A back key is available on top-left of the screen,