Added import scene
This commit is contained in:
parent
d5e1c7a7e0
commit
5360e26581
5 changed files with 145 additions and 5 deletions
|
@ -39,6 +39,7 @@ typedef enum {
|
|||
FP_Scene_Create,
|
||||
FP_Scene_Type,
|
||||
FP_Scene_Archive,
|
||||
FP_Scene_Import,
|
||||
FP_Scene_About,
|
||||
FP_Scene_Count // Last Index, says how many scenes there are
|
||||
} FP_Scene;
|
||||
|
|
|
@ -58,8 +58,17 @@ bool FP_Scene_Event_Archive(void* context, SceneManagerEvent event){
|
|||
// We consumed it
|
||||
consumed = true;
|
||||
|
||||
// Not using the app
|
||||
UNUSED(app);
|
||||
// What did we choose?
|
||||
switch (event.event) {
|
||||
case FP_Scene_Archive_Event_Import:
|
||||
scene_manager_next_scene(
|
||||
app->scene_manager,
|
||||
FP_Scene_Import
|
||||
);
|
||||
break;
|
||||
case FP_Scene_Archive_Event_Export:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
consumed = false;
|
||||
}
|
||||
|
|
112
project/ui/scenes/import.c
Normal file
112
project/ui/scenes/import.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
// Header
|
||||
#include "import.h"
|
||||
|
||||
// Functions
|
||||
void FP_Scene_Callback_Import(DialogExResult result, void* context){
|
||||
// Setting context
|
||||
FP_App* app = context;
|
||||
|
||||
// Sending it to the scene manager
|
||||
scene_manager_handle_custom_event(app->scene_manager, result);
|
||||
}
|
||||
void FP_Scene_Enter_Import(void* context){
|
||||
// Setting context
|
||||
FP_App* app = context;
|
||||
|
||||
// Setting selection
|
||||
app->selection = 0;
|
||||
|
||||
// Resetting scene
|
||||
dialog_ex_reset(app->dialog);
|
||||
|
||||
// Setting dialog content
|
||||
dialog_ex_set_header(
|
||||
app->dialog,
|
||||
"Import Archive",
|
||||
0, 0,
|
||||
AlignLeft, AlignTop
|
||||
);
|
||||
dialog_ex_set_text(
|
||||
app->dialog,
|
||||
"Are you sure you want to import: /ext/apps_data/fpass/archive.txt?",
|
||||
5, 15,
|
||||
AlignLeft, AlignTop
|
||||
);
|
||||
dialog_ex_set_center_button_text(
|
||||
app->dialog,
|
||||
"Yes"
|
||||
);
|
||||
dialog_ex_set_left_button_text(
|
||||
app->dialog,
|
||||
"No"
|
||||
);
|
||||
|
||||
// Setting callback
|
||||
dialog_ex_set_result_callback(
|
||||
app->dialog,
|
||||
FP_Scene_Callback_Import
|
||||
);
|
||||
dialog_ex_set_context(
|
||||
app->dialog,
|
||||
app
|
||||
);
|
||||
|
||||
// Sending view to Flipper
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, FP_View_Dialog);
|
||||
}
|
||||
void FP_Scene_Exit_Import(void* context){
|
||||
// Setting context
|
||||
FP_App* app = context;
|
||||
|
||||
// Reset menu
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
bool FP_Scene_Event_Import(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;
|
||||
|
||||
// Are we already good?
|
||||
if (app->selection >= 1) {
|
||||
scene_manager_previous_scene(
|
||||
app->scene_manager
|
||||
);
|
||||
}
|
||||
|
||||
// What should we do?
|
||||
switch (event.event) {
|
||||
case DialogExResultCenter: // Yes
|
||||
// Telling the user it worked!
|
||||
dialog_ex_set_text(
|
||||
app->dialog,
|
||||
"Imported Successfully.",
|
||||
5, 15,
|
||||
AlignLeft, AlignTop
|
||||
);
|
||||
dialog_ex_set_center_button_text(
|
||||
app->dialog,
|
||||
"Okay"
|
||||
);
|
||||
dialog_ex_set_left_button_text(
|
||||
app->dialog,
|
||||
NULL
|
||||
);
|
||||
app->selection++;
|
||||
|
||||
break;
|
||||
case DialogExResultLeft: // No
|
||||
scene_manager_previous_scene(app->scene_manager);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
consumed = false;
|
||||
}
|
||||
|
||||
// Return result
|
||||
return consumed;
|
||||
}
|
14
project/ui/scenes/import.h
Normal file
14
project/ui/scenes/import.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Define once
|
||||
#ifndef H_S_IMPORT
|
||||
#define H_S_IMPORT
|
||||
|
||||
// Libraries
|
||||
#include "../app.h"
|
||||
|
||||
// Functions
|
||||
void FP_Scene_Callback_Import(DialogExResult result, void* context);
|
||||
void FP_Scene_Enter_Import(void* context);
|
||||
void FP_Scene_Exit_Import(void* context);
|
||||
bool FP_Scene_Event_Import(void* context, SceneManagerEvent event);
|
||||
|
||||
#endif
|
|
@ -11,6 +11,7 @@
|
|||
#include "scenes/create.h"
|
||||
#include "scenes/type.h"
|
||||
#include "scenes/archive.h"
|
||||
#include "scenes/import.h"
|
||||
|
||||
// Handlers
|
||||
void (*const FP_Scene_Enter_Handlers[])(void*) = {
|
||||
|
@ -22,7 +23,8 @@ void (*const FP_Scene_Enter_Handlers[])(void*) = {
|
|||
FP_Scene_Enter_Send,
|
||||
FP_Scene_Enter_Create,
|
||||
FP_Scene_Enter_Type,
|
||||
FP_Scene_Enter_Archive
|
||||
FP_Scene_Enter_Archive,
|
||||
FP_Scene_Enter_Import
|
||||
};
|
||||
bool (*const FP_Scene_Event_Handlers[])(void*, SceneManagerEvent) = {
|
||||
FP_Scene_Event_Auth,
|
||||
|
@ -33,7 +35,8 @@ bool (*const FP_Scene_Event_Handlers[])(void*, SceneManagerEvent) = {
|
|||
FP_Scene_Event_Send,
|
||||
FP_Scene_Event_Create,
|
||||
FP_Scene_Event_Type,
|
||||
FP_Scene_Event_Archive
|
||||
FP_Scene_Event_Archive,
|
||||
FP_Scene_Event_Import
|
||||
};
|
||||
void (*const FP_Scene_Exit_Handlers[])(void*) = {
|
||||
FP_Scene_Exit_Auth,
|
||||
|
@ -44,7 +47,8 @@ void (*const FP_Scene_Exit_Handlers[])(void*) = {
|
|||
FP_Scene_Exit_Send,
|
||||
FP_Scene_Exit_Create,
|
||||
FP_Scene_Exit_Type,
|
||||
FP_Scene_Exit_Archive
|
||||
FP_Scene_Exit_Archive,
|
||||
FP_Scene_Exit_Import
|
||||
};
|
||||
|
||||
// Main Handler
|
||||
|
|
Loading…
Reference in a new issue