status-desktop/ui/app/AppLayouts/Onboarding/controls/AccountViewDelegate.qml

106 lines
2.8 KiB
QML
Raw Permalink Normal View History

import QtQuick 2.15
import QtQuick.Controls 2.15
import utils 1.0
2020-06-03 20:50:59 +00:00
import shared 1.0
import shared.panels 1.0
import shared.status 1.0
import shared.controls.chat 1.0
import StatusQ.Controls 0.1 as StatusQControls
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
Rectangle {
id: root
2020-06-03 20:50:59 +00:00
property string username: "Jotaro Kujo"
property string keyUid: "0x123345677890987654321123456"
property string address: ""
property var colorHash
property int colorId
property url image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAg0lEQVR4nOzXwQmAMBAFURV7sQybsgybsgyr0QYUlE1g+Mw7ioQMe9lMQwhDaAyhMYTGEJqYkPnrj/t5XE/ft2UdW1yken7MRAyhMYTGEBpDaAyhKe9JbzvSX9WdLWYihtAYQuMLkcYQGkPUScxEDKExhMYQGkNoDKExhMYQmjsAAP//ZfIUZgXTZXQAAAAASUVORK5CYII="
property var onAccountSelect: function() {}
2020-06-13 15:17:54 +00:00
property var isSelected: function() {}
property bool selected: {
return isSelected(index, keyUid)
2020-06-13 15:17:54 +00:00
}
property bool isHovered: false
2020-06-03 20:50:59 +00:00
height: 64
2020-06-03 20:50:59 +00:00
anchors.right: parent.right
anchors.left: parent.left
border.width: 0
color: getBgColor()
radius: Theme.radius
2020-06-03 20:50:59 +00:00
function getBgColor() {
if (selected) return Theme.palette.secondaryBackground
if (isHovered) return Theme.palette.backgroundHover
return Theme.palette.transparent
}
UserImage {
id: accountImage
anchors.left: parent.left
anchors.leftMargin: Theme.padding
anchors.verticalCenter: parent.verticalCenter
name: root.username
image: root.image
colorId: root.colorId
colorHash: root.colorHash
}
StyledText {
id: usernameText
text: username
2020-06-13 15:17:54 +00:00
elide: Text.ElideRight
anchors.right: parent.right
anchors.rightMargin: Theme.padding + radio.width
font.pixelSize: 17
anchors.top: accountImage.top
anchors.left: accountImage.right
anchors.leftMargin: Theme.padding
}
StyledText {
id: addressText
width: 108
text: address
font.family: Theme.monoFont.name
elide: Text.ElideMiddle
anchors.bottom: accountImage.bottom
anchors.bottomMargin: 0
anchors.left: usernameText.left
anchors.leftMargin: 0
font.pixelSize: 15
color: Theme.palette.secondaryText
}
StatusQControls.StatusRadioButton {
id: radio
anchors.right: parent.right
anchors.rightMargin: Theme.padding
anchors.verticalCenter: parent.verticalCenter
checked: root.selected
}
MouseArea {
hoverEnabled: true
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
onAccountSelect(index)
2020-06-03 20:50:59 +00:00
}
onEntered: {
root.isHovered = true
2020-06-03 20:50:59 +00:00
}
onExited: {
root.isHovered = false
2020-06-03 20:50:59 +00:00
}
}
}