FlippyPass/project/ui/scenes/overview.c

67 lines
No EOL
1.6 KiB
C

// Header
#include "overview.h"
// Functions
void FP_Scene_Callback_Overview(void* context, uint32_t index) {
// Setting context
FP_App* app = context;
// Sending it to the scene manager
scene_manager_handle_custom_event(app->scene_manager, index);
}
void FP_Scene_Enter_Overview(void* context) {
// Setting context
FP_App* app = context;
// Reset menu
submenu_reset(app->submenu);
// Adding menu items
for (int i = 0; i < app->manager->count; i++) {
submenu_add_item(
app->submenu,
app->manager->names[i],
i,
FP_Scene_Callback_Overview,
app
);
}
// Sending view to Flipper
view_dispatcher_switch_to_view(app->view_dispatcher, FP_View_Submenu);
}
void FP_Scene_Exit_Overview(void* context) {
// Setting context
FP_App* app = context;
// Reset menu
submenu_reset(app->submenu);
}
bool FP_Scene_Event_Overview(void* context, SceneManagerEvent event) {
// Setting context
FP_App* app = context;
bool consumed = false;
// Switching based on event
if (event.type == SceneManagerEventTypeCustom) {
// We consumed it
consumed = true;
// Loading password
manager_loadpass(app->manager, app->manager->names[event.event]);
// Is the current password a fake?
if (!app->manager->current) {
FURI_LOG_E(TAG, "Password is NULL!");
furi_crash();
}
// Switch to password view screen
scene_manager_next_scene(app->scene_manager, FP_Scene_View);
} else {
consumed = false;
}
// Return result
return consumed;
}