2022-03-23 13:45:37 +00:00
|
|
|
#include "../nfc_i.h"
|
|
|
|
|
|
|
|
enum SubmenuIndex {
|
|
|
|
SubmenuIndexSave,
|
|
|
|
};
|
|
|
|
|
|
|
|
void nfc_scene_mifare_desfire_menu_submenu_callback(void* context, uint32_t index) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 13:45:37 +00:00
|
|
|
|
|
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_mifare_desfire_menu_on_enter(void* context) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 13:45:37 +00:00
|
|
|
Submenu* submenu = nfc->submenu;
|
|
|
|
|
|
|
|
submenu_add_item(
|
2022-04-11 11:54:38 +00:00
|
|
|
submenu, "Save", SubmenuIndexSave, nfc_scene_mifare_desfire_menu_submenu_callback, nfc);
|
2022-03-23 13:45:37 +00: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 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
|
|
|
bool consumed = false;
|
2022-03-23 13:45:37 +00: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 15:23:58 +00:00
|
|
|
consumed = true;
|
2022-03-23 13:45:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-19 15:23:58 +00:00
|
|
|
return consumed;
|
2022-03-23 13:45:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_mifare_desfire_menu_on_exit(void* context) {
|
2022-04-19 15:23:58 +00:00
|
|
|
Nfc* nfc = context;
|
2022-03-23 13:45:37 +00:00
|
|
|
|
2022-04-19 15:23:58 +00:00
|
|
|
// Clear view
|
2022-03-23 13:45:37 +00:00
|
|
|
submenu_reset(nfc->submenu);
|
|
|
|
}
|