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

Add extended version of nbgl_useCaseGetNbTagValuesInPage() to handle skippable review #787

Merged
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
5 changes: 5 additions & 0 deletions lib_nbgl/include/nbgl_use_case.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,11 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPai
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool *requireSpecificDisplay);
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs,
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool isSkippable,
bool *requireSpecificDisplay);
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos,
const nbgl_contentInfoList_t *infosList,
uint8_t startIndex,
Expand Down
132 changes: 70 additions & 62 deletions lib_nbgl/src/nbgl_use_case.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,36 +268,31 @@ static void bundleNavStartHome(void);
static void bundleNavStartSettingsAtPage(uint8_t initSettingPage);
static void bundleNavStartSettings(void);

static void bundleNavReviewStreamingChoice(bool confirm);
static void blindSigningWarning(void);
static void useCaseReview(nbgl_operationType_t operationType,
const nbgl_contentTagValueList_t *tagValueList,
const nbgl_icon_details_t *icon,
const char *reviewTitle,
const char *reviewSubTitle,
const char *finishTitle,
const nbgl_tipBox_t *tipBox,
nbgl_choiceCallback_t choiceCallback,
bool isLight,
bool playNotifSound);
static void useCaseReviewStreamingStart(nbgl_operationType_t operationType,
const nbgl_icon_details_t *icon,
const char *reviewTitle,
const char *reviewSubTitle,
nbgl_choiceCallback_t choiceCallback,
bool playNotifSound);
static void useCaseHomeExt(const char *appName,
const nbgl_icon_details_t *appIcon,
const char *tagline,
bool withSettings,
nbgl_homeAction_t *homeAction,
nbgl_callback_t topRightCallback,
nbgl_callback_t quitCallback);
static uint8_t useCaseGetNbTagValuesInPage(uint8_t nbPairs,
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool isSkippable,
bool *requireSpecificDisplay);
static void bundleNavReviewStreamingChoice(bool confirm);
static void blindSigningWarning(void);
static void useCaseReview(nbgl_operationType_t operationType,
const nbgl_contentTagValueList_t *tagValueList,
const nbgl_icon_details_t *icon,
const char *reviewTitle,
const char *reviewSubTitle,
const char *finishTitle,
const nbgl_tipBox_t *tipBox,
nbgl_choiceCallback_t choiceCallback,
bool isLight,
bool playNotifSound);
static void useCaseReviewStreamingStart(nbgl_operationType_t operationType,
const nbgl_icon_details_t *icon,
const char *reviewTitle,
const char *reviewSubTitle,
nbgl_choiceCallback_t choiceCallback,
bool playNotifSound);
static void useCaseHomeExt(const char *appName,
const nbgl_icon_details_t *appIcon,
const char *tagline,
bool withSettings,
nbgl_homeAction_t *homeAction,
nbgl_callback_t topRightCallback,
nbgl_callback_t quitCallback);

static void reset_callbacks(void)
{
Expand Down Expand Up @@ -1491,7 +1486,7 @@ static uint8_t nbgl_useCaseGetNbPagesForContent(const nbgl_content_t *content,
// if the current page is not the first one (or last), a navigation bar exists
bool hasNav = !isLast || (pageIdxStart > 0) || (elemIdx > 0);
if (content->type == TAG_VALUE_LIST) {
nbElementsInPage = useCaseGetNbTagValuesInPage(
nbElementsInPage = nbgl_useCaseGetNbTagValuesInPageExt(
nbElements, &content->content.tagValueList, elemIdx, isSkippable, &flag);
}
else if (content->type == INFOS_LIST) {
Expand Down Expand Up @@ -1952,11 +1947,49 @@ static void useCaseHomeExt(const char *appName,
nbgl_refreshSpecial(FULL_COLOR_CLEAN_REFRESH);
}

static uint8_t useCaseGetNbTagValuesInPage(uint8_t nbPairs,
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool isSkippable,
bool *requireSpecificDisplay)
/**********************
* GLOBAL FUNCTIONS
**********************/

/**
* @brief computes the number of tag/values pairs displayable in a page, with the given list of
* tag/value pairs
*
* @param nbPairs number of tag/value pairs to use in \b tagValueList
* @param tagValueList list of tag/value pairs
* @param startIndex first index to consider in \b tagValueList
* @param requireSpecificDisplay (output) set to true if the tag/value needs a specific display:
* - centeredInfo flag is enabled
* - the tag/value doesn't fit in a page
* @return the number of tag/value pairs fitting in a page
*/
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs,
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool *requireSpecificDisplay)
{
return nbgl_useCaseGetNbTagValuesInPageExt(
nbPairs, tagValueList, startIndex, false, requireSpecificDisplay);
}

/**
* @brief computes the number of tag/values pairs displayable in a page, with the given list of
* tag/value pairs
*
* @param nbPairs number of tag/value pairs to use in \b tagValueList
* @param tagValueList list of tag/value pairs
* @param startIndex first index to consider in \b tagValueList
* @param isSkippable if true, a skip header is added
* @param requireSpecificDisplay (output) set to true if the tag/value needs a specific display:
* - centeredInfo flag is enabled
* - the tag/value doesn't fit in a page
* @return the number of tag/value pairs fitting in a page
*/
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs,
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool isSkippable,
bool *requireSpecificDisplay)
{
uint8_t nbPairsInPage = 0;
#ifdef TARGET_STAX
Expand Down Expand Up @@ -2045,31 +2078,6 @@ static uint8_t useCaseGetNbTagValuesInPage(uint8_t nbP
return nbPairsInPage;
}

/**********************
* GLOBAL FUNCTIONS
**********************/

/**
* @brief computes the number of tag/values pairs displayable in a page, with the given list of
* tag/value pairs
*
* @param nbPairs number of tag/value pairs to use in \b tagValueList
* @param tagValueList list of tag/value pairs
* @param startIndex first index to consider in \b tagValueList
* @param requireSpecificDisplay (output) set to true if the tag/value needs a specific display:
* - centeredInfo flag is enabled
* - the tag/value doesn't fit in a page
* @return the number of tag/value pairs fitting in a page
*/
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs,
const nbgl_contentTagValueList_t *tagValueList,
uint8_t startIndex,
bool *requireSpecificDisplay)
{
return useCaseGetNbTagValuesInPage(
nbPairs, tagValueList, startIndex, false, requireSpecificDisplay);
}

/**
* @brief computes the number of infos displayable in a page, with the given list of
* infos
Expand Down Expand Up @@ -2270,7 +2278,7 @@ uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *

while (i < tagValueList->nbPairs) {
// upper margin
nbPairsInPage = useCaseGetNbTagValuesInPage(nbPairs, tagValueList, i, false, &flag);
nbPairsInPage = nbgl_useCaseGetNbTagValuesInPageExt(nbPairs, tagValueList, i, false, &flag);
i += nbPairsInPage;
nbPairs -= nbPairsInPage;
nbPages++;
Expand Down
Loading