Skip to content

Commit

Permalink
Merge pull request #64 from blooo-io/fix/LDG-631-fix-main-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
n4l5u0r authored Dec 17, 2024
2 parents cda06e7 + aac63c1 commit df3e4d2
Show file tree
Hide file tree
Showing 72 changed files with 4 additions and 115 deletions.
96 changes: 1 addition & 95 deletions src/common/ui/menu_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,115 +37,21 @@ void app_quit(void) {
#define SETTING_INFO_NB 2
static const char* const INFO_TYPES[SETTING_INFO_NB] = {"Version", "Developer"};
static const char* const INFO_CONTENTS[SETTING_INFO_NB] = {APPVERSION, "Blooo"};

// settings switches definitions
enum { DUMMY_SWITCH_1_TOKEN = FIRST_USER_TOKEN, DUMMY_SWITCH_2_TOKEN };
enum { DUMMY_SWITCH_1_ID = 0, DUMMY_SWITCH_2_ID, SETTINGS_SWITCHES_NB };

static nbgl_contentSwitch_t switches[SETTINGS_SWITCHES_NB] = {0};

static const nbgl_contentInfoList_t infoList = {
.nbInfos = SETTING_INFO_NB,
.infoTypes = INFO_TYPES,
.infoContents = INFO_CONTENTS,
};

static uint8_t initSettingPage;
static void review_warning_choice(bool confirm);
static void controls_callback(int token, uint8_t index, int page);

// settings menu definition
#define SETTING_CONTENTS_NB 1
static const nbgl_content_t contents[SETTING_CONTENTS_NB] = {
{.type = SWITCHES_LIST,
.content.switchesList.nbSwitches = SETTINGS_SWITCHES_NB,
.content.switchesList.switches = switches,
.contentActionCallback = controls_callback}};

static const nbgl_genericContents_t settingContents = {.callbackCallNeeded = false,
.contentsList = contents,
.nbContents = SETTING_CONTENTS_NB};

// callback for setting warning choice
static void review_warning_choice(bool confirm) {
uint8_t switch_value;
if (confirm) {
// toggle the switch value
switch_value = !N_storage.dummy2_allowed;
switches[DUMMY_SWITCH_2_ID].initState = (nbgl_state_t)switch_value;
// store the new setting value in NVM
nvm_write((void*)&N_storage.dummy2_allowed, &switch_value, 1);
}

// Reset setting menu to the right page
nbgl_useCaseHomeAndSettings(APPNAME,
&C_app_concordium_64px,
NULL,
initSettingPage,
&settingContents,
&infoList,
NULL,
app_quit);
}

static void controls_callback(int token, uint8_t index, int page) {
UNUSED(index);

initSettingPage = page;

uint8_t switch_value;
if (token == DUMMY_SWITCH_1_TOKEN) {
// Dummy 1 switch touched
// toggle the switch value
switch_value = !N_storage.dummy1_allowed;
switches[DUMMY_SWITCH_1_ID].initState = (nbgl_state_t)switch_value;
// store the new setting value in NVM
nvm_write((void*)&N_storage.dummy1_allowed, &switch_value, 1);
} else if (token == DUMMY_SWITCH_2_TOKEN) {
// Dummy 2 switch touched

// in this example we display a warning when the user wants
// to activate the dummy 2 setting
if (!N_storage.dummy2_allowed) {
// Display the warning message and ask the user to confirm
nbgl_useCaseChoice(&C_Warning_64px,
"Dummy 2",
"Are you sure to\nallow dummy 2\nin transactions?",
"I understand, confirm",
"Cancel",
review_warning_choice);
} else {
// toggle the switch value
switch_value = !N_storage.dummy2_allowed;
switches[DUMMY_SWITCH_2_ID].initState = (nbgl_state_t)switch_value;
// store the new setting value in NVM
nvm_write((void*)&N_storage.dummy2_allowed, &switch_value, 1);
}
}
}

// home page definition
void ui_menu_main(void) {
tx_state->currentInstruction = -1;

// Initialize switches data
switches[DUMMY_SWITCH_1_ID].initState = (nbgl_state_t)N_storage.dummy1_allowed;
switches[DUMMY_SWITCH_1_ID].text = "Dummy 1";
switches[DUMMY_SWITCH_1_ID].subText = "Allow dummy 1\nin transactions";
switches[DUMMY_SWITCH_1_ID].token = DUMMY_SWITCH_1_TOKEN;
switches[DUMMY_SWITCH_1_ID].tuneId = TUNE_TAP_CASUAL;

switches[DUMMY_SWITCH_2_ID].initState = (nbgl_state_t)N_storage.dummy2_allowed;
switches[DUMMY_SWITCH_2_ID].text = "Dummy 2";
switches[DUMMY_SWITCH_2_ID].subText = "Allow dummy 2\nin transactions";
switches[DUMMY_SWITCH_2_ID].token = DUMMY_SWITCH_2_TOKEN;
switches[DUMMY_SWITCH_2_ID].tuneId = TUNE_TAP_CASUAL;

nbgl_useCaseHomeAndSettings(APPNAME,
&C_app_concordium_64px,
NULL,
INIT_HOME_PAGE,
&settingContents,
NULL,
&infoList,
NULL,
app_quit);
Expand Down
Binary file modified tests/snapshots/flex/test_app_mainmenu/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_app_mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_app_mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_deploy_module/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_get_public_key_confirm_refused/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_init_contract/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_sign_configure_baker_only_keys/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_sign_configure_baker_url_only/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/flex/test_transfer_to_public/00003.png
Binary file modified tests/snapshots/flex/test_update_contract/00004.png
Binary file modified tests/snapshots/flex/test_verify_address_confirm_refused/00004.png
Binary file modified tests/snapshots/stax/test_app_mainmenu/00000.png
Binary file modified tests/snapshots/stax/test_app_mainmenu/00001.png
Binary file modified tests/snapshots/stax/test_app_mainmenu/00002.png
Binary file modified tests/snapshots/stax/test_deploy_module/00003.png
Binary file modified tests/snapshots/stax/test_get_public_key_confirm_refused/00002.png
Binary file modified tests/snapshots/stax/test_init_contract/00004.png
Binary file modified tests/snapshots/stax/test_sign_configure_baker_only_keys/00003.png
Binary file modified tests/snapshots/stax/test_sign_configure_baker_url_only/00004.png
Binary file modified tests/snapshots/stax/test_transfer_to_public/00003.png
Binary file modified tests/snapshots/stax/test_update_contract/00003.png
Binary file modified tests/snapshots/stax/test_verify_address_confirm_refused/00004.png
23 changes: 3 additions & 20 deletions tests/test_app_mainmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,9 @@ def test_app_mainmenu(firmware, navigator, test_name, default_screenshot_path):
NavInsID.RIGHT_CLICK,
NavInsID.RIGHT_CLICK,
]
elif firmware is Firmware.STAX:
instructions = [
NavInsID.USE_CASE_HOME_SETTINGS,
NavIns(NavInsID.TOUCH, (200, 113)),
NavIns(NavInsID.TOUCH, (200, 261)),
NavInsID.USE_CASE_CHOICE_CONFIRM,
NavIns(NavInsID.TOUCH, (200, 261)),
NavInsID.USE_CASE_SETTINGS_NEXT,
NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT,
]
elif firmware is Firmware.FLEX:
instructions = [
NavInsID.USE_CASE_HOME_SETTINGS,
NavIns(NavInsID.TOUCH, (200, 113)),
NavIns(NavInsID.TOUCH, (200, 300)),
NavInsID.USE_CASE_CHOICE_CONFIRM,
NavIns(NavInsID.TOUCH, (200, 300)),
NavInsID.USE_CASE_SETTINGS_NEXT,
NavInsID.USE_CASE_SETTINGS_MULTI_PAGE_EXIT,
]
else:
instructions = [NavInsID.USE_CASE_HOME_SETTINGS, NavInsID.LEFT_HEADER_TAP]

navigator.navigate_and_compare(
default_screenshot_path,
test_name,
Expand Down

0 comments on commit df3e4d2

Please sign in to comment.