[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:
7
applications/nfc/nfc.c
Normal file → Executable file
7
applications/nfc/nfc.c
Normal file → Executable file
@@ -7,10 +7,10 @@ bool nfc_custom_event_callback(void* context, uint32_t event) {
|
||||
return scene_manager_handle_custom_event(nfc->scene_manager, event);
|
||||
}
|
||||
|
||||
bool nfc_navigation_event_callback(void* context) {
|
||||
bool nfc_back_event_callback(void* context) {
|
||||
furi_assert(context);
|
||||
Nfc* nfc = (Nfc*)context;
|
||||
return scene_manager_handle_navigation_event(nfc->scene_manager);
|
||||
return scene_manager_handle_back_event(nfc->scene_manager);
|
||||
}
|
||||
|
||||
void nfc_tick_event_callback(void* context) {
|
||||
@@ -28,8 +28,7 @@ Nfc* nfc_alloc() {
|
||||
view_dispatcher_enable_queue(nfc->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(nfc->view_dispatcher, nfc);
|
||||
view_dispatcher_set_custom_event_callback(nfc->view_dispatcher, nfc_custom_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
nfc->view_dispatcher, nfc_navigation_event_callback);
|
||||
view_dispatcher_set_navigation_event_callback(nfc->view_dispatcher, nfc_back_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(nfc->view_dispatcher, nfc_tick_event_callback, 100);
|
||||
|
||||
// Open GUI record
|
||||
|
@@ -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
3
applications/nfc/scenes/nfc_scene_delete.c
Normal file → Executable 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
3
applications/nfc/scenes/nfc_scene_delete_success.c
Normal file → Executable 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;
|
||||
|
@@ -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
5
applications/nfc/scenes/nfc_scene_mifare_ul_menu.c
Normal file → Executable 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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user