Skip to content

Commit 34d95d6

Browse files
Add extended version of nbgl_useCaseGetNbTagValuesInPage() to handle skippable review
1 parent 33db50a commit 34d95d6

File tree

2 files changed

+75
-62
lines changed

2 files changed

+75
-62
lines changed

lib_nbgl/include/nbgl_use_case.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPai
341341
const nbgl_contentTagValueList_t *tagValueList,
342342
uint8_t startIndex,
343343
bool *requireSpecificDisplay);
344+
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs,
345+
const nbgl_contentTagValueList_t *tagValueList,
346+
uint8_t startIndex,
347+
bool isSkippable,
348+
bool *requireSpecificDisplay);
344349
uint8_t nbgl_useCaseGetNbInfosInPage(uint8_t nbInfos,
345350
const nbgl_contentInfoList_t *infosList,
346351
uint8_t startIndex,

lib_nbgl/src/nbgl_use_case.c

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -268,36 +268,31 @@ static void bundleNavStartHome(void);
268268
static void bundleNavStartSettingsAtPage(uint8_t initSettingPage);
269269
static void bundleNavStartSettings(void);
270270

271-
static void bundleNavReviewStreamingChoice(bool confirm);
272-
static void blindSigningWarning(void);
273-
static void useCaseReview(nbgl_operationType_t operationType,
274-
const nbgl_contentTagValueList_t *tagValueList,
275-
const nbgl_icon_details_t *icon,
276-
const char *reviewTitle,
277-
const char *reviewSubTitle,
278-
const char *finishTitle,
279-
const nbgl_tipBox_t *tipBox,
280-
nbgl_choiceCallback_t choiceCallback,
281-
bool isLight,
282-
bool playNotifSound);
283-
static void useCaseReviewStreamingStart(nbgl_operationType_t operationType,
284-
const nbgl_icon_details_t *icon,
285-
const char *reviewTitle,
286-
const char *reviewSubTitle,
287-
nbgl_choiceCallback_t choiceCallback,
288-
bool playNotifSound);
289-
static void useCaseHomeExt(const char *appName,
290-
const nbgl_icon_details_t *appIcon,
291-
const char *tagline,
292-
bool withSettings,
293-
nbgl_homeAction_t *homeAction,
294-
nbgl_callback_t topRightCallback,
295-
nbgl_callback_t quitCallback);
296-
static uint8_t useCaseGetNbTagValuesInPage(uint8_t nbPairs,
297-
const nbgl_contentTagValueList_t *tagValueList,
298-
uint8_t startIndex,
299-
bool isSkippable,
300-
bool *requireSpecificDisplay);
271+
static void bundleNavReviewStreamingChoice(bool confirm);
272+
static void blindSigningWarning(void);
273+
static void useCaseReview(nbgl_operationType_t operationType,
274+
const nbgl_contentTagValueList_t *tagValueList,
275+
const nbgl_icon_details_t *icon,
276+
const char *reviewTitle,
277+
const char *reviewSubTitle,
278+
const char *finishTitle,
279+
const nbgl_tipBox_t *tipBox,
280+
nbgl_choiceCallback_t choiceCallback,
281+
bool isLight,
282+
bool playNotifSound);
283+
static void useCaseReviewStreamingStart(nbgl_operationType_t operationType,
284+
const nbgl_icon_details_t *icon,
285+
const char *reviewTitle,
286+
const char *reviewSubTitle,
287+
nbgl_choiceCallback_t choiceCallback,
288+
bool playNotifSound);
289+
static void useCaseHomeExt(const char *appName,
290+
const nbgl_icon_details_t *appIcon,
291+
const char *tagline,
292+
bool withSettings,
293+
nbgl_homeAction_t *homeAction,
294+
nbgl_callback_t topRightCallback,
295+
nbgl_callback_t quitCallback);
301296

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

1955-
static uint8_t useCaseGetNbTagValuesInPage(uint8_t nbPairs,
1956-
const nbgl_contentTagValueList_t *tagValueList,
1957-
uint8_t startIndex,
1958-
bool isSkippable,
1959-
bool *requireSpecificDisplay)
1950+
/**********************
1951+
* GLOBAL FUNCTIONS
1952+
**********************/
1953+
1954+
/**
1955+
* @brief computes the number of tag/values pairs displayable in a page, with the given list of
1956+
* tag/value pairs
1957+
*
1958+
* @param nbPairs number of tag/value pairs to use in \b tagValueList
1959+
* @param tagValueList list of tag/value pairs
1960+
* @param startIndex first index to consider in \b tagValueList
1961+
* @param requireSpecificDisplay (output) set to true if the tag/value needs a specific display:
1962+
* - centeredInfo flag is enabled
1963+
* - the tag/value doesn't fit in a page
1964+
* @return the number of tag/value pairs fitting in a page
1965+
*/
1966+
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs,
1967+
const nbgl_contentTagValueList_t *tagValueList,
1968+
uint8_t startIndex,
1969+
bool *requireSpecificDisplay)
1970+
{
1971+
return nbgl_useCaseGetNbTagValuesInPageExt(
1972+
nbPairs, tagValueList, startIndex, false, requireSpecificDisplay);
1973+
}
1974+
1975+
/**
1976+
* @brief computes the number of tag/values pairs displayable in a page, with the given list of
1977+
* tag/value pairs
1978+
*
1979+
* @param nbPairs number of tag/value pairs to use in \b tagValueList
1980+
* @param tagValueList list of tag/value pairs
1981+
* @param startIndex first index to consider in \b tagValueList
1982+
* @param isSkippable if true, a skip header is added
1983+
* @param requireSpecificDisplay (output) set to true if the tag/value needs a specific display:
1984+
* - centeredInfo flag is enabled
1985+
* - the tag/value doesn't fit in a page
1986+
* @return the number of tag/value pairs fitting in a page
1987+
*/
1988+
uint8_t nbgl_useCaseGetNbTagValuesInPageExt(uint8_t nbPairs,
1989+
const nbgl_contentTagValueList_t *tagValueList,
1990+
uint8_t startIndex,
1991+
bool isSkippable,
1992+
bool *requireSpecificDisplay)
19601993
{
19611994
uint8_t nbPairsInPage = 0;
19621995
#ifdef TARGET_STAX
@@ -2045,31 +2078,6 @@ static uint8_t useCaseGetNbTagValuesInPage(uint8_t nbP
20452078
return nbPairsInPage;
20462079
}
20472080

2048-
/**********************
2049-
* GLOBAL FUNCTIONS
2050-
**********************/
2051-
2052-
/**
2053-
* @brief computes the number of tag/values pairs displayable in a page, with the given list of
2054-
* tag/value pairs
2055-
*
2056-
* @param nbPairs number of tag/value pairs to use in \b tagValueList
2057-
* @param tagValueList list of tag/value pairs
2058-
* @param startIndex first index to consider in \b tagValueList
2059-
* @param requireSpecificDisplay (output) set to true if the tag/value needs a specific display:
2060-
* - centeredInfo flag is enabled
2061-
* - the tag/value doesn't fit in a page
2062-
* @return the number of tag/value pairs fitting in a page
2063-
*/
2064-
uint8_t nbgl_useCaseGetNbTagValuesInPage(uint8_t nbPairs,
2065-
const nbgl_contentTagValueList_t *tagValueList,
2066-
uint8_t startIndex,
2067-
bool *requireSpecificDisplay)
2068-
{
2069-
return useCaseGetNbTagValuesInPage(
2070-
nbPairs, tagValueList, startIndex, false, requireSpecificDisplay);
2071-
}
2072-
20732081
/**
20742082
* @brief computes the number of infos displayable in a page, with the given list of
20752083
* infos
@@ -2270,7 +2278,7 @@ uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *
22702278

22712279
while (i < tagValueList->nbPairs) {
22722280
// upper margin
2273-
nbPairsInPage = useCaseGetNbTagValuesInPage(nbPairs, tagValueList, i, false, &flag);
2281+
nbPairsInPage = nbgl_useCaseGetNbTagValuesInPageExt(nbPairs, tagValueList, i, false, &flag);
22742282
i += nbPairsInPage;
22752283
nbPairs -= nbPairsInPage;
22762284
nbPages++;

0 commit comments

Comments
 (0)