mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-17 18:31:36 +03:00
b22ad77bbe
* [FL-2403] Changed (Name and save) buttons name * [FL-2403] NFC Reading revert LED color to blue * [FL-2438] Capital_letter_menu_names * [FL-2438] Capital_letter_menu_names * [FL-2438] Rename and unify menu items with capitals * [FL-2438] Capital_letter_menu_and_returned_Empty_folder * [FL-2438] Capital_letter_menu_and_returned_Empty_folder_label * [FL-2438] Capital_letter_menu_and_returned_Empty_folder_label_reformating Co-authored-by: あく <alleteam@gmail.com>
61 lines
1.8 KiB
C++
61 lines
1.8 KiB
C++
#include "lfrfid_app_scene_start.h"
|
|
|
|
typedef enum {
|
|
SubmenuRead,
|
|
SubmenuSaved,
|
|
SubmenuAddManually,
|
|
} SubmenuIndex;
|
|
|
|
void LfRfidAppSceneStart::on_enter(LfRfidApp* app, bool need_restore) {
|
|
auto submenu = app->view_controller.get<SubmenuVM>();
|
|
|
|
submenu->add_item("Read", SubmenuRead, submenu_callback, app);
|
|
submenu->add_item("Saved", SubmenuSaved, submenu_callback, app);
|
|
submenu->add_item("Add Manually", SubmenuAddManually, submenu_callback, app);
|
|
|
|
if(need_restore) {
|
|
submenu->set_selected_item(submenu_item_selected);
|
|
}
|
|
|
|
app->view_controller.switch_to<SubmenuVM>();
|
|
|
|
// clear key
|
|
app->worker.key.clear();
|
|
}
|
|
|
|
bool LfRfidAppSceneStart::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 SubmenuRead:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::Read);
|
|
break;
|
|
case SubmenuSaved:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::SelectKey);
|
|
break;
|
|
case SubmenuAddManually:
|
|
app->scene_controller.switch_to_next_scene(LfRfidApp::SceneType::SaveType);
|
|
break;
|
|
}
|
|
consumed = true;
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void LfRfidAppSceneStart::on_exit(LfRfidApp* app) {
|
|
app->view_controller.get<SubmenuVM>()->clean();
|
|
}
|
|
|
|
void LfRfidAppSceneStart::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);
|
|
}
|