ui: save mnemonic phrase word on enter key press, remove useless separate function to check back press event

This commit is contained in:
ardocrat
2023-07-23 17:21:02 +03:00
parent 2f5011c36f
commit c166f21d1e
3 changed files with 17 additions and 10 deletions
+9 -2
View File
@@ -74,7 +74,7 @@ impl MnemonicSetup {
ui.vertical_centered(|ui| {
ui.label(RichText::new(t!("wallets.saved_phrase")).size(16.0).color(Colors::GRAY));
});
ui.add_space(6.0);
ui.add_space(4.0);
ScrollArea::vertical()
.id_source("confirm_mnemonic_words_list")
.auto_shrink([false; 2])
@@ -266,7 +266,8 @@ impl MnemonicSetup {
});
});
columns[1].vertical_centered_justified(|ui| {
View::button(ui, t!("continue"), Colors::WHITE, || {
// Callback to save the word.
let mut save = || {
// Check if word is valid.
let word_index = self.word_num_edit - 1;
if !self.mnemonic.is_valid_word(&self.word_edit, word_index) {
@@ -291,7 +292,13 @@ impl MnemonicSetup {
self.word_num_edit += 1;
self.word_edit = "".to_string();
}
};
// Call save on Enter key press.
View::on_enter_key(ui, || {
(save)();
});
// Show save button.
View::button(ui, t!("continue"), Colors::WHITE, save);
});
});
ui.add_space(6.0);