feat(StatusTagSelector): Added colorIdForPubkeyGet property (#702)

Needed for: https://github.com/status-im/status-desktop/issues/5875
This commit is contained in:
Alexandra Betouni 2022-06-01 10:47:38 +03:00 committed by Michał Cieślak
parent c7a2f6b479
commit b94debcaaf
2 changed files with 15 additions and 2 deletions

View File

@ -58,6 +58,11 @@ Page {
} }
return randomString.join().toString().replace(/,/g, ''); return randomString.join().toString().replace(/,/g, '');
} }
colorIdForPubkeyGetter: function (pubKey) {
//for simulation purposes only, in real app
//this would be Utils.colorIdForPubkey(pubKey);
return Math.floor(Math.random() * 10);
}
onTextChanged: { onTextChanged: {
sortModel(root.contactsModel); sortModel(root.contactsModel);
} }

View File

@ -96,19 +96,26 @@ Item {
property int nameCountLimit: 5 property int nameCountLimit: 5
/*! /*!
\qmlproperty var StatusTagSelector::ringSpecModel \qmlproperty var StatusTagSelector::ringSpecModelGetter
This property holds the function to calculate the ring spec model This property holds the function to calculate the ring spec model
based on the public key. based on the public key.
*/ */
property var ringSpecModelGetter: (pubKey) => { /*return ringSpecModel*/ } property var ringSpecModelGetter: (pubKey) => { /*return ringSpecModel*/ }
/*! /*!
\qmlproperty var StatusTagSelector::compressKey \qmlproperty var StatusTagSelector::compressKeyGetter
This property holds the function to calculate the compressed This property holds the function to calculate the compressed
key based on the public key. key based on the public key.
*/ */
property var compressedKeyGetter: (pubKey) => { /*return compressed key;*/ } property var compressedKeyGetter: (pubKey) => { /*return compressed key;*/ }
/*!
\qmlproperty var StatusTagSelector::colorIdForPubkeyGetter
This property holds the function to calculate the color Id
based on the public key.
*/
property var colorIdForPubkeyGetter: (pubKey) => { /*return color Id;*/ }
/*! /*!
\qmlproperty ListModel StatusTagSelector::sortedList \qmlproperty ListModel StatusTagSelector::sortedList
This property holds the sorted list model. This property holds the sorted list model.
@ -390,6 +397,7 @@ Item {
isMutualContact: model.isMutualContact isMutualContact: model.isMutualContact
image.source: model.icon image.source: model.icon
image.isIdenticon: model.isIdenticon image.isIdenticon: model.isIdenticon
icon.color: Theme.palette.userCustomizationColors[root.colorIdForPubkeyGetter(model.publicId)]
isOnline: model.onlineStatus isOnline: model.onlineStatus
statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4 statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4
ringSettings.ringSpecModel: root.ringSpecModelGetter(publicId) ringSettings.ringSpecModel: root.ringSpecModelGetter(publicId)