diff --git a/lib_nbgl/doc/nbgl_use_case.dox b/lib_nbgl/doc/nbgl_use_case.dox index 5035fd80a..d92699220 100644 --- a/lib_nbgl/doc/nbgl_use_case.dox +++ b/lib_nbgl/doc/nbgl_use_case.dox @@ -55,11 +55,11 @@ A few APIs are available to draw typical Use-Cases, such as: - for keypad: - @ref nbgl_useCaseKeypadPIN() to draw a default keypad implementation with hidden digits (see @subpage use_case_keypad) - @ref nbgl_useCaseKeypadDigits() to draw a default keypad implementation, showing digits (see @subpage use_case_keypad) +- for generic navigable content: + - @ref nbgl_useCaseNavigableContent() to draw a level of generic content navigable pages Some APIs have also been kept for backward compatibility, and for some rare cases: -- for Settings: - - @ref nbgl_useCaseSettings() to draw a level of settings pages - for most used reviews: - @ref nbgl_useCaseReviewStart() to draw the cover page of a review (initial page, without data) - @ref nbgl_useCaseStaticReview() to draw the data pages of a regular review, when all info are available from the beginning (all pages but the cover one) diff --git a/lib_nbgl/include/nbgl_use_case.h b/lib_nbgl/include/nbgl_use_case.h index 3d56a73f1..e36079cae 100644 --- a/lib_nbgl/include/nbgl_use_case.h +++ b/lib_nbgl/include/nbgl_use_case.h @@ -365,61 +365,70 @@ uint8_t nbgl_useCaseGetNbChoicesInPage(uint8_t nbChoice uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t *tagValueList); // use case drawing -void nbgl_useCaseHome(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback); -void nbgl_useCaseHomeExt(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - const char *actionButtonText, - nbgl_callback_t actionCallback, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback); -void nbgl_useCaseSettings(const char *settingsTitle, - uint8_t initPage, - uint8_t nbPages, - bool touchableTitle, - nbgl_callback_t quitCallback, - nbgl_navCallback_t navCallback, - nbgl_layoutTouchCallback_t controlsCallback); -void nbgl_useCaseGenericSettings(const char *appName, - uint8_t initPage, - const nbgl_genericContents_t *settingContents, - const nbgl_contentInfoList_t *infosList, - nbgl_callback_t quitCallback); -void nbgl_useCaseConfirm(const char *message, - const char *subMessage, - const char *confirmText, - const char *rejectText, - nbgl_callback_t callback); -void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, - const char *reviewTitle, - const char *reviewSubTitle, - const char *rejectText, - nbgl_callback_t continueCallback, - nbgl_callback_t rejectCallback); -void nbgl_useCaseRegularReview(uint8_t initPage, - uint8_t nbPages, - const char *rejectText, - nbgl_layoutTouchCallback_t buttonCallback, - nbgl_navCallback_t navCallback, - nbgl_choiceCallback_t choiceCallback); -void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, - const nbgl_pageInfoLongPress_t *infoLongPress, - const char *rejectText, - nbgl_choiceCallback_t callback); -void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, - const nbgl_pageInfoLongPress_t *infoLongPress, - const char *rejectText, - nbgl_choiceCallback_t callback); -void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback); -void nbgl_useCaseAddressConfirmationExt(const char *address, - nbgl_choiceCallback_t callback, - const nbgl_contentTagValueList_t *tagValueList); +DEPRECATED void nbgl_useCaseHome(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback); +DEPRECATED void nbgl_useCaseHomeExt(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + const char *actionButtonText, + nbgl_callback_t actionCallback, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback); +void nbgl_useCaseNavigableContent(const char *title, + uint8_t initPage, + uint8_t nbPages, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback); +DEPRECATED void nbgl_useCaseSettings(const char *settingsTitle, + uint8_t initPage, + uint8_t nbPages, + bool touchableTitle, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback); +void nbgl_useCaseGenericSettings(const char *appName, + uint8_t initPage, + const nbgl_genericContents_t *settingContents, + const nbgl_contentInfoList_t *infosList, + nbgl_callback_t quitCallback); +void nbgl_useCaseConfirm(const char *message, + const char *subMessage, + const char *confirmText, + const char *rejectText, + nbgl_callback_t callback); +void nbgl_useCaseReviewStart(const nbgl_icon_details_t *icon, + const char *reviewTitle, + const char *reviewSubTitle, + const char *rejectText, + nbgl_callback_t continueCallback, + nbgl_callback_t rejectCallback); +void nbgl_useCaseRegularReview(uint8_t initPage, + uint8_t nbPages, + const char *rejectText, + nbgl_layoutTouchCallback_t buttonCallback, + nbgl_navCallback_t navCallback, + nbgl_choiceCallback_t choiceCallback); +void nbgl_useCaseStaticReview(const nbgl_contentTagValueList_t *tagValueList, + const nbgl_pageInfoLongPress_t *infoLongPress, + const char *rejectText, + nbgl_choiceCallback_t callback); +void nbgl_useCaseStaticReviewLight(const nbgl_contentTagValueList_t *tagValueList, + const nbgl_pageInfoLongPress_t *infoLongPress, + const char *rejectText, + nbgl_choiceCallback_t callback); + +DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, + nbgl_choiceCallback_t callback, + const nbgl_contentTagValueList_t *tagValueList); +#define nbgl_useCaseAddressConfirmation(__address, __callback) \ + nbgl_useCaseAddressConfirmationExt(__address, __callback, NULL) + #ifdef NBGL_KEYPAD void nbgl_useCaseKeypadDigits(const char *title, uint8_t minDigits, diff --git a/lib_nbgl/src/nbgl_use_case.c b/lib_nbgl/src/nbgl_use_case.c index bb77a2e50..c905fe97c 100644 --- a/lib_nbgl/src/nbgl_use_case.c +++ b/lib_nbgl/src/nbgl_use_case.c @@ -16,7 +16,6 @@ #include "os_pic.h" #include "os_print.h" #include "os_helpers.h" -#include "decorators.h" /********************* * DEFINES @@ -2330,29 +2329,30 @@ uint8_t nbgl_useCaseGetNbPagesForTagValueList(const nbgl_contentTagValueList_t * * @deprecated * See #nbgl_useCaseHomeAndSettings */ -DEPRECATED void nbgl_useCaseHome(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) -{ - nbgl_useCaseHomeExt( - appName, appIcon, tagline, withSettings, NULL, NULL, topRightCallback, quitCallback); +void nbgl_useCaseHome(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback) +{ + nbgl_homeAction_t homeAction = {0}; + useCaseHomeExt( + appName, appIcon, tagline, withSettings, &homeAction, topRightCallback, quitCallback); } /** * @deprecated * See #nbgl_useCaseHomeAndSettings */ -DEPRECATED void nbgl_useCaseHomeExt(const char *appName, - const nbgl_icon_details_t *appIcon, - const char *tagline, - bool withSettings, - const char *actionButtonText, - nbgl_callback_t actionCallback, - nbgl_callback_t topRightCallback, - nbgl_callback_t quitCallback) +void nbgl_useCaseHomeExt(const char *appName, + const nbgl_icon_details_t *appIcon, + const char *tagline, + bool withSettings, + const char *actionButtonText, + nbgl_callback_t actionCallback, + nbgl_callback_t topRightCallback, + nbgl_callback_t quitCallback) { nbgl_homeAction_t homeAction = {.callback = actionCallback, .icon = NULL, @@ -2364,28 +2364,25 @@ DEPRECATED void nbgl_useCaseHomeExt(const char *appName, } /** - * @brief Draws the settings pages of an app with as many pages as given - * For each page, the given navCallback will be called to get the content. Only 'type' and - * union has to be set in this content + * @brief Initiates the drawing a set of pages of generic content, with a touchable header (usually + * to go back or to an upper level) For each page (including the first one), the given 'navCallback' + * will be called to get the content. Only 'type' and union has to be set in this content. * - * @param title string to set in touchable title + * @param title string to set in touchable title (header) * @param initPage page on which to start [0->(nbPages-1)] * @param nbPages number of pages - * @param touchable unused, it is always on - * @param quitCallback callback called when quit button (or title) is pressed + * @param quitCallback callback called title is pressed * @param navCallback callback called when navigation arrows are pressed * @param controlsCallback callback called when any controls in the settings (radios, switches) is * called (the tokens must be >= @ref FIRST_USER_TOKEN) */ -void nbgl_useCaseSettings(const char *title, - uint8_t initPage, - uint8_t nbPages, - bool touchable, - nbgl_callback_t quitCallback, - nbgl_navCallback_t navCallback, - nbgl_layoutTouchCallback_t controlsCallback) +void nbgl_useCaseNavigableContent(const char *title, + uint8_t initPage, + uint8_t nbPages, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback) { - UNUSED(touchable); reset_callbacks(); // memorize context @@ -2401,6 +2398,24 @@ void nbgl_useCaseSettings(const char *title, displaySettingsPage(initPage, true); } +/** + * @deprecated + * See #nbgl_useCaseHomeAndSettings if used in a 'Settings' context, or nbgl_useCaseNavigableContent + * otherwise + */ +void nbgl_useCaseSettings(const char *title, + uint8_t initPage, + uint8_t nbPages, + bool touchable, + nbgl_callback_t quitCallback, + nbgl_navCallback_t navCallback, + nbgl_layoutTouchCallback_t controlsCallback) +{ + UNUSED(touchable); + nbgl_useCaseNavigableContent( + title, initPage, nbPages, quitCallback, navCallback, controlsCallback); +} + /** * @brief Draws the settings pages of an app with automatic pagination depending on content * to be displayed that is passed through settingContents and infosList @@ -3245,18 +3260,9 @@ void nbgl_useCaseReviewStreamingFinish(const char *finishTitle, * @deprecated * See #nbgl_useCaseAddressReview */ -DEPRECATED void nbgl_useCaseAddressConfirmation(const char *address, nbgl_choiceCallback_t callback) -{ - nbgl_useCaseAddressConfirmationExt(address, callback, NULL); -} - -/** - * @deprecated - * See #nbgl_useCaseAddressReview - */ -DEPRECATED void nbgl_useCaseAddressConfirmationExt(const char *address, - nbgl_choiceCallback_t callback, - const nbgl_contentTagValueList_t *tagValueList) +void nbgl_useCaseAddressConfirmationExt(const char *address, + nbgl_choiceCallback_t callback, + const nbgl_contentTagValueList_t *tagValueList) { reset_callbacks(); memset(&genericContext, 0, sizeof(genericContext));