Skip to content

Commit ac19869

Browse files
committed
ui: change title when showing mnemonic to include number of words
`1 of 24`, `2 of 24`, ... instead of `01`, `02`, ... More explicit, harder to make mistakes. The label is offset to the left a bit, otherwise it intersects with `Continue` that appears in the top right on the last word. The xoffset/yoffset are converted to signed ints so a negative offset is possible.
1 parent 30a5f4e commit ac19869

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/rust/bitbox02-rust/src/workflow/mnemonic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub async fn show_and_confirm_mnemonic(
138138

139139
// Part 2) Confirm words
140140
for (word_idx, word) in words.iter().enumerate() {
141-
let title = format!("{:02}", word_idx + 1);
141+
let title = format!("{} of {}", word_idx + 1, words.len());
142142
let (correct_idx, choices) = create_random_unique_words(word, NUM_RANDOM_WORDS);
143143
let mut choices: Vec<&str> = choices.iter().map(|c| c.as_ref()).collect();
144144
choices.push("Back to\nrecovery words");

src/ui/components/label.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ typedef struct {
3737
float slider_position_diff;
3838
int16_t text_position;
3939
int16_t text_position_last;
40-
uint8_t xoffset;
41-
uint8_t yoffset;
40+
int16_t xoffset;
41+
int16_t yoffset;
4242
} data_t;
4343

4444
static void _measure_label_dimensions(component_t* label);
@@ -219,8 +219,8 @@ static component_t* _label_create(
219219
const bool upside_down,
220220
const UG_FONT* font,
221221
enum screen_position_t position,
222-
uint8_t xoffset,
223-
uint8_t yoffset,
222+
int16_t xoffset,
223+
int16_t yoffset,
224224
bool scrollable,
225225
component_t* parent)
226226
{
@@ -266,8 +266,8 @@ component_t* label_create_offset(
266266
const char* text,
267267
const UG_FONT* font,
268268
enum screen_position_t position,
269-
uint8_t xoffset,
270-
uint8_t yoffset,
269+
int16_t xoffset,
270+
int16_t yoffset,
271271
component_t* parent)
272272
{
273273
return _label_create(text, false, font, position, xoffset, yoffset, false, parent);
@@ -286,8 +286,8 @@ component_t* label_create_scrollable_offset(
286286
const char* text,
287287
const UG_FONT* font,
288288
enum screen_position_t position,
289-
uint8_t xoffset,
290-
uint8_t yoffset,
289+
int16_t xoffset,
290+
int16_t yoffset,
291291
component_t* parent)
292292
{
293293
return _label_create(text, false, font, position, xoffset, yoffset, true, parent);

src/ui/components/label.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ component_t* label_create_offset(
5757
const char* text,
5858
const UG_FONT* font,
5959
enum screen_position_t position,
60-
uint8_t xoffset,
61-
uint8_t yoffset,
60+
int16_t xoffset,
61+
int16_t yoffset,
6262
component_t* parent);
6363

6464
/**
@@ -87,8 +87,8 @@ component_t* label_create_scrollable_offset(
8787
const char* text,
8888
const UG_FONT* font,
8989
enum screen_position_t position,
90-
uint8_t xoffset,
91-
uint8_t yoffset,
90+
int16_t xoffset,
91+
int16_t yoffset,
9292
component_t* parent);
9393

9494
#endif

src/ui/components/menu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ static void _cancel(component_t* component)
7777
static void _display_index(component_t* menu)
7878
{
7979
menu_data_t* data = (menu_data_t*)menu->data;
80-
char index_str[4];
81-
snprintf(index_str, sizeof(index_str), "%02u", (data->index + 1U));
80+
char index_str[11];
81+
snprintf(index_str, sizeof(index_str), "%u of %u", data->index + 1U, data->length);
8282
label_update(data->index_label, index_str);
8383
}
8484

@@ -283,7 +283,7 @@ component_t* menu_create(
283283
ui_util_add_sub_component(menu, label);
284284
labels[i] = label;
285285
}
286-
data->index_label = label_create("", NULL, CENTER_TOP, menu);
286+
data->index_label = label_create_offset("", NULL, CENTER_TOP, -10, 0, menu);
287287
ui_util_add_sub_component(menu, data->index_label);
288288
if (data->show_index) {
289289
_display_index(menu);

0 commit comments

Comments
 (0)