[FL-1543] Scene manager search scene API (#611)

* scene_manager: search -> search_and_switch_to previous_scene
* scene_manager: add search and switch to another scene API
* scene_manager: Navigation -> Back event
This commit is contained in:
gornekich
2021-07-28 17:52:00 +03:00
committed by GitHub
parent 1c58de24f5
commit 91c1eaf5a8
14 changed files with 116 additions and 37 deletions

View File

@@ -70,8 +70,9 @@ const bool nfc_scene_card_menu_on_event(void* context, SceneManagerEvent event)
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
return true;
}
} else if(event.type == SceneManagerEventTypeNavigation) {
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
} else if(event.type == SceneManagerEventTypeBack) {
return scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);
}
return false;

3
applications/nfc/scenes/nfc_scene_delete.c Normal file → Executable file
View File

@@ -75,7 +75,8 @@ const bool nfc_scene_delete_on_event(void* context, SceneManagerEvent event) {
if(nfc_device_delete(&nfc->dev)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneDeleteSuccess);
} else {
scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);
}
return true;
}

3
applications/nfc/scenes/nfc_scene_delete_success.c Normal file → Executable file
View File

@@ -26,7 +26,8 @@ const bool nfc_scene_delete_success_on_event(void* context, SceneManagerEvent ev
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
return scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);
}
}
return false;

View File

@@ -6,7 +6,7 @@ const void nfc_scene_file_select_on_enter(void* context) {
if(nfc_file_select(&nfc->dev)) {
scene_manager_next_scene(nfc->scene_manager, NfcSceneSavedMenu);
} else {
scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
scene_manager_search_and_switch_to_previous_scene(nfc->scene_manager, NfcSceneStart);
}
}

5
applications/nfc/scenes/nfc_scene_mifare_ul_menu.c Normal file → Executable file
View File

@@ -41,8 +41,9 @@ const bool nfc_scene_mifare_ul_menu_on_event(void* context, SceneManagerEvent ev
scene_manager_next_scene(nfc->scene_manager, NfcSceneNotImplemented);
return true;
}
} else if(event.type == SceneManagerEventTypeNavigation) {
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
} else if(event.type == SceneManagerEventTypeBack) {
return scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);
}
return false;

View File

@@ -68,15 +68,16 @@ const bool nfc_scene_read_emv_data_success_on_event(void* context, SceneManagerE
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == GuiButtonTypeLeft) {
return scene_manager_search_previous_scene(
return scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneReadEmvAppSuccess);
} else if(event.event == GuiButtonTypeRight) {
nfc->dev.format = NfcDeviceSaveFormatBankCard;
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
return true;
}
} else if(event.type == SceneManagerEventTypeNavigation) {
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneReadEmvAppSuccess);
} else if(event.type == SceneManagerEventTypeBack) {
return scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneReadEmvAppSuccess);
}
return false;
}

View File

@@ -45,7 +45,8 @@ const bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event)
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveSuccess);
return true;
} else {
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
return scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);
}
}
}

View File

@@ -23,13 +23,23 @@ const void nfc_scene_save_success_on_enter(void* context) {
const bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) {
Nfc* nfc = (Nfc*)context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SCENE_SAVE_SUCCESS_CUSTOM_EVENT) {
return scene_manager_search_previous_scene(nfc->scene_manager, NfcSceneStart);
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneCardMenu)) {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneCardMenu);
} else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) {
consumed = scene_manager_search_and_switch_to_another_scene(
nfc->scene_manager, NfcSceneFileSelect);
} else {
consumed = scene_manager_search_and_switch_to_previous_scene(
nfc->scene_manager, NfcSceneStart);
}
}
}
return false;
return consumed;
}
const void nfc_scene_save_success_on_exit(void* context) {