Truncate long 3 words name. Fixes #1830

This commit is contained in:
ace-smart 2021-02-13 01:13:16 +04:00 committed by Iuri Matias
parent 3420593774
commit 6494d45b44
3 changed files with 10 additions and 2 deletions

View File

@ -86,7 +86,7 @@ PopupMenu {
StyledText {
id: username
text: Utils.removeStatusEns(userName)
text: Utils.truncateName(Utils.removeStatusEns(userName))
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
anchors.top: profileImage.bottom

View File

@ -67,7 +67,7 @@ ModalPopup {
StyledTextEdit {
id: profileName
text: Utils.removeStatusEns(userName)
text: Utils.truncateName(Utils.removeStatusEns(userName))
anchors.top: parent.top
anchors.topMargin: Style.current.padding
anchors.left: profilePic.right

View File

@ -74,6 +74,14 @@ QtObject {
return userName.endsWith(".stateofus.eth") ? userName.substr(0, userName.length - 14) : userName
}
function truncateName(name, num = 32) {
if (name.length <= num) {
return name;
}
return name.slice(0, num) + "...";
}
function isValidAddress(inputValue) {
return inputValue !== "0x" && /^0x[a-fA-F0-9]{40}$/.test(inputValue)
}