-
Notifications
You must be signed in to change notification settings - Fork 109
Update word check #5232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Update word check #5232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the mnemonic phrase input validation by adding real-time word checking against the BIP-39 word list. The update provides immediate visual feedback to users when they enter invalid mnemonic words.
- Added import for
MnemonicCode
to access the BIP-39 word list - Implemented visual validation with color changes for invalid words
- Added error message display for invalid mnemonic phrases
- Updated button enable/disable logic to require valid words
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
InputBar(currentText) { word -> | ||
inputs = inputs.toMutableList().also { it[focusIndex] = word } | ||
if (focusIndex != -1) { | ||
InputBar(currentText) { word -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The InputBar is now conditionally rendered only when focusIndex != -1, which means users cannot interact with the input bar when no field is focused. This breaks the user experience as the input bar becomes inaccessible after losing focus.
InputBar(currentText) { word -> | |
InputBar(currentText) { word -> | |
if (focusIndex != -1) { |
Copilot uses AI. Check for mistakes.
@@ -198,6 +199,12 @@ fun MnemonicPhraseInput( | |||
) | |||
} | |||
} else { | |||
val text = inputs[index] | |||
val textColor = if (index != focusIndex && text.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(text).not()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word list lookup MnemonicCode.INSTANCE.wordList.contains(text)
is being called multiple times for the same text during composition. Consider caching the validation result or extracting it to avoid redundant lookups.
val textColor = if (index != focusIndex && text.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(text).not()) { | |
val isWordInList = remember(text) { MnemonicCode.INSTANCE.wordList.contains(text) } | |
val textColor = if (index != focusIndex && text.isNotEmpty() && !isWordInList) { |
Copilot uses AI. Check for mistakes.
@@ -393,14 +399,22 @@ fun MnemonicPhraseInput( | |||
color = MixinAppTheme.colors.tipError, | |||
) | |||
Spacer(modifier = Modifier.height(8.dp)) | |||
} else if (inputs.any { it.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(it).not() }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This validation logic iterates through all inputs and performs word list lookups on each composition. This could be expensive with many input fields. Consider memoizing this validation or moving it to a computed property.
} else if (inputs.any { it.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(it).not() }) { | |
} else if (hasInvalidInput) { |
Copilot uses AI. Check for mistakes.
No description provided.