Skip to content

Commit

Permalink
upd flipbip
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Oct 24, 2023
1 parent 800482e commit 4ed4e31
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 17 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ App(
fap_category="Tools",
fap_author="Struan Clark (xtruan)",
fap_weburl="https://github.com/xtruan/FlipBIP",
fap_version=(1, 13),
fap_version=(1, 14),
fap_description="Crypto wallet for Flipper",
)
30 changes: 30 additions & 0 deletions flipbip.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ static void text_input_callback(void* context) {
}
}

static void flipbip_scene_renew_dialog_callback(DialogExResult result, void* context) {
FlipBip* app = context;
if(result == DialogExResultRight) {
app->wallet_create(app);
} else {
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewIdMenu);
}
}

static void flipbip_wallet_create(void* context) {
FlipBip* app = context;
furi_assert(app);
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
}

FlipBip* flipbip_app_alloc() {
FlipBip* app = malloc(sizeof(FlipBip));
app->gui = furi_record_open(RECORD_GUI);
Expand Down Expand Up @@ -148,6 +165,16 @@ FlipBip* flipbip_app_alloc() {
view_dispatcher_add_view(
app->view_dispatcher, FlipBipViewIdTextInput, text_input_get_view(app->text_input));

app->wallet_create = flipbip_wallet_create;
app->renew_dialog = dialog_ex_alloc();
dialog_ex_set_result_callback(app->renew_dialog, flipbip_scene_renew_dialog_callback);
dialog_ex_set_context(app->renew_dialog, app);
dialog_ex_set_left_button_text(app->renew_dialog, "No");
dialog_ex_set_right_button_text(app->renew_dialog, "Yes");
dialog_ex_set_header(app->renew_dialog, "Current wallet\nWill be lost.\nProceed?", 16, 12, AlignLeft, AlignTop);
view_dispatcher_add_view(
app->view_dispatcher, FlipBipViewRenewConfirm, dialog_ex_get_view(app->renew_dialog));

// End Scene Additions

return app;
Expand All @@ -168,6 +195,9 @@ void flipbip_app_free(FlipBip* app) {
view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewIdTextInput);
submenu_free(app->submenu);

view_dispatcher_remove_view(app->view_dispatcher, FlipBipViewRenewConfirm);
dialog_ex_free(app->renew_dialog);

view_dispatcher_free(app->view_dispatcher);
furi_record_close(RECORD_GUI);

Expand Down
21 changes: 20 additions & 1 deletion flipbip.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
#include <gui/scene_manager.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/variable_item_list.h>
#include <gui/modules/text_input.h>
#include "scenes/flipbip_scene.h"
#include "views/flipbip_scene_1.h"

#define FLIPBIP_VERSION "v1.13"
#define FLIPBIP_VERSION "v1.14"

#define COIN_BTC 0
#define COIN_DOGE 3
Expand All @@ -23,6 +24,8 @@

#define TEXT_BUFFER_SIZE 256



typedef struct {
Gui* gui;
// NotificationApp* notification;
Expand All @@ -31,6 +34,7 @@ typedef struct {
SceneManager* scene_manager;
VariableItemList* variable_item_list;
TextInput* text_input;
DialogEx* renew_dialog;
FlipBipScene1* flipbip_scene_1;
char* mnemonic_menu_text;
// Settings options
Expand All @@ -45,6 +49,8 @@ typedef struct {
char passphrase_text[TEXT_BUFFER_SIZE];
char import_mnemonic_text[TEXT_BUFFER_SIZE];
char input_text[TEXT_BUFFER_SIZE];

void (* wallet_create)(void* context);
} FlipBip;

typedef enum {
Expand All @@ -53,6 +59,7 @@ typedef enum {
FlipBipViewIdScene1,
FlipBipViewIdSettings,
FlipBipViewIdTextInput,
FlipBipViewRenewConfirm,
} FlipBipViewId;

typedef enum {
Expand Down Expand Up @@ -86,3 +93,15 @@ typedef enum {
FlipBipStatusSaveError = 12,
FlipBipStatusMnemonicCheckError = 13,
} FlipBipStatus;

typedef enum {
SubmenuIndexScene1BTC = 10,
SubmenuIndexScene1ETH,
SubmenuIndexScene1DOGE,
SubmenuIndexScene1ZEC,
SubmenuIndexScene1New,
SubmenuIndexScene1Renew,
SubmenuIndexScene1Import,
SubmenuIndexSettings,
SubmenuIndexNOP,
} SubmenuIndex;
23 changes: 8 additions & 15 deletions scenes/flipbip_scene_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@

#define FLIPBIP_SUBMENU_TEXT "** FlipBIP wallet " FLIPBIP_VERSION " **"

enum SubmenuIndex {
SubmenuIndexScene1BTC = 10,
SubmenuIndexScene1ETH,
SubmenuIndexScene1DOGE,
SubmenuIndexScene1ZEC,
SubmenuIndexScene1New,
SubmenuIndexScene1Import,
SubmenuIndexSettings,
SubmenuIndexNOP,
};

void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
furi_assert(context);
FlipBip* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
Expand Down Expand Up @@ -59,7 +49,7 @@ void flipbip_scene_menu_on_enter(void* context) {
submenu_add_item(
app->submenu,
"Regenerate wallet",
SubmenuIndexScene1New,
SubmenuIndexScene1Renew,
flipbip_scene_menu_submenu_callback,
app);
} else {
Expand Down Expand Up @@ -130,9 +120,12 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
} else if(event.event == SubmenuIndexScene1New) {
app->overwrite_saved_seed = 1;
app->import_from_mnemonic = 0;
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
app->wallet_create(app);
return true;
} else if(event.event == SubmenuIndexScene1Renew) {
app->overwrite_saved_seed = 1;
app->import_from_mnemonic = 0;
view_dispatcher_switch_to_view(app->view_dispatcher, FlipBipViewRenewConfirm);
return true;
} else if(event.event == SubmenuIndexScene1Import) {
app->import_from_mnemonic = 1;
Expand Down

0 comments on commit 4ed4e31

Please sign in to comment.