feat(StatusLetterIdenticon): make useAcronymForLetterIdenticon mode charactersLen unaware
This commit is contained in:
parent
aeb9929fcd
commit
b2ab3a455a
|
@ -13,6 +13,13 @@ Rectangle {
|
||||||
property int letterSize: 21
|
property int letterSize: 21
|
||||||
property int charactersLen: 1
|
property int charactersLen: 1
|
||||||
property color letterIdenticonColor: Theme.palette.miscColor5
|
property color letterIdenticonColor: Theme.palette.miscColor5
|
||||||
|
|
||||||
|
// In this mode, one or two letters are used depending on words used:
|
||||||
|
// John -> J
|
||||||
|
// John Smith -> JS
|
||||||
|
// John Smith Junior -> JS
|
||||||
|
//
|
||||||
|
// characterLen is ignored
|
||||||
property bool useAcronymForLetterIdenticon: false
|
property bool useAcronymForLetterIdenticon: false
|
||||||
property bool strictBackgroundColor: !useAcronymForLetterIdenticon
|
property bool strictBackgroundColor: !useAcronymForLetterIdenticon
|
||||||
|
|
||||||
|
@ -57,19 +64,18 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
text: {
|
text: {
|
||||||
let parts = root.name.split(" ")
|
const parts = root.name.split(" ")
|
||||||
if (root.useAcronymForLetterIdenticon && parts.length > 1) {
|
|
||||||
let word = ""
|
|
||||||
for (let i=0; i<root.charactersLen; i++) {
|
|
||||||
if (i >= parts.length) {
|
|
||||||
return word
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (root.useAcronymForLetterIdenticon) {
|
||||||
|
let word = ""
|
||||||
|
|
||||||
|
for (let i = 0; i < Math.min(parts.length, 2); i++) {
|
||||||
let shift = (parts[i].charAt(0) === "#") ||
|
let shift = (parts[i].charAt(0) === "#") ||
|
||||||
(parts[i].charAt(0) === "@")
|
(parts[i].charAt(0) === "@")
|
||||||
|
|
||||||
word += parts[i].substring(shift, shift + 1).toUpperCase()
|
word += parts[i].substring(shift, shift + 1).toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
return word
|
return word
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,6 @@ StatusListItem {
|
||||||
width: 40
|
width: 40
|
||||||
height: 40
|
height: 40
|
||||||
color: Utils.getColorForId(root.colorId)
|
color: Utils.getColorForId(root.colorId)
|
||||||
charactersLen: {
|
|
||||||
let parts = root.name.split(" ")
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
isLetterIdenticon: true
|
isLetterIdenticon: true
|
||||||
useAcronymForLetterIdenticon: true
|
useAcronymForLetterIdenticon: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -563,12 +563,7 @@ StatusModal {
|
||||||
color: model.color
|
color: model.color
|
||||||
isLetterIdenticon: !model.icon
|
isLetterIdenticon: !model.icon
|
||||||
useAcronymForLetterIdenticon: model.type === AddEditSavedAddressPopup.CardType.SavedAddress
|
useAcronymForLetterIdenticon: model.type === AddEditSavedAddressPopup.CardType.SavedAddress
|
||||||
charactersLen: {
|
charactersLen: 2
|
||||||
if (model.type === AddEditSavedAddressPopup.CardType.SavedAddress && model.title.split(" ").length == 1) {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,13 +231,7 @@ StatusModal {
|
||||||
name: !root.selectedAccount.name && !root.selectedAccount.emoji? "status-logo-icon" : ""
|
name: !root.selectedAccount.name && !root.selectedAccount.emoji? "status-logo-icon" : ""
|
||||||
color: !root.selectedAccount.name && !root.selectedAccount.emoji? "transparent" : Utils.getColorForId(root.selectedAccount.colorId)
|
color: !root.selectedAccount.name && !root.selectedAccount.emoji? "transparent" : Utils.getColorForId(root.selectedAccount.colorId)
|
||||||
emoji: root.selectedAccount.emoji
|
emoji: root.selectedAccount.emoji
|
||||||
charactersLen: {
|
charactersLen: 1
|
||||||
let parts = root.selectedAccount.name.split(" ")
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
isLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
isLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
||||||
useAcronymForLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
useAcronymForLetterIdenticon: root.selectedAccount.name && !root.selectedAccount.emoji
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,13 +54,6 @@ StatusDialog {
|
||||||
name: root.name
|
name: root.name
|
||||||
asset {
|
asset {
|
||||||
color: Utils.getColorForId(root.colorId)
|
color: Utils.getColorForId(root.colorId)
|
||||||
charactersLen: {
|
|
||||||
let parts = root.name.split(" ")
|
|
||||||
if (parts.length > 1) {
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
isLetterIdenticon: true
|
isLetterIdenticon: true
|
||||||
useAcronymForLetterIdenticon: true
|
useAcronymForLetterIdenticon: true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue