Adding Creation menu
This commit is contained in:
parent
0d8b27e98d
commit
1190b52701
2 changed files with 74 additions and 1 deletions
|
@ -1,6 +1,9 @@
|
|||
// Header
|
||||
#include "ui.h"
|
||||
|
||||
// Constants
|
||||
#define MAX_OPTIONS 4
|
||||
|
||||
// Structures
|
||||
/* Scenes */
|
||||
typedef enum {
|
||||
|
@ -15,7 +18,7 @@ typedef enum {
|
|||
} FP_Scene;
|
||||
|
||||
/* Types of Views */
|
||||
typedef enum { FP_View_Submenu, FP_View_Dialog, FP_View_Popup } FP_View;
|
||||
typedef enum { FP_View_VariableItemList, FP_View_Submenu, FP_View_Dialog, FP_View_Popup } FP_View;
|
||||
|
||||
/* All events */
|
||||
typedef enum {
|
||||
|
@ -32,6 +35,21 @@ typedef enum {
|
|||
FP_Scene_MainMenu_Event_About
|
||||
} FP_Scene_MainMenu_Event;
|
||||
|
||||
/* Extras */
|
||||
typedef struct {
|
||||
const char* title;
|
||||
const char* options[MAX_OPTIONS];
|
||||
int selection;
|
||||
} FP_Variable_Item;
|
||||
|
||||
/* Variable Item Lists */
|
||||
const FP_Variable_Item fp_scene_create_options[4] = {
|
||||
{"Name", {""}, 0},
|
||||
{"Username", {""}, 0},
|
||||
{"Password", {""}, 0},
|
||||
{"Create", {""}, 0}
|
||||
};
|
||||
|
||||
// Page functions
|
||||
void FP_Scene_Callback_MainMenu(void* context, uint32_t index) {
|
||||
// Setting context
|
||||
|
@ -81,6 +99,13 @@ void FP_Scene_Callback_Create(void* context, uint32_t index) {
|
|||
// Sending it to the scene manager
|
||||
scene_manager_handle_custom_event(app->scene_manager, index);
|
||||
}
|
||||
void FP_Scene_Callback_Create_Change(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_MainMenu(void* context) {
|
||||
// Setting context
|
||||
|
@ -229,8 +254,47 @@ void FP_Scene_Enter_Create(void* context) {
|
|||
FP_App* app = context;
|
||||
|
||||
// Reset page
|
||||
variable_item_list_reset(app->varitemlist);
|
||||
|
||||
// Drawing
|
||||
variable_item_list_add(
|
||||
app->varitemlist,
|
||||
"Name",
|
||||
1,
|
||||
FP_Scene_Callback_Create_Change,
|
||||
app
|
||||
);
|
||||
variable_item_list_add(
|
||||
app->varitemlist,
|
||||
"Username",
|
||||
1,
|
||||
FP_Scene_Callback_Create_Change,
|
||||
app
|
||||
);
|
||||
variable_item_list_add(
|
||||
app->varitemlist,
|
||||
"Password",
|
||||
1,
|
||||
FP_Scene_Callback_Create_Change,
|
||||
app
|
||||
);
|
||||
variable_item_list_add(
|
||||
app->varitemlist,
|
||||
"Create",
|
||||
1,
|
||||
NULL,
|
||||
app
|
||||
);
|
||||
|
||||
// Callbacks
|
||||
variable_item_list_set_enter_callback(
|
||||
app->varitemlist,
|
||||
FP_Scene_Callback_Create,
|
||||
app
|
||||
);
|
||||
|
||||
// Send view to Flipper
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, FP_View_VariableItemList);
|
||||
}
|
||||
|
||||
void FP_Scene_Exit_MainMenu(void* context) {
|
||||
|
@ -408,6 +472,9 @@ bool FP_Scene_Event_Create(void* context, SceneManagerEvent event) {
|
|||
// We consumed it
|
||||
consumed = true;
|
||||
|
||||
// Debug log about what we pressed
|
||||
FURI_LOG_D(TAG, "Pressed %li", event.event);
|
||||
|
||||
UNUSED(app);
|
||||
|
||||
// What to do?
|
||||
|
@ -491,6 +558,7 @@ FP_App* fp_app_init() {
|
|||
view_dispatcher_enable_queue(result->view_dispatcher);
|
||||
|
||||
// Allocating all types of views
|
||||
result->varitemlist = variable_item_list_alloc();
|
||||
result->dialog = dialog_ex_alloc();
|
||||
result->submenu = submenu_alloc();
|
||||
result->popup = popup_alloc();
|
||||
|
@ -501,6 +569,7 @@ FP_App* fp_app_init() {
|
|||
view_dispatcher_set_navigation_event_callback(result->view_dispatcher, FP_SceneManager_Callback_Navigation);
|
||||
|
||||
// Adding views to dispatcher
|
||||
view_dispatcher_add_view(result->view_dispatcher, FP_View_VariableItemList, variable_item_list_get_view(result->varitemlist));
|
||||
view_dispatcher_add_view(result->view_dispatcher, FP_View_Submenu, submenu_get_view(result->submenu));
|
||||
view_dispatcher_add_view(result->view_dispatcher, FP_View_Dialog, dialog_ex_get_view(result->dialog));
|
||||
view_dispatcher_add_view(result->view_dispatcher, FP_View_Popup, popup_get_view(result->popup));
|
||||
|
@ -530,10 +599,12 @@ void fp_app_free(FP_App* app) {
|
|||
// Freeing stuff from memory
|
||||
manager_free(app->manager);
|
||||
scene_manager_free(app->scene_manager);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, FP_View_VariableItemList);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, FP_View_Submenu);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, FP_View_Dialog);
|
||||
view_dispatcher_remove_view(app->view_dispatcher, FP_View_Popup);
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
variable_item_list_free(app->varitemlist);
|
||||
dialog_ex_free(app->dialog);
|
||||
submenu_free(app->submenu);
|
||||
popup_free(app->popup);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <gui/modules/dialog_ex.h>
|
||||
#include <gui/modules/submenu.h>
|
||||
#include <gui/modules/popup.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
|
||||
#include "app.h"
|
||||
#include "manager.h"
|
||||
|
@ -21,6 +22,7 @@
|
|||
typedef struct {
|
||||
SceneManager* scene_manager;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
VariableItemList* varitemlist;
|
||||
DialogEx* dialog;
|
||||
Submenu* submenu;
|
||||
Popup* popup;
|
||||
|
|
Loading…
Reference in a new issue