Skip to content

Commit

Permalink
new wallet generation ability
Browse files Browse the repository at this point in the history
  • Loading branch information
xtruan committed Mar 7, 2023
1 parent 1a7b0db commit ab40026
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
23 changes: 16 additions & 7 deletions scenes/flipbip_scene_menu.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "../flipbip.h"
#include "../helpers/flipbip_file.h"

enum SubmenuIndex {
SubmenuIndexScene1BTC = 10,
SubmenuIndexScene1ETH,
SubmenuIndexScene1New,
SubmenuIndexSettings,
};

Expand All @@ -14,13 +16,12 @@ void flipbip_scene_menu_submenu_callback(void* context, uint32_t index) {
void flipbip_scene_menu_on_enter(void* context) {
FlipBip* app = context;

// if (app->bip44_coin == FlipBipCoinBTC0) { // BTC
submenu_add_item(app->submenu, "Generate BTC wallet", SubmenuIndexScene1BTC, flipbip_scene_menu_submenu_callback, app);
// }
// if (app->bip44_coin == FlipBipCoinETH60) { // ETH
submenu_add_item(app->submenu, "Generate ETH wallet", SubmenuIndexScene1ETH, flipbip_scene_menu_submenu_callback, app);
// }
//submenu_add_item(app->submenu, "Scene 2", SubmenuIndexScene2, flipbip_scene_menu_submenu_callback, app);
if(flipbip_has_settings(true) && flipbip_has_settings(false)) {
submenu_add_item(app->submenu, "View saved BTC wallet", SubmenuIndexScene1BTC, flipbip_scene_menu_submenu_callback, app);
submenu_add_item(app->submenu, "View saved ETH wallet", SubmenuIndexScene1ETH, flipbip_scene_menu_submenu_callback, app);
}
submenu_add_item(app->submenu, "Generate new wallet", SubmenuIndexScene1New, flipbip_scene_menu_submenu_callback, app);

submenu_add_item(app->submenu, "Settings", SubmenuIndexSettings, flipbip_scene_menu_submenu_callback, app);

submenu_set_selected_item(app->submenu, scene_manager_get_scene_state(app->scene_manager, FlipBipSceneMenu));
Expand All @@ -38,17 +39,25 @@ bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexScene1BTC) {
app->overwrite_saved_seed = 0;
app->bip44_coin = FlipBipCoinBTC0;
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1BTC);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
} else if (event.event == SubmenuIndexScene1ETH) {
app->overwrite_saved_seed = 0;
app->bip44_coin = FlipBipCoinETH60;
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1ETH);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
} else if (event.event == SubmenuIndexScene1New) {
app->overwrite_saved_seed = 1;
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1New);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
} else if (event.event == SubmenuIndexSettings) {
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexSettings);
Expand Down
7 changes: 6 additions & 1 deletion views/flipbip_scene_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {

if (model->page == 0) {
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 1, 10, "Generating...");
canvas_draw_str(canvas, 1, 10, "Loading...");
canvas_draw_str(canvas, 6, 30, "m/44'/C'/0'/0");
} else if (model->page >= 9 && model->page <= 13) {
canvas_set_font(canvas, FontSecondary);
Expand Down Expand Up @@ -487,6 +487,11 @@ void flipbip_scene_1_enter(void* context) {
FlipBipScene1Model * model,
{
flipbip_scene_1_model_init(model, strength, coin, overwrite);

// if overwrite is set, return from scene immediately
if (overwrite) {
instance->callback(FlipBipCustomEventScene1Back, instance->context);
}
},
true
);
Expand Down

0 comments on commit ab40026

Please sign in to comment.