Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
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
2021-09-28 15:28:00 -04:00

97 lines
3.1 KiB
QML

import QtQuick 2.3
import QtGraphicalEffects 1.13
import "../../../../../../shared"
import utils 1.0
Rectangle {
property int state: Constants.pending
property bool outgoing: true
id: root
width: childrenRect.width + 24
height: 28
border.width: 1
border.color: Style.current.border
radius: 24
color: Style.current.background
SVGImage {
id: stateImage
source: {
switch (root.state) {
case Constants.pending:
case Constants.addressReceived:
case Constants.transactionRequested:
case Constants.addressRequested: return Style.svg("dotsLoadings")
case Constants.confirmed: return Style.svg("check")
case Constants.transactionDeclined:
case Constants.declined: return Style.svg("exclamation")
default: return ""
}
}
width: 16
height: 16
anchors.left: parent.left
anchors.leftMargin: Style.current.halfPadding
anchors.verticalCenter: stateText.verticalCenter
}
ColorOverlay {
anchors.fill: stateImage
source: stateImage
color: state === Constants.confirmed ? Style.current.transparent : Style.current.textColor
}
StyledText {
id: stateText
color: {
if (root.state === Constants.unknown || root.state === Constants.failure) {
return Style.current.danger
}
if (root.state === Constants.confirmed || root.state === Constants.declined) {
return Style.current.textColor
}
return Style.current.secondaryText
}
text: {
switch (root.state) {
//% "Pending"
case Constants.pending: return qsTrId("invite-chat-pending")
//% "Confirmed"
case Constants.confirmed: return qsTrId("status-confirmed")
//% "Unknown token"
case Constants.unknown: return qsTrId("unknown-token")
//% "Address requested"
case Constants.addressRequested: return qsTrId("address-requested")
//% "Waiting to accept"
case Constants.transactionRequested: return qsTrId("waiting-to-accept")
case Constants.addressReceived: return (!root.outgoing ?
//% "Address shared"
qsTrId("address-shared") :
//% "Address received"
qsTrId("address-received"))
case Constants.transactionDeclined:
//% "Transaction declined"
case Constants.declined: return qsTrId("transaction-declined")
//% "failure"
case Constants.failure: return qsTrId("failure")
//% "Unknown state"
default: return qsTrId("unknown-state")
}
}
font.weight: Font.Medium
anchors.left: stateImage.right
anchors.leftMargin: 4
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 13
}
}
/*##^##
Designer {
D{i:0;formeditorColor:"#808080";formeditorZoom:2}
}
##^##*/