From 312858b4204825ce47d36bacfcf7a8fb327ff652 Mon Sep 17 00:00:00 2001 From: Alexandra Betouni <31625338+alexandraB99@users.noreply.github.com> Date: Wed, 1 Jun 2022 10:47:38 +0300 Subject: [PATCH] feat(StatusTagSelector): Added colorIdForPubkeyGet property (#702) Needed for: https://github.com/status-im/status-desktop/issues/5875 --- sandbox/demoapp/CreateChatView.qml | 5 +++++ src/StatusQ/Components/StatusTagSelector.qml | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sandbox/demoapp/CreateChatView.qml b/sandbox/demoapp/CreateChatView.qml index 5804d8ff..0b2f0ad3 100644 --- a/sandbox/demoapp/CreateChatView.qml +++ b/sandbox/demoapp/CreateChatView.qml @@ -58,6 +58,11 @@ Page { } 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: { sortModel(root.contactsModel); } diff --git a/src/StatusQ/Components/StatusTagSelector.qml b/src/StatusQ/Components/StatusTagSelector.qml index 7fe3be89..4a4e01f7 100644 --- a/src/StatusQ/Components/StatusTagSelector.qml +++ b/src/StatusQ/Components/StatusTagSelector.qml @@ -96,19 +96,26 @@ Item { property int nameCountLimit: 5 /*! - \qmlproperty var StatusTagSelector::ringSpecModel + \qmlproperty var StatusTagSelector::ringSpecModelGetter This property holds the function to calculate the ring spec model based on the public key. */ property var ringSpecModelGetter: (pubKey) => { /*return ringSpecModel*/ } /*! - \qmlproperty var StatusTagSelector::compressKey + \qmlproperty var StatusTagSelector::compressKeyGetter This property holds the function to calculate the compressed key based on the public 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 This property holds the sorted list model. @@ -390,6 +397,7 @@ Item { isMutualContact: model.isMutualContact image.source: model.icon image.isIdenticon: model.isIdenticon + icon.color: Theme.palette.userCustomizationColors[root.colorIdForPubkeyGetter(model.publicId)] isOnline: model.onlineStatus statusListItemIcon.badge.border.color: sensor.containsMouse ? Theme.palette.baseColor2 : Theme.palette.baseColor4 ringSettings.ringSpecModel: root.ringSpecModelGetter(publicId)