diff --git a/app/glyphs/tezos_16px.gif b/app/glyphs/tezos_16px.gif new file mode 100644 index 000000000..8aa134eaa Binary files /dev/null and b/app/glyphs/tezos_16px.gif differ diff --git a/app/src/globals.h b/app/src/globals.h index d852ed245..3bb6954f3 100644 --- a/app/src/globals.h +++ b/app/src/globals.h @@ -112,6 +112,8 @@ typedef struct { struct { bagl_element_t bagls[4 + TZ_SCREEN_LINES_11PX]; } ux; /// Config for history screens for nano devices. + char expert_mode_state[10]; /// Expert mode state to be displayed in + /// settings.ENAELED/DISABLED. #endif #ifdef HAVE_NBGL diff --git a/app/src/ui_home.c b/app/src/ui_home.c index 5b2d145ad..06c701187 100644 --- a/app/src/ui_home.c +++ b/app/src/ui_home.c @@ -22,53 +22,46 @@ #include "app_main.h" #include "globals.h" #include "ui_home_nbgl.h" +#include "os.h" +#include "ux.h" +#include "glyphs.h" #ifdef HAVE_BAGL /* Prototypes */ static void cb(tz_ui_cb_type_t cb_type); -/** - * @brief Callback for home screen stream. - * - * @param cb_type one of the 4 home screens (HOME, VERSION, SETTINGS, QUIT) */ -static void -cb(tz_ui_cb_type_t cb_type) -{ - FUNC_ENTER(("cb_type=%u", cb_type)); - - switch (cb_type) { - case SCREEN_HOME: - case SCREEN_VERSION: - break; - case SCREEN_SETTINGS: - ui_settings_init(SETTINGS_HOME_PAGE); - break; - case SCREEN_QUIT: - app_exit(); - } - FUNC_LEAVE(); -} -#endif // HAVE_BAGL +UX_STEP_NOCB(ux_menu_ready_step, pnn,{&C_tezos_16px , "Application", "is ready"}); +UX_STEP_NOCB(ux_menu_version_step, bn, {"Version", APPVERSION}); +UX_STEP_CB(ux_menu_settings_step, pb, ui_settings_init(SETTINGS_HOME_PAGE), {&C_icon_coggle, "Settings"}); +UX_STEP_VALID(ux_menu_exit_step, pb, os_sched_exit(-1), {&C_icon_dashboard_x, "Quit"}); +// FLOW for the main menu: +// #1 screen: ready +// #2 screen: version of the app +// #3 screen: about submenu +// #4 screen: quit +UX_FLOW(ux_menu_main_flow, + &ux_menu_ready_step, + &ux_menu_version_step, + &ux_menu_settings_step, + &ux_menu_exit_step, + FLOW_LOOP); + +#endif // HAVE_BAGL void ui_home_init(void) { FUNC_ENTER(("void")); #ifdef HAVE_BAGL - tz_ui_stream_init(cb); - tz_ui_stream_push(SCREEN_HOME, "Application", "is ready", - TZ_UI_LAYOUT_HOME_N, TZ_UI_ICON_NONE); - tz_ui_stream_push(SCREEN_VERSION, "Version", APPVERSION, - TZ_UI_LAYOUT_HOME_BN, TZ_UI_ICON_NONE); - tz_ui_stream_push(SCREEN_SETTINGS, "Settings", "", TZ_UI_LAYOUT_HOME_PB, - TZ_UI_ICON_SETTINGS); - tz_ui_stream_push(SCREEN_QUIT, "Quit?", "", TZ_UI_LAYOUT_HOME_PB, - TZ_UI_ICON_DASHBOARD); - tz_ui_stream_close(); - tz_ui_stream_start(); + if (G_ux.stack_count == 0) { + ux_stack_push(); + } + + ux_flow_init(0, ux_menu_main_flow, NULL); + #elif defined(HAVE_NBGL) tz_ui_home_redisplay(); #endif diff --git a/app/src/ui_settings.c b/app/src/ui_settings.c index b6ff5c9de..a87f1512b 100644 --- a/app/src/ui_settings.c +++ b/app/src/ui_settings.c @@ -21,44 +21,34 @@ #include "globals.h" -static void cb(tz_ui_cb_type_t cb_type); - -#define EXPERT_MODE 0x01 -#define BACK 0x02 - static void -cb(tz_ui_cb_type_t cb_type) +expert_mode_toggle() { - FUNC_ENTER(("cb_type=%u", cb_type)); - switch (cb_type) { - case EXPERT_MODE: - toggle_expert_mode(); - ui_settings_init(SETTINGS_HOME_PAGE); - break; - case BACK: - ui_home_init(); - break; - } + FUNC_ENTER(); + toggle_expert_mode(); + ui_settings_init(SETTINGS_HOME_PAGE); + FUNC_LEAVE(); } +UX_STEP_CB(ux_expert_mode_step, bn, expert_mode_toggle(), {"Expert mode", global.expert_mode_state}); +UX_STEP_CB(ux_back_step, pb, ui_home_init(), {&C_icon_back, "Back"}); + +UX_FLOW(ux_expert_mode_flow, + &ux_expert_mode_step, + &ux_back_step, + FLOW_LOOP); + void ui_settings_init(int16_t page) { - const char *exp_mode = "DISABLED"; + strncpy(global.expert_mode_state,"DISABLED", sizeof(global.expert_mode_state)); FUNC_ENTER(("void")); if (N_settings.expert_mode) { - exp_mode = "ENABLED"; + strncpy(global.expert_mode_state, "ENABLED", sizeof(global.expert_mode_state)); } - tz_ui_stream_init(cb); - tz_ui_stream_push(EXPERT_MODE, "Expert mode", exp_mode, - TZ_UI_LAYOUT_HOME_BN, TZ_UI_ICON_NONE); - tz_ui_stream_push(BACK, "Back", "", TZ_UI_LAYOUT_HOME_PB, - TZ_UI_ICON_BACK); - tz_ui_stream_close(); - global.stream.current = page; - tz_ui_stream_start(); + ux_flow_init(0, ux_expert_mode_flow, NULL); FUNC_LEAVE(); } diff --git a/tests/integration/nano/snapshots/nanos/back.png b/tests/integration/nano/snapshots/nanos/back.png index 7bbfa7095..b5c1b1cbe 100644 Binary files a/tests/integration/nano/snapshots/nanos/back.png and b/tests/integration/nano/snapshots/nanos/back.png differ diff --git a/tests/integration/nano/snapshots/nanos/home.png b/tests/integration/nano/snapshots/nanos/home.png index 37183b78b..056ffc401 100644 Binary files a/tests/integration/nano/snapshots/nanos/home.png and b/tests/integration/nano/snapshots/nanos/home.png differ diff --git a/tests/integration/nano/snapshots/nanos/quit.png b/tests/integration/nano/snapshots/nanos/quit.png index 6e442b793..e2279803e 100644 Binary files a/tests/integration/nano/snapshots/nanos/quit.png and b/tests/integration/nano/snapshots/nanos/quit.png differ diff --git a/tests/integration/nano/snapshots/nanos/settings.png b/tests/integration/nano/snapshots/nanos/settings.png index 60133e61c..34cf547a2 100644 Binary files a/tests/integration/nano/snapshots/nanos/settings.png and b/tests/integration/nano/snapshots/nanos/settings.png differ diff --git a/tests/integration/nano/snapshots/nanos/settings_expert_mode_disabled.png b/tests/integration/nano/snapshots/nanos/settings_expert_mode_disabled.png index e14c6998a..a10bdaeac 100644 Binary files a/tests/integration/nano/snapshots/nanos/settings_expert_mode_disabled.png and b/tests/integration/nano/snapshots/nanos/settings_expert_mode_disabled.png differ diff --git a/tests/integration/nano/snapshots/nanos/settings_expert_mode_enabled.png b/tests/integration/nano/snapshots/nanos/settings_expert_mode_enabled.png index 363c6c9bb..1b968b6c2 100644 Binary files a/tests/integration/nano/snapshots/nanos/settings_expert_mode_enabled.png and b/tests/integration/nano/snapshots/nanos/settings_expert_mode_enabled.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_parsing_errors/wrong_last_packet/00012.png b/tests/integration/nano/snapshots/nanos/test_parsing_errors/wrong_last_packet/00012.png index 37183b78b..056ffc401 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_parsing_errors/wrong_last_packet/00012.png and b/tests/integration/nano/snapshots/nanos/test_parsing_errors/wrong_last_packet/00012.png differ diff --git a/tests/integration/nano/snapshots/nanos/version.png b/tests/integration/nano/snapshots/nanos/version.png index b3aaadcc8..c2181ffc0 100644 Binary files a/tests/integration/nano/snapshots/nanos/version.png and b/tests/integration/nano/snapshots/nanos/version.png differ diff --git a/tests/integration/nano/snapshots/nanosp/back.png b/tests/integration/nano/snapshots/nanosp/back.png index 5da237b76..e06738f46 100644 Binary files a/tests/integration/nano/snapshots/nanosp/back.png and b/tests/integration/nano/snapshots/nanosp/back.png differ diff --git a/tests/integration/nano/snapshots/nanosp/home.png b/tests/integration/nano/snapshots/nanosp/home.png index 39ed6ff59..13403d2eb 100644 Binary files a/tests/integration/nano/snapshots/nanosp/home.png and b/tests/integration/nano/snapshots/nanosp/home.png differ diff --git a/tests/integration/nano/snapshots/nanosp/quit.png b/tests/integration/nano/snapshots/nanosp/quit.png index 24033fcb8..bcb20c683 100644 Binary files a/tests/integration/nano/snapshots/nanosp/quit.png and b/tests/integration/nano/snapshots/nanosp/quit.png differ diff --git a/tests/integration/nano/snapshots/nanosp/settings.png b/tests/integration/nano/snapshots/nanosp/settings.png index 99d3e4228..d885fe67b 100644 Binary files a/tests/integration/nano/snapshots/nanosp/settings.png and b/tests/integration/nano/snapshots/nanosp/settings.png differ diff --git a/tests/integration/nano/snapshots/nanosp/settings_expert_mode_disabled.png b/tests/integration/nano/snapshots/nanosp/settings_expert_mode_disabled.png index f19ea84c9..c38eac887 100644 Binary files a/tests/integration/nano/snapshots/nanosp/settings_expert_mode_disabled.png and b/tests/integration/nano/snapshots/nanosp/settings_expert_mode_disabled.png differ diff --git a/tests/integration/nano/snapshots/nanosp/settings_expert_mode_enabled.png b/tests/integration/nano/snapshots/nanosp/settings_expert_mode_enabled.png index 90dc4e8dc..7adaf2fb3 100644 Binary files a/tests/integration/nano/snapshots/nanosp/settings_expert_mode_enabled.png and b/tests/integration/nano/snapshots/nanosp/settings_expert_mode_enabled.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_parsing_errors/wrong_last_packet/00007.png b/tests/integration/nano/snapshots/nanosp/test_parsing_errors/wrong_last_packet/00007.png index 39ed6ff59..13403d2eb 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_parsing_errors/wrong_last_packet/00007.png and b/tests/integration/nano/snapshots/nanosp/test_parsing_errors/wrong_last_packet/00007.png differ diff --git a/tests/integration/nano/snapshots/nanosp/version.png b/tests/integration/nano/snapshots/nanosp/version.png index 1d2e46068..e7e6e3a69 100644 Binary files a/tests/integration/nano/snapshots/nanosp/version.png and b/tests/integration/nano/snapshots/nanosp/version.png differ diff --git a/tests/integration/nano/snapshots/nanox/back.png b/tests/integration/nano/snapshots/nanox/back.png index 5da237b76..e06738f46 100644 Binary files a/tests/integration/nano/snapshots/nanox/back.png and b/tests/integration/nano/snapshots/nanox/back.png differ diff --git a/tests/integration/nano/snapshots/nanox/home.png b/tests/integration/nano/snapshots/nanox/home.png index 39ed6ff59..13403d2eb 100644 Binary files a/tests/integration/nano/snapshots/nanox/home.png and b/tests/integration/nano/snapshots/nanox/home.png differ diff --git a/tests/integration/nano/snapshots/nanox/quit.png b/tests/integration/nano/snapshots/nanox/quit.png index 24033fcb8..bcb20c683 100644 Binary files a/tests/integration/nano/snapshots/nanox/quit.png and b/tests/integration/nano/snapshots/nanox/quit.png differ diff --git a/tests/integration/nano/snapshots/nanox/settings.png b/tests/integration/nano/snapshots/nanox/settings.png index 99d3e4228..d885fe67b 100644 Binary files a/tests/integration/nano/snapshots/nanox/settings.png and b/tests/integration/nano/snapshots/nanox/settings.png differ diff --git a/tests/integration/nano/snapshots/nanox/settings_expert_mode_disabled.png b/tests/integration/nano/snapshots/nanox/settings_expert_mode_disabled.png index f19ea84c9..c38eac887 100644 Binary files a/tests/integration/nano/snapshots/nanox/settings_expert_mode_disabled.png and b/tests/integration/nano/snapshots/nanox/settings_expert_mode_disabled.png differ diff --git a/tests/integration/nano/snapshots/nanox/settings_expert_mode_enabled.png b/tests/integration/nano/snapshots/nanox/settings_expert_mode_enabled.png index 90dc4e8dc..7adaf2fb3 100644 Binary files a/tests/integration/nano/snapshots/nanox/settings_expert_mode_enabled.png and b/tests/integration/nano/snapshots/nanox/settings_expert_mode_enabled.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_parsing_errors/wrong_last_packet/00007.png b/tests/integration/nano/snapshots/nanox/test_parsing_errors/wrong_last_packet/00007.png index 39ed6ff59..13403d2eb 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_parsing_errors/wrong_last_packet/00007.png and b/tests/integration/nano/snapshots/nanox/test_parsing_errors/wrong_last_packet/00007.png differ diff --git a/tests/integration/nano/snapshots/nanox/version.png b/tests/integration/nano/snapshots/nanox/version.png index 1d2e46068..e7e6e3a69 100644 Binary files a/tests/integration/nano/snapshots/nanox/version.png and b/tests/integration/nano/snapshots/nanox/version.png differ diff --git a/tests/integration/nano/test_basic.py b/tests/integration/nano/test_basic.py index 2437dee22..08d19eba9 100755 --- a/tests/integration/nano/test_basic.py +++ b/tests/integration/nano/test_basic.py @@ -32,10 +32,12 @@ def test_basic(app): app.assert_screen(Screen.Version) app.backend.left_click() app.assert_screen(Screen.Home) - app.backend.left_click() - app.assert_screen(Screen.Home) app.backend.both_click() app.assert_screen(Screen.Home) + app.backend.left_click() + app.assert_screen(Screen.Quit) + app.backend.right_click() + app.assert_screen(Screen.Home) app.backend.right_click() app.assert_screen(Screen.Version) app.backend.right_click() @@ -43,10 +45,12 @@ def test_basic(app): app.backend.right_click() app.assert_screen(Screen.Quit) app.backend.right_click() - app.assert_screen(Screen.Quit) + app.assert_screen(Screen.Home) + app.backend.right_click() + app.assert_screen(Screen.Version) # Check Settings menu operation - app.backend.left_click() + app.backend.right_click() app.assert_screen(Screen.Settings) app.backend.both_click() app.assert_screen(Screen.Settings_expert_mode_disabled) @@ -62,7 +66,5 @@ def test_basic(app): app.assert_screen(Screen.Settings_back) app.backend.both_click() app.assert_screen(Screen.Home) - app.backend.right_click() - app.backend.right_click() - app.backend.right_click() + app.backend.left_click() app._quit()