2022-10-21 18:00:59 +02:00
|
|
|
#ifdef HAVE_EIP712_FULL_SUPPORT
|
2020-09-26 15:49:36 +02:00
|
|
|
|
2022-10-21 18:00:59 +02:00
|
|
|
#include "ui_logic.h"
|
|
|
|
|
#include "shared_context.h" // strings
|
|
|
|
|
|
|
|
|
|
enum { UI_712_POS_REVIEW, UI_712_POS_END };
|
|
|
|
|
static uint8_t ui_pos;
|
2020-09-26 15:49:36 +02:00
|
|
|
|
2022-10-21 18:00:59 +02:00
|
|
|
static void dummy_cb(void) {
|
2022-11-18 11:26:06 +01:00
|
|
|
switch (ui_712_next_field()) {
|
|
|
|
|
case EIP712_NO_MORE_FIELD:
|
|
|
|
|
if (ui_pos == UI_712_POS_REVIEW) {
|
|
|
|
|
ux_flow_next();
|
|
|
|
|
ui_pos = UI_712_POS_END;
|
2024-07-24 10:02:54 +02:00
|
|
|
} else {
|
|
|
|
|
// Keep user at the end of the flow
|
|
|
|
|
ux_flow_next();
|
2022-11-18 11:26:06 +01:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case EIP712_FIELD_INCOMING:
|
|
|
|
|
// temporarily disable button clicks, they will be re-enabled as soon as new data
|
|
|
|
|
// is received and the page is redrawn with ux_flow_init()
|
|
|
|
|
G_ux.stack[0].button_push_callback = NULL;
|
|
|
|
|
break;
|
|
|
|
|
case EIP712_FIELD_LATER:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2022-10-21 18:00:59 +02:00
|
|
|
}
|
2020-09-26 15:49:36 +02:00
|
|
|
}
|
|
|
|
|
|
2020-12-01 16:20:13 +01:00
|
|
|
// clang-format off
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_NOCB(
|
2022-10-21 18:00:59 +02:00
|
|
|
ux_712_step_review,
|
2020-09-26 15:49:36 +02:00
|
|
|
pnn,
|
|
|
|
|
{
|
2022-10-21 18:00:59 +02:00
|
|
|
&C_icon_eye,
|
|
|
|
|
"Review",
|
2020-09-26 15:49:36 +02:00
|
|
|
"typed message",
|
|
|
|
|
});
|
2022-10-21 18:00:59 +02:00
|
|
|
UX_STEP_NOCB(
|
|
|
|
|
ux_712_step_dynamic,
|
|
|
|
|
bnnn_paging,
|
|
|
|
|
{
|
|
|
|
|
.title = strings.tmp.tmp2,
|
2020-09-26 15:49:36 +02:00
|
|
|
.text = strings.tmp.tmp,
|
2022-10-21 18:00:59 +02:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
UX_STEP_INIT(
|
|
|
|
|
ux_712_step_dummy,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
{
|
|
|
|
|
dummy_cb();
|
|
|
|
|
}
|
|
|
|
|
);
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2022-10-21 18:00:59 +02:00
|
|
|
ux_712_step_approve,
|
|
|
|
|
pb,
|
2024-04-12 16:40:05 +02:00
|
|
|
ui_712_approve(),
|
2020-09-26 15:49:36 +02:00
|
|
|
{
|
|
|
|
|
&C_icon_validate_14,
|
2022-10-21 18:00:59 +02:00
|
|
|
"Approve",
|
2020-09-26 15:49:36 +02:00
|
|
|
});
|
2020-10-20 15:40:31 +02:00
|
|
|
UX_STEP_CB(
|
2022-10-21 18:00:59 +02:00
|
|
|
ux_712_step_reject,
|
|
|
|
|
pb,
|
2024-04-12 16:40:05 +02:00
|
|
|
ui_712_reject(),
|
2020-09-26 15:49:36 +02:00
|
|
|
{
|
|
|
|
|
&C_icon_crossmark,
|
2022-10-21 18:00:59 +02:00
|
|
|
"Reject",
|
2020-09-26 15:49:36 +02:00
|
|
|
});
|
2020-12-01 16:20:13 +01:00
|
|
|
// clang-format on
|
2020-09-26 15:49:36 +02:00
|
|
|
|
2022-10-21 18:00:59 +02:00
|
|
|
UX_FLOW(ux_712_flow,
|
|
|
|
|
&ux_712_step_review,
|
|
|
|
|
&ux_712_step_dynamic,
|
|
|
|
|
&ux_712_step_dummy,
|
|
|
|
|
&ux_712_step_approve,
|
|
|
|
|
&ux_712_step_reject);
|
|
|
|
|
|
|
|
|
|
void ui_712_start(void) {
|
|
|
|
|
ux_flow_init(0, ux_712_flow, NULL);
|
|
|
|
|
ui_pos = UI_712_POS_REVIEW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui_712_switch_to_message(void) {
|
|
|
|
|
ux_flow_init(0, ux_712_flow, &ux_712_step_dynamic);
|
|
|
|
|
ui_pos = UI_712_POS_REVIEW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ui_712_switch_to_sign(void) {
|
|
|
|
|
ux_flow_init(0, ux_712_flow, &ux_712_step_approve);
|
|
|
|
|
ui_pos = UI_712_POS_END;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // HAVE_EIP712_FULL_SUPPORT
|