Fixed Dialog
This commit is contained in:
parent
f045026f93
commit
bae7928ac4
1 changed files with 50 additions and 4 deletions
|
@ -55,12 +55,12 @@ void FP_Scene_Callback_Overview(void* context, uint32_t index) {
|
|||
// Sending it to the scene manager
|
||||
scene_manager_handle_custom_event(app->scene_manager, index);
|
||||
}
|
||||
void FP_Scene_Callback_View(void* context, uint32_t index) {
|
||||
void FP_Scene_Callback_View(DialogExResult result, void* context) {
|
||||
// Setting context
|
||||
FP_App* app = context;
|
||||
|
||||
// Sending it to the scene manager
|
||||
scene_manager_handle_custom_event(app->scene_manager, index);
|
||||
scene_manager_handle_custom_event(app->scene_manager, result);
|
||||
}
|
||||
|
||||
void FP_Scene_Enter_MainMenu(void* context) {
|
||||
|
@ -127,19 +127,42 @@ void FP_Scene_Enter_Overview(void* context) {
|
|||
void FP_Scene_Enter_View(void* context) {
|
||||
// Setting context
|
||||
FP_App* app = context;
|
||||
Password* current = app->manager->current;
|
||||
|
||||
// Freeing Dialog
|
||||
dialog_ex_reset(app->dialog);
|
||||
|
||||
// Username
|
||||
FuriString* text = furi_string_alloc();
|
||||
furi_string_printf(text, "U: %s", app->manager->current->user);
|
||||
|
||||
// Adding some content
|
||||
dialog_ex_set_header(
|
||||
app->dialog,
|
||||
current->name,
|
||||
app->manager->current->name,
|
||||
0, 0,
|
||||
AlignLeft,
|
||||
AlignTop
|
||||
);
|
||||
dialog_ex_set_text(
|
||||
app->dialog,
|
||||
furi_string_get_cstr(text),
|
||||
5,
|
||||
15,
|
||||
AlignLeft,
|
||||
AlignTop
|
||||
);
|
||||
dialog_ex_set_left_button_text(
|
||||
app->dialog,
|
||||
"Pass"
|
||||
);
|
||||
dialog_ex_set_center_button_text(
|
||||
app->dialog,
|
||||
"BadUSB"
|
||||
);
|
||||
|
||||
// Left & Right
|
||||
dialog_ex_set_result_callback(app->dialog, FP_Scene_Callback_View);
|
||||
dialog_ex_set_context(app->dialog, app);
|
||||
|
||||
// Sending view to Flipper
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, FP_View_Dialog);
|
||||
|
@ -233,6 +256,29 @@ bool FP_Scene_Event_View(void* context, SceneManagerEvent event) {
|
|||
// We consumed it
|
||||
consumed = true;
|
||||
|
||||
// What did we press?
|
||||
switch (event.event) {
|
||||
case DialogExResultLeft:
|
||||
// Getting password and storing it in memory
|
||||
FuriString* text = furi_string_alloc();
|
||||
furi_string_printf(text, "U: %s\nP: %s",
|
||||
app->manager->current->user,
|
||||
app->manager->current->phrase
|
||||
);
|
||||
|
||||
dialog_ex_set_text(
|
||||
app->dialog,
|
||||
furi_string_get_cstr(text),
|
||||
5,15,
|
||||
AlignLeft,
|
||||
AlignTop
|
||||
);
|
||||
dialog_ex_set_left_button_text(app->dialog, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Switching based on event
|
||||
UNUSED(app);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue