refactor: replace StatusIdenticon with StatusSmartIdenticon

closes #3882
This commit is contained in:
Khushboo Mehta 2021-10-22 01:34:35 +02:00 committed by Iuri Matias
parent 781f86bd60
commit 173943f1be
8 changed files with 110 additions and 102 deletions

View File

@ -2,12 +2,12 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import "../../../../shared"
import "../../../../shared/panels"
import "../../../../shared/status"
import utils 1.0
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
Item {
id: wrapper
@ -53,17 +53,23 @@ Item {
}
}
StatusIdenticon {
StatusSmartIdenticon {
id: contactImage
height: 28
width: 28
chatId: wrapper.publicKey
chatName: wrapper.name
chatType: Constants.chatTypeOneToOne
identicon: wrapper.profileImage || wrapper.identicon
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
image: StatusImageSettings {
width: 28
height: 28
source: wrapper.profileImage || wrapper.identicon
isIdenticon: true
}
icon: StatusIconSettings {
width: 28
height: 28
letterSize: 15
}
name: wrapper.name
}
StyledText {

View File

@ -6,7 +6,9 @@ import Qt.labs.platform 1.1
import utils 1.0
import "../../../../../shared"
import "../../../../../shared/panels"
import "../../../../../shared/status"
import StatusQ.Components 0.1
import StatusQ.Core 0.1
Item {
id: channelBadge
@ -28,18 +30,23 @@ Item {
anchors.verticalCenter:parent.verticalCenter
}
StatusIdenticon {
StatusSmartIdenticon {
id: contactImage
height: 16
width: 16
chatId: chatId
chatName: name
chatType: realChatType
identicon: profileImage || identicon
anchors.left: channelIcon.right
anchors.leftMargin: 4
anchors.verticalCenter: parent.verticalCenter
letterSize: 11
image: StatusImageSettings {
width: 16
height: 16
source: profileImage || identicon
isIdenticon: true
}
icon: StatusIconSettings {
width: 16
height: 16
letterSize: 11
}
name: channelBadge.name
}
StyledText {

View File

@ -5,9 +5,9 @@ import utils 1.0
import "../../../../shared"
import "../../../../shared/panels"
import "../../../../shared/controls"
import "../../../../shared/status"
import StatusQ.Components 0.1 as StatusQ
import StatusQ.Core 0.1
Item {
id: wrapper
@ -180,18 +180,23 @@ Item {
anchors.verticalCenter:parent.verticalCenter
}
StatusIdenticon {
StatusQ.StatusSmartIdenticon {
id: contactImage
height: 16
width: 16
chatId: wrapper.chatId
chatName: wrapper.name
chatType: wrapper.realChatType
identicon: wrapper.profileImage || wrapper.identicon
anchors.left: channelIcon.right
anchors.leftMargin: 4
anchors.verticalCenter: parent.verticalCenter
letterSize: 11
image: StatusImageSettings {
width: 16
height: 16
source: wrapper.profileImage || wrapper.identicon
isIdenticon: true
}
icon: StatusIconSettings {
width: 16
height: 16
letterSize: 11
}
name: wrapper.name
}
StyledText {

View File

@ -3,7 +3,6 @@ import QtGraphicalEffects 1.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/status"
import "../../../../shared/popups"
import "../../../../shared/controls"
import "../../../../shared/panels"
@ -11,6 +10,9 @@ import "../../../../shared/panels"
import "../controls"
import "../panels"
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
Item {
id: root
width: parent.width
@ -42,17 +44,13 @@ Item {
anchors.topMargin: dateGroupLbl.visible ? 4 : 0
color: model.read ? Style.current.transparent : Utils.setColorAlpha(Style.current.blue, 0.1)
StatusIdenticon {
StatusSmartIdenticon {
id: channelIdenticon
height: 40
width: 40
chatId: model.chatId
chatName: model.name
chatType: Constants.chatTypePrivateGroupChat
identicon: ""
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.verticalCenter: parent.verticalCenter
name: model.name
icon.color: Theme.palette.miscColor5
}
Item {

View File

@ -6,11 +6,13 @@ import QtQuick.Layouts 1.13
import utils 1.0
import StatusQ.Controls 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
import "../../../../shared"
import "../../../../shared/popups"
import "../../../../shared/panels"
import "../../../../shared/status"
// TODO: replace with StatusModal
ModalPopup {
@ -39,16 +41,24 @@ ModalPopup {
radius: Style.current.radius
color: isHovered ? Style.current.backgroundHover : Style.current.transparent
StatusIdenticon {
StatusSmartIdenticon {
id: contactImage
height: 40
width: 40
chatName: model.name
chatType: model.chatType
identicon: model.identicon
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
image: StatusImageSettings {
width: 40
height: 40
source: model.identicon
isIdenticon: true
}
icon: StatusIconSettings {
width: 40
height: 40
letterSize: 15
color: Theme.palette.miscColor5
}
name: model.name
}
StyledText {

View File

@ -21,9 +21,11 @@ import Qt.labs.platform 1.1
import Qt.labs.settings 1.0
import StatusQ.Core.Theme 0.1
import StatusQ.Components 0.1
import StatusQ.Controls 0.1
import StatusQ.Layout 0.1
import StatusQ.Popups 0.1
import StatusQ.Core 0.1
Item {
@ -737,8 +739,22 @@ Item {
}
Component {
id: statusIdenticonComponent
StatusIdenticon {}
id: statusSmartIdenticonComponent
StatusSmartIdenticon {
property string imageSource: ""
image: StatusImageSettings {
width: channelPicker.imageWidth
height: channelPicker.imageHeight
source: imageSource
isIdenticon: true
}
icon: StatusIconSettings {
width: channelPicker.imageWidth
height: channelPicker.imageHeight
letterSize: 15
color: Theme.palette.miscColor5
}
}
}
StatusInputListPopup {
@ -754,12 +770,9 @@ Item {
return modelData.name
}
getImageComponent: function (parent, modelData) {
return statusIdenticonComponent.createObject(parent, {
width: channelPicker.imageWidth,
height: channelPicker.imageHeight,
chatName: modelData.name,
chatType: modelData.chatType,
identicon: modelData.identicon
return statusSmartIdenticonComponent.createObject(parent, {
imageSource: modelData.identicon,
name: modelData.name
});
}
onClicked: function (index) {

View File

@ -1,47 +0,0 @@
import QtQuick 2.13
import utils 1.0
import StatusQ.Components 0.1
import "../../shared"
Item {
id: root
property string chatId
property string chatName
property int chatType
property string identicon
property int letterSize: 15
width: 40
height: 40
Loader {
sourceComponent: root.chatType == Constants.chatTypeOneToOne || !!root.identicon ? imageIdenticon : letterIdenticon
anchors.fill: parent
}
Component {
id: letterIdenticon
StatusLetterIdenticon {
name: root.chatName
width: parent.width
height: parent.height
letterSize: root.letterSize
}
}
Component {
id: imageIdenticon
StatusImageIdenticon {
source: root.identicon
width: parent.width
height: parent.height
}
}
}

View File

@ -6,6 +6,10 @@ import utils 1.0
import "../../shared"
import "../../shared/panels"
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core 0.1
Rectangle {
id: root
property string chatId: ""
@ -33,12 +37,24 @@ Rectangle {
Component {
id: userOrChannelIdenticon
StatusIdenticon {
height: 40
width: 40
chatName: root.name
chatType: root.chatType
identicon: root.identicon
StatusSmartIdenticon {
id: contactImage
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
image: StatusImageSettings {
width: 40
height: 40
source: root.identicon
isIdenticon: true
}
icon: StatusIconSettings {
width: 40
height: 40
letterSize: 15
color: Theme.palette.miscColor5
}
name: root.name
}
}