Skip to content

Commit b04ca92

Browse files
committed
refactor text
1 parent 84d40af commit b04ca92

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

views/flipbip_scene_1.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222
#define DERIV_ACCOUNT 0
2323
#define DERIV_CHANGE 0
2424

25+
#define TEXT_LOADING "Loading..."
26+
#define TEXT_NEW_WALLET "New wallet"
27+
#define TEXT_DEFAULT_COIN "Coin"
28+
#define TEXT_RECEIVE_ADDRESS "receive address:"
29+
#define TEXT_DEFAULT_DERIV "m/44'/X'/0'/0"
30+
31+
const char* TEXT_INFO = "-Scroll pages with up/down-"
32+
"p1,2) Mnemonic/Seed "
33+
"p3) xprv Root Key "
34+
"p4,5) xprv/xpub Accnt Keys"
35+
"p6,7) xprv/xpub Extnd Keys"
36+
"p8+) Receive Addresses ";
37+
2538
// bip44_coin, xprv_version, xpub_version, addr_version, wif_version, addr_format
2639
const uint32_t COIN_INFO_ARRAY[3][6] = {
2740
{COIN_BTC, 0x0488ade4, 0x0488b21e, 0x00, 0x80, FlipBipCoinBTC0},
@@ -63,7 +76,7 @@ static CONFIDENTIAL char s_disp_text3[30 + 1];
6376
static CONFIDENTIAL char s_disp_text4[30 + 1];
6477
static CONFIDENTIAL char s_disp_text5[30 + 1];
6578
static CONFIDENTIAL char s_disp_text6[30 + 1];
66-
static const char* s_derivation_text = "m/44'/X'/0'/0";
79+
static const char* s_derivation_text = TEXT_DEFAULT_DERIV;
6780
//static bool s_busy = false;
6881

6982
void flipbip_scene_1_set_callback(
@@ -234,13 +247,7 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
234247

235248
flipbip_scene_1_clear_text();
236249
if(model->page == 1) {
237-
const char* info = "-Scroll pages with up/down-"
238-
"p1,2) Mnemonic/Seed "
239-
"p3) xprv Root Key "
240-
"p4,5) xprv/xpub Accnt Keys"
241-
"p6,7) xprv/xpub Extnd Keys"
242-
"p8+) Receive Addresses ";
243-
flipbip_scene_1_draw_generic(info, 27);
250+
flipbip_scene_1_draw_generic(TEXT_INFO, 27);
244251
} else if(model->page == 2) {
245252
flipbip_scene_1_draw_mnemonic(model->mnemonic);
246253
} else if(model->page == 3) {
@@ -261,18 +268,19 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
261268

262269
if(model->page == 0) {
263270
canvas_set_font(canvas, FontPrimary);
264-
canvas_draw_str(canvas, 1, 10, "Loading...");
271+
canvas_draw_str(canvas, 1, 10, TEXT_LOADING);
265272
canvas_draw_str(canvas, 6, 30, s_derivation_text);
266273
canvas_draw_icon(canvas, 86, 25, &I_Keychain_39x36);
267274
} else if(model->page >= 9 && model->page <= 13) {
268275
canvas_set_font(canvas, FontSecondary);
269276
// coin_name, derivation_path
270277
const char* receive_text = COIN_TEXT_ARRAY[model->coin][0];
271278
if (receive_text == NULL) {
272-
receive_text = "Coin";
279+
receive_text = TEXT_DEFAULT_COIN;
273280
}
281+
const size_t receive_len = strlen(receive_text) * 7;
274282
canvas_draw_str_aligned(canvas, 1, 2, AlignLeft, AlignTop, receive_text);
275-
canvas_draw_str_aligned(canvas, strlen(receive_text) * 7, 2, AlignLeft, AlignTop, "receive address:");
283+
canvas_draw_str_aligned(canvas, receive_len, 2, AlignLeft, AlignTop, TEXT_RECEIVE_ADDRESS);
276284
canvas_set_font(canvas, FontPrimary);
277285
canvas_draw_str(canvas, 6, 22, s_disp_text1);
278286
canvas_draw_str(canvas, 6, 34, s_disp_text2);
@@ -519,6 +527,9 @@ void flipbip_scene_1_enter(void* context) {
519527

520528
// Overwrite the saved seed with a new one setting
521529
bool overwrite = app->overwrite_saved_seed != 0;
530+
if (overwrite) {
531+
s_derivation_text = TEXT_NEW_WALLET;
532+
}
522533

523534
flipbip_play_happy_bump(app);
524535
flipbip_led_set_rgb(app, 255, 0, 0);

0 commit comments

Comments
 (0)