feat: implement seed word phrase counter
- If the count matches the required amount a tick will be included next the count - The format is "✓ 12 words" - This commit also fixes the text color when in dark in the wallet add new account modal
This commit is contained in:
parent
0ed41902a8
commit
3c299d054c
|
@ -82,6 +82,12 @@ ModalPopup {
|
||||||
validationError: popup.seedValidationError
|
validationError: popup.seedValidationError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: Utils.seedPhraseWordCountText(accountSeedInput.text)
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: accountSeedInput.bottom
|
||||||
|
}
|
||||||
|
|
||||||
Input {
|
Input {
|
||||||
id: accountNameInput
|
id: accountNameInput
|
||||||
anchors.top: accountSeedInput.bottom
|
anchors.top: accountSeedInput.bottom
|
||||||
|
|
|
@ -147,4 +147,24 @@ QtObject {
|
||||||
function isPunct(c) {
|
function isPunct(c) {
|
||||||
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|_|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|_|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTick(wordCount) {
|
||||||
|
return (wordCount === 12 || wordCount === 15 ||
|
||||||
|
wordCount === 18 || wordCount === 21 || wordCount === 24)
|
||||||
|
? "✓ " : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function countWords(text) {
|
||||||
|
if (text.trim() === "")
|
||||||
|
return 0;
|
||||||
|
return text.trim().split(" ").length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns text in the format "✓ 12 words" for seed phrases input boxes
|
||||||
|
*/
|
||||||
|
function seedPhraseWordCountText(text) {
|
||||||
|
let wordCount = countWords(text);
|
||||||
|
return getTick(wordCount) + wordCount.toString() + " words";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,12 @@ ModalPopup {
|
||||||
KeyNavigation.tab: submitBtn
|
KeyNavigation.tab: submitBtn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: Utils.seedPhraseWordCountText(mnemonicTextField.text)
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: mnemonicTextField.bottom
|
||||||
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: errorText
|
id: errorText
|
||||||
visible: !!text && text != ""
|
visible: !!text && text != ""
|
||||||
|
|
|
@ -58,6 +58,8 @@ Item {
|
||||||
anchors.topMargin: Style.current.smallPadding
|
anchors.topMargin: Style.current.smallPadding
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
font.family: Style.current.fontRegular.name
|
font.family: Style.current.fontRegular.name
|
||||||
|
color: Style.current.textColor
|
||||||
|
placeholderTextColor: Style.current.darkGrey
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
Loading…
Reference in New Issue