2022-03-23 16:45:37 +03:00
|
|
|
#include "../nfc_i.h"
|
|
|
|
|
|
|
|
enum SubmenuIndex {
|
|
|
|
SubmenuIndexSave,
|
|
|
|
};
|
|
|
|
|
|
|
|
void nfc_scene_mifare_desfire_menu_submenu_callback(void* context, uint32_t index) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 16:45:37 +03:00
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_mifare_desfire_menu_on_enter(void* context) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 16:45:37 +03:00
|
|
|
Submenu* submenu = nfc->submenu;
|
|
|
|
|
|
|
|
submenu_add_item(
|
2022-04-11 14:54:38 +03:00
|
|
|
submenu, "Save", SubmenuIndexSave, nfc_scene_mifare_desfire_menu_submenu_callback, nfc);
|
2022-03-23 16:45:37 +03:00
|
|
|
submenu_set_selected_item(
|
|
|
|
nfc->submenu,
|
|
|
|
scene_manager_get_scene_state(nfc->scene_manager, NfcSceneMifareDesfireMenu));
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nfc_scene_mifare_desfire_menu_on_event(void* context, SceneManagerEvent event) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
|
|
|
bool consumed = false;
|
2022-03-23 16:45:37 +03:00
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
if(event.event == SubmenuIndexSave) {
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
nfc->scene_manager, NfcSceneMifareDesfireMenu, SubmenuIndexSave);
|
|
|
|
nfc->dev->format = NfcDeviceSaveFormatMifareDesfire;
|
|
|
|
// Clear device name
|
|
|
|
nfc_device_set_name(nfc->dev, "");
|
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneSaveName);
|
2022-04-19 18:23:58 +03:00
|
|
|
consumed = true;
|
2022-03-23 16:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-19 18:23:58 +03:00
|
|
|
return consumed;
|
2022-03-23 16:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_mifare_desfire_menu_on_exit(void* context) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 16:45:37 +03:00
|
|
|
|
2022-04-19 18:23:58 +03:00
|
|
|
// Clear view
|
2022-03-23 16:45:37 +03:00
|
|
|
submenu_reset(nfc->submenu);
|
|
|
|
}
|