19#include "bolos_ux_loc_strings.h"
20#include "localization.h"
27#define NB_MAX_LAYERS 3
32typedef struct FlowContext_s {
44static FlowContext_t contexts[NB_MAX_LAYERS];
56static FlowContext_t *getFreeContext(
bool modal)
58 FlowContext_t *ctx = NULL;
66 while (i < NB_MAX_LAYERS) {
67 if (contexts[i].stepCtx == NULL) {
85static FlowContext_t *getContextFromStepCtx(
nbgl_step_t stepCtx)
87 FlowContext_t *ctx = NULL;
89 while (i < NB_MAX_LAYERS) {
90 if (contexts[i].stepCtx == stepCtx) {
103static void drawStep(FlowContext_t *ctx,
111 if ((ctx->loop) && (ctx->nbSteps > 1)) {
120 =
nbgl_stepDrawText(pos, actionCallback, NULL, txt, subTxt, REGULAR_INFO, modal);
127 info.
style = REGULAR_INFO;
137 FlowContext_t *ctx = getContextFromStepCtx(stepCtx);
155 if (ctx->steps[ctx->curStep].callback != NULL) {
156 ctx->steps[ctx->curStep].callback();
164#ifdef HAVE_LANGUAGE_PACK
165 const char *txt = (step->
text != NULL)
167 : ((step->textId != INVALID_ID) ? get_ux_loc_string(step->textId) : NULL);
169 const char *txt = step->
text;
173 if (step->
init != NULL) {
176 drawStep(ctx, pos, ctx->modal, step->
icon, txt, step->
subText);
201#ifdef HAVE_LANGUAGE_PACK
202 const char *txt = (step->
text != NULL)
204 : ((step->textId != INVALID_ID) ? get_ux_loc_string(step->textId) : NULL);
206 const char *txt = step->
text;
209 FlowContext_t *ctx = getFreeContext(modal);
215 ctx->nbSteps = nbSteps;
216 ctx->curStep = initStep;
219 if (step->
init != NULL) {
223 drawStep(ctx, pos, ctx->modal, step->
icon, txt, step->
subText);
235 FlowContext_t *ctx = (FlowContext_t *) flow;
#define LOG_WARN(__logger,...)
#define LOG_DEBUG(__logger,...)
#define LOG_FATAL(__logger,...)
Flow construction API of NBGL.
void nbgl_flowRelease(nbgl_flow_t flow)
void * nbgl_flow_t
type shared externally
nbgl_flow_t nbgl_flowDraw(const nbgl_stepDesc_t *steps, uint8_t nbSteps, uint8_t initStep, bool loop, bool modal)
@ BUTTON_BOTH_PRESSED
Sent when both buttons are released.
@ BUTTON_LEFT_PRESSED
Sent when Left button is released.
@ BUTTON_RIGHT_PRESSED
Send when Right button is released.
#define GET_POS_OF_STEP(_step, _nb_steps)
void * nbgl_step_t
type shared externally
uint8_t nbgl_stepPosition_t
this type is a bitfield containing:
@ NEITHER_FIRST_NOR_LAST_STEP
neither first nor last in a multiple steps flow
int nbgl_stepRelease(nbgl_step_t step)
#define FORWARD_DIRECTION
When the flow is navigated from last to first step.
nbgl_step_t nbgl_stepDrawText(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, const char *text, const char *subText, nbgl_contentCenteredInfoStyle_t style, bool modal)
nbgl_step_t nbgl_stepDrawCenteredInfo(nbgl_stepPosition_t pos, nbgl_stepButtonCallback_t onActionCallback, nbgl_screenTickerConfiguration_t *ticker, nbgl_layoutCenteredInfo_t *info, bool modal)
#define BACKWARD_DIRECTION
When action callback applies on any button press.
struct PACKED__ nbgl_icon_details_s nbgl_icon_details_t
Represents all information about an icon.
This structure contains info to build a centered (vertically and horizontally) area,...
const char * text2
second text (can be null)
const char * text1
first text (can be null)
bool onTop
if set to true, align only horizontally
nbgl_contentCenteredInfoStyle_t style
style to apply to this info
const nbgl_icon_details_t * icon
a buffer containing the 1BPP icon
Structure containing all specific information when creating a NBGL step.
const char * subText
sub-text to display in step (NULL most of the time)
const nbgl_icon_details_t * icon
icon to display in step (text must be single-page)
nbgl_stepCallback_t init
if not NULL, function to be called when the step is entered
const char * text
text to display in step (can be multi-pages if icon == NULL)