mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-24 11:43:09 +00:00
7a13391b2b
* File worker: file operations helper. * Notification app: removed yield * File worker: write operations, calls to system file widgets * App ibutton: use file worker * Lfrfid: generic key loading, add path helper and hex conversion to lib * FileWorker: plain C verison * FileWorker: add to lib.mk * FileWorker: add to C sources, instead of CPP * Lfrfid: save scene * App lfrfid: add key scene, saved key menu * App lfrfid: saved key info scene * App lfrfid: delete key scene
67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
#include "lfrfid-app-scene-saved-key-menu.h"
|
|
|
|
typedef enum {
|
|
SubmenuEmulate,
|
|
SubmenuWrite,
|
|
SubmenuEdit,
|
|
SubmenuDelete,
|
|
SubmenuInfo,
|
|
} SubmenuIndex;
|
|
|
|
void LfRfidAppSceneSavedKeyMenu::on_enter(LfRfidApp* app, bool need_restore) {
|
|
auto submenu = app->view_controller.get<SubmenuVM>();
|
|
|
|
submenu->add_item("Emulate", SubmenuEmulate, submenu_callback, app);
|
|
submenu->add_item("Write", SubmenuWrite, submenu_callback, app);
|
|
submenu->add_item("Edit", SubmenuEdit, submenu_callback, app);
|
|
submenu->add_item("Delete", SubmenuDelete, submenu_callback, app);
|
|
submenu->add_item("Info", SubmenuInfo, submenu_callback, app);
|
|
|
|
if(need_restore) {
|
|
submenu->set_selected_item(submenu_item_selected);
|
|
}
|
|
|
|
app->view_controller.switch_to<SubmenuVM>();
|
|
}
|
|
|
|
bool LfRfidAppSceneSavedKeyMenu::on_event(LfRfidApp* app, LfRfidApp::Event* event) {
|
|
bool consumed = false;
|
|
|
|
if(event->type == LfRfidApp::EventType::MenuSelected) {
|
|
submenu_item_selected = event->payload.menu_index;
|
|
switch(event->payload.menu_index) {
|
|
case SubmenuEmulate:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::Emulate);
|
|
break;
|
|
case SubmenuWrite:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::Write);
|
|
break;
|
|
case SubmenuEdit:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::SaveData);
|
|
break;
|
|
case SubmenuDelete:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::DeleteConfirm);
|
|
break;
|
|
case SubmenuInfo:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::SavedInfo);
|
|
break;
|
|
}
|
|
consumed = true;
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void LfRfidAppSceneSavedKeyMenu::on_exit(LfRfidApp* app) {
|
|
app->view_controller.get<SubmenuVM>()->clean();
|
|
}
|
|
|
|
void LfRfidAppSceneSavedKeyMenu::submenu_callback(void* context, uint32_t index) {
|
|
LfRfidApp* app = static_cast<LfRfidApp*>(context);
|
|
LfRfidApp::Event event;
|
|
|
|
event.type = LfRfidApp::EventType::MenuSelected;
|
|
event.payload.menu_index = index;
|
|
|
|
app->view_controller.send_event(&event);
|
|
}
|