diff --git a/src/app/chat/views/community_item.nim b/src/app/chat/views/community_item.nim index 3124f95648..7feff7b254 100644 --- a/src/app/chat/views/community_item.nim +++ b/src/app/chat/views/community_item.nim @@ -125,6 +125,11 @@ QtObject: read = nbMembers notify = nbMembersChanged + proc communityColor*(self: CommunityItemView): string {.slot.} = result = ?.self.communityItem.communityColor + + QtProperty[string] communityColor: + read = communityColor + proc chatsChanged*(self: CommunityItemView) {.signal.} proc getChats*(self: CommunityItemView): QVariant {.slot.} = diff --git a/src/app/chat/views/community_list.nim b/src/app/chat/views/community_list.nim index 2037ad310b..b8fa0ca646 100644 --- a/src/app/chat/views/community_list.nim +++ b/src/app/chat/views/community_list.nim @@ -22,6 +22,7 @@ type CanJoin = UserRole + 14 IsMember = UserRole + 15 UnviewedMessagesCount = UserRole + 16 + CommunityColor = UserRole + 17 QtObject: type @@ -77,6 +78,7 @@ QtObject: result = newQVariant(communityItem.communityImage.large) else: result = newQVariant("") + of CommunityRoles.CommunityColor: result = newQVariant(communityItem.communityColor) method roleNames(self: CommunityList): Table[int, string] = { @@ -95,7 +97,8 @@ QtObject: CommunityRoles.NumMembers.int: "nbMembers", CommunityRoles.UnviewedMessagesCount.int: "unviewedMessagesCount", CommunityRoles.ThumbnailImage.int:"thumbnailImage", - CommunityRoles.LargeImage.int:"largeImage" + CommunityRoles.LargeImage.int:"largeImage", + CommunityRoles.CommunityColor.int:"communityColor" }.toTable proc setNewData*(self: CommunityList, communityList: seq[Community]) = diff --git a/src/status/chat/chat.nim b/src/status/chat/chat.nim index 28f723ade7..6fca4a2c19 100644 --- a/src/status/chat/chat.nim +++ b/src/status/chat/chat.nim @@ -111,6 +111,7 @@ type Community* = object isMember*: bool communityImage*: IdentityImage membershipRequests*: seq[CommunityMembershipRequest] + communityColor*: string proc `$`*(self: Chat): string = result = fmt"Chat(id:{self.id}, name:{self.name}, active:{self.isActive}, type:{self.chatType})" diff --git a/src/status/signals/messages.nim b/src/status/signals/messages.nim index 1307b1f73b..170fd714ab 100644 --- a/src/status/signals/messages.nim +++ b/src/status/signals/messages.nim @@ -183,6 +183,7 @@ proc toCommunity*(jsonCommunity: JsonNode): Community = isMember: jsonCommunity{"isMember"}.getBool, chats: newSeq[Chat](), members: newSeq[string](), + communityColor: jsonCommunity{"color"}.getStr, communityImage: IdentityImage() ) diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/CommunityList.qml b/ui/app/AppLayouts/Chat/CommunityComponents/CommunityList.qml index d5f077bccd..813fb11de6 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CommunityList.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CommunityList.qml @@ -20,5 +20,7 @@ ListView { name: model.name image: model.thumbnailImage unviewedMessagesCount: model.unviewedMessagesCount + iconColor: model.communityColor + useLetterIdenticon: model.thumbnailImage === "" } } diff --git a/ui/shared/status/StatusIconTabButton.qml b/ui/shared/status/StatusIconTabButton.qml index 2f9c0188f9..d7bde06541 100644 --- a/ui/shared/status/StatusIconTabButton.qml +++ b/ui/shared/status/StatusIconTabButton.qml @@ -19,6 +19,8 @@ TabButton { property int sectionIndex: Utils.getAppSectionIndex(section) property bool doNotHandleClick: false property bool borderOnChecked: false + property bool useLetterIdenticon: false + property string name: "" onClicked: { if (doNotHandleClick) { @@ -55,7 +57,8 @@ TabButton { active: true anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - sourceComponent: !!iconSource ? imageIcon : defaultIcon + sourceComponent: useLetterIdenticon ? letterIdenticon : + !!iconSource ? imageIcon : defaultIcon } Component { @@ -84,6 +87,17 @@ TabButton { noMouseArea: true } } + + Component { + id: letterIdenticon + StatusLetterIdenticon { + width: 26 + height: 26 + letterSize: 15 + chatName: control.name + color: control.iconColor + } + } } background: Rectangle { color: hovered || (borderOnChecked && checked) ? Style.current.secondaryBackground : "transparent" diff --git a/ui/shared/status/StatusLetterIdenticon.qml b/ui/shared/status/StatusLetterIdenticon.qml index 3c80e87caa..a9be93149f 100644 --- a/ui/shared/status/StatusLetterIdenticon.qml +++ b/ui/shared/status/StatusLetterIdenticon.qml @@ -7,6 +7,7 @@ Rectangle { property string chatId property string chatName + property int letterSize: root.isCompact ? 15 : 21 width: 40 height: 40 @@ -24,9 +25,11 @@ Rectangle { text: (root.chatName.charAt(0) == "#" ? root.chatName.charAt(1) : root.chatName.charAt(0)).toUpperCase() opacity: 0.7 font.weight: Font.Bold - font.pixelSize: root.isCompact ? 15 : 21 + font.pixelSize: root.letterSize color: "white" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: -1 + anchors.bottomMargin: -2 } }