Skip to content

Commit

Permalink
seperate menu items for coin instead of preference, remove scene_2
Browse files Browse the repository at this point in the history
  • Loading branch information
xtruan committed Mar 7, 2023
1 parent f133996 commit 5d626b8
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 363 deletions.
2 changes: 0 additions & 2 deletions flipbip.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ FlipBip* flipbip_app_alloc() {
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdStartscreen, flipbip_startscreen_get_view(app->flipbip_startscreen));
app->flipbip_scene_1 = flipbip_scene_1_alloc();
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdScene1, flipbip_scene_1_get_view(app->flipbip_scene_1));
// app->flipbip_scene_2 = flipbip_scene_2_alloc();
// view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdScene2, flipbip_scene_2_get_view(app->flipbip_scene_2));
app->variable_item_list = variable_item_list_alloc();
view_dispatcher_add_view(app->view_dispatcher, FlipBipViewIdSettings, variable_item_list_get_view(app->variable_item_list));

Expand Down
2 changes: 0 additions & 2 deletions flipbip.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "scenes/flipbip_scene.h"
#include "views/flipbip_startscreen.h"
#include "views/flipbip_scene_1.h"
// #include "views/flipbip_scene_2.h"

typedef struct {
Gui* gui;
Expand All @@ -24,7 +23,6 @@ typedef struct {
VariableItemList* variable_item_list;
FlipBipStartscreen* flipbip_startscreen;
FlipBipScene1* flipbip_scene_1;
// FlipBipScene2* flipbip_scene_2;
int haptic;
int led;
int bip39_strength;
Expand Down
1 change: 0 additions & 1 deletion scenes/flipbip_scene_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ADD_SCENE(flipbip, startscreen, Startscreen)
ADD_SCENE(flipbip, menu, Menu)
ADD_SCENE(flipbip, scene_1, Scene_1)
// ADD_SCENE(flipbip, scene_2, Scene_2)
ADD_SCENE(flipbip, settings, Settings)
34 changes: 18 additions & 16 deletions scenes/flipbip_scene_menu.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../flipbip.h"

enum SubmenuIndex {
SubmenuIndexScene1 = 10,
// SubmenuIndexScene2,
SubmenuIndexScene1BTC = 10,
SubmenuIndexScene1ETH,
SubmenuIndexSettings,
};

Expand All @@ -14,12 +14,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", SubmenuIndexScene1, flipbip_scene_menu_submenu_callback, app);
}
if (app->bip44_coin == FlipBipCoinETH60) { // ETH
submenu_add_item(app->submenu, "Generate ETH wallet", SubmenuIndexScene1, flipbip_scene_menu_submenu_callback, app);
}
// 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);
submenu_add_item(app->submenu, "Settings", SubmenuIndexSettings, flipbip_scene_menu_submenu_callback, app);

Expand All @@ -30,23 +30,25 @@ void flipbip_scene_menu_on_enter(void* context) {

bool flipbip_scene_menu_on_event(void* context, SceneManagerEvent event) {
FlipBip* app = context;
UNUSED(app);
//UNUSED(app);
if(event.type == SceneManagerEventTypeBack) {
//exit app
scene_manager_stop(app->scene_manager);
view_dispatcher_stop(app->view_dispatcher);
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubmenuIndexScene1) {
if(event.event == SubmenuIndexScene1BTC) {
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->bip44_coin = FlipBipCoinETH60;
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1);
app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene1ETH);
scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_1);
return true;
// } else if (event.event == SubmenuIndexScene2) {
// scene_manager_set_scene_state(
// app->scene_manager, FlipBipSceneMenu, SubmenuIndexScene2);
// scene_manager_next_scene(app->scene_manager, FlipBipSceneScene_2);
// return true;
} else if (event.event == SubmenuIndexSettings) {
scene_manager_set_scene_state(
app->scene_manager, FlipBipSceneMenu, SubmenuIndexSettings);
Expand Down
53 changes: 0 additions & 53 deletions scenes/flipbip_scene_scene_2.c

This file was deleted.

32 changes: 16 additions & 16 deletions scenes/flipbip_scene_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ static void flipbip_scene_settings_set_bip39_strength(VariableItem* item) {
app->bip39_strength = bip39_strength_value[index];
}

static void flipbip_scene_settings_set_bip44_coin(VariableItem* item) {
FlipBip* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, bip44_coin_text[index]);
app->bip44_coin = bip44_coin_value[index];
}
// static void flipbip_scene_settings_set_bip44_coin(VariableItem* item) {
// FlipBip* app = variable_item_get_context(item);
// uint8_t index = variable_item_get_current_value_index(item);
// variable_item_set_current_value_text(item, bip44_coin_text[index]);
// app->bip44_coin = bip44_coin_value[index];
// }

void flipbip_scene_settings_submenu_callback(void* context, uint32_t index) {
FlipBip* app = context;
Expand All @@ -95,16 +95,16 @@ void flipbip_scene_settings_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, bip39_strength_text[value_index]);

// BIP44 Coin
item = variable_item_list_add(
app->variable_item_list,
"BIP44 Coin:",
2,
flipbip_scene_settings_set_bip44_coin,
app);
value_index = value_index_uint32(app->bip44_coin, bip44_coin_value, 2);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, bip44_coin_text[value_index]);
// // BIP44 Coin
// item = variable_item_list_add(
// app->variable_item_list,
// "BIP44 Coin:",
// 2,
// flipbip_scene_settings_set_bip44_coin,
// app);
// value_index = value_index_uint32(app->bip44_coin, bip44_coin_value, 2);
// variable_item_set_current_value_index(item, value_index);
// variable_item_set_current_value_text(item, bip44_coin_text[value_index]);

// Vibro on/off
item = variable_item_list_add(
Expand Down
Loading

0 comments on commit 5d626b8

Please sign in to comment.