mirror of
https://github.com/status-im/status-desktop.git
synced 2025-03-02 15:31:04 +00:00
Introduced Style.svg() Style.png() Style.emoji() and Style.icon() in Style.qml. Those should be used to set the source in Images instead of using relative paths. Usage: Image { source: Style.svg("check) .... Also moved all Singletons inside a new "utils" folder and made it a QML module, to use import utils 1.0 instead of relative paths Closes #3678
73 lines
2.2 KiB
QML
73 lines
2.2 KiB
QML
import QtQuick 2.13
|
|
import QtQuick.Controls 2.13
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import utils 1.0
|
|
import "../../../../shared"
|
|
|
|
Item {
|
|
property string channelName
|
|
property int channelType
|
|
property string channelIdenticon
|
|
readonly property int defaultFontSize: 21
|
|
property int fontSize: defaultFontSize
|
|
id: contactImage
|
|
width: 36
|
|
height: 36
|
|
|
|
Loader {
|
|
sourceComponent: channelType == Constants.chatTypeOneToOne ? imageIdenticon : letterIdenticon
|
|
anchors.fill: parent
|
|
}
|
|
|
|
Component {
|
|
id: letterIdenticon
|
|
Rectangle {
|
|
width: contactImage.width
|
|
height: contactImage.height
|
|
radius: 50
|
|
color: {
|
|
const color = chatsModel.channelView.getChannelColor(channelName)
|
|
if (!color) {
|
|
return Style.current.transparent
|
|
}
|
|
return color
|
|
}
|
|
|
|
StyledText {
|
|
text: {
|
|
if (channelType == Constants.chatTypeOneToOne) {
|
|
return channelName
|
|
} else {
|
|
return (channelName.charAt(0) == "#" ? channelName.charAt(1) : channelName.charAt(0)).toUpperCase()
|
|
}
|
|
}
|
|
opacity: 0.7
|
|
font.weight: Font.Bold
|
|
font.pixelSize: fontSize
|
|
color: "white"
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|
|
}
|
|
|
|
Component {
|
|
id: imageIdenticon
|
|
Rectangle {
|
|
width: contactImage.width ? contactImage.width : 40
|
|
height: contactImage.height ? contactImage.height : 40
|
|
radius: 50
|
|
border.color: Style.current.border
|
|
border.width: 1
|
|
color: Style.current.background
|
|
SVGImage {
|
|
width: contactImage.width ? contactImage.width : 40
|
|
height: contactImage.height ? contactImage.height : 40
|
|
fillMode: Image.PreserveAspectFit
|
|
source: channelIdenticon
|
|
}
|
|
}
|
|
}
|
|
}
|