2024-07-01 15:56:44 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml.Models 2.15
|
2024-07-11 21:00:15 +00:00
|
|
|
import QtGraphicalEffects 1.15
|
2024-07-01 15:56:44 +00:00
|
|
|
|
|
|
|
import StatusQ 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
|
|
|
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
StatusDialog {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property int loginType // RootStore.loginType -> Constants.LoginType enum
|
|
|
|
|
|
|
|
property Component headerIconComponent
|
|
|
|
|
|
|
|
property bool feesLoading
|
2024-07-11 21:00:15 +00:00
|
|
|
property bool signButtonEnabled: true
|
2024-07-01 15:56:44 +00:00
|
|
|
|
|
|
|
property ObjectModel leftFooterContents
|
|
|
|
property ObjectModel rightFooterContents: ObjectModel {
|
|
|
|
RowLayout {
|
|
|
|
Layout.rightMargin: 4
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
StatusFlatButton {
|
|
|
|
objectName: "rejectButton"
|
|
|
|
Layout.preferredHeight: signButton.height
|
|
|
|
text: qsTr("Reject")
|
|
|
|
onClicked: root.reject() // close and emit rejected() signal
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
objectName: "signButton"
|
|
|
|
id: signButton
|
2024-07-11 21:00:15 +00:00
|
|
|
interactive: !root.feesLoading && root.signButtonEnabled
|
2024-07-01 15:56:44 +00:00
|
|
|
icon.name: Constants.authenticationIconByType[root.loginType]
|
2024-07-10 18:35:24 +00:00
|
|
|
disabledColor: Theme.palette.directColor8
|
2024-07-01 15:56:44 +00:00
|
|
|
text: qsTr("Sign")
|
|
|
|
onClicked: root.accept() // close and emit accepted() signal
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property color gradientColor: backgroundColor
|
|
|
|
property url fromImageSource
|
2024-07-04 11:55:16 +00:00
|
|
|
property alias fromImageSmartIdenticon: fromImageSmartIdenticon
|
2024-07-01 15:56:44 +00:00
|
|
|
property url toImageSource
|
2024-07-11 21:00:15 +00:00
|
|
|
readonly property alias toImageSmartIdenticon: toImageSmartIdenticon
|
2024-07-01 15:56:44 +00:00
|
|
|
property alias headerMainText: headerMainText.text
|
2024-07-11 21:00:15 +00:00
|
|
|
readonly property alias headerSubTextLayout: headerSubTextLayout.children
|
2024-07-01 15:56:44 +00:00
|
|
|
property string infoTagText
|
2024-07-11 21:00:15 +00:00
|
|
|
readonly property alias infoTag: infoTag
|
|
|
|
property bool showHeaderDivider: true
|
2024-07-01 15:56:44 +00:00
|
|
|
|
2024-07-11 21:00:15 +00:00
|
|
|
default property alias contents: contentsLayout.data
|
2024-07-01 15:56:44 +00:00
|
|
|
|
|
|
|
width: 480
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
function formatBigNumber(number: string, decimals = -1) {
|
|
|
|
if (!number)
|
|
|
|
return ""
|
|
|
|
const big = SQUtils.AmountsArithmetic.fromString(number)
|
|
|
|
const resultNum = decimals === -1 ? big.toFixed() : big.round(decimals).toFixed()
|
|
|
|
return resultNum.replace('.', Qt.locale().decimalPoint)
|
|
|
|
}
|
|
|
|
|
2024-07-04 11:55:16 +00:00
|
|
|
function openLinkWithConfirmation(linkUrl) {
|
|
|
|
Global.openLinkWithConfirmation(linkUrl, SQUtils.StringUtils.extractDomainFromLink(linkUrl))
|
|
|
|
}
|
|
|
|
|
2024-07-01 15:56:44 +00:00
|
|
|
header: StatusDialogHeader {
|
|
|
|
visible: root.title || root.subtitle
|
|
|
|
headline.title: root.title
|
|
|
|
headline.subtitle: root.subtitle
|
|
|
|
actions.closeButton.onClicked: root.closeHandler()
|
|
|
|
|
|
|
|
leftComponent: root.headerIconComponent
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: StatusDialogFooter {
|
|
|
|
dropShadowEnabled: true
|
|
|
|
|
|
|
|
leftButtons: root.leftFooterContents
|
|
|
|
rightButtons: root.rightFooterContents
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: scrollView
|
|
|
|
anchors.fill: parent
|
|
|
|
contentWidth: availableWidth
|
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 4
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
// header box with gradient
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: -parent.anchors.leftMargin - scrollView.leftPadding
|
|
|
|
Layout.rightMargin: -parent.anchors.rightMargin - scrollView.rightPadding
|
2024-07-04 11:55:16 +00:00
|
|
|
Layout.preferredHeight: childrenRect.height + 80 // 40 + 40 top/bottomMargin
|
2024-07-01 15:56:44 +00:00
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop { position: 0.0; color: root.gradientColor }
|
|
|
|
GradientStop { position: 1.0; color: root.backgroundColor }
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: 336 // by design
|
|
|
|
spacing: 12
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
Row {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.topMargin: 4
|
|
|
|
spacing: -10
|
2024-07-04 11:55:16 +00:00
|
|
|
StatusSmartIdenticon {
|
|
|
|
objectName: "fromImageIdenticon"
|
|
|
|
id: fromImageSmartIdenticon
|
|
|
|
width: 40
|
|
|
|
height: 40
|
2024-07-11 21:00:15 +00:00
|
|
|
asset.name: root.fromImageSource
|
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
2024-07-04 11:55:16 +00:00
|
|
|
asset.bgWidth: 40
|
|
|
|
asset.bgHeight: 40
|
2024-07-11 21:00:15 +00:00
|
|
|
asset.color: "transparent"
|
|
|
|
asset.bgColor: "transparent"
|
2024-07-04 11:55:16 +00:00
|
|
|
visible: !!asset.name
|
2024-07-11 21:00:15 +00:00
|
|
|
layer.enabled: toImageSmartIdenticon.visible
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
id: mask
|
|
|
|
invert: true
|
|
|
|
|
|
|
|
maskSource: Item {
|
|
|
|
width: mask.width + 4
|
|
|
|
height: mask.height + 4
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.horizontalCenterOffset: toImageSmartIdenticon.width - 10
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: width
|
|
|
|
radius: width / 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-07-04 11:55:16 +00:00
|
|
|
}
|
2024-07-11 21:00:15 +00:00
|
|
|
|
|
|
|
StatusSmartIdenticon {
|
|
|
|
objectName: "toImageIdenticon"
|
|
|
|
id: toImageSmartIdenticon
|
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
asset.bgWidth: 40
|
|
|
|
asset.bgHeight: 40
|
|
|
|
visible: !!asset.name || !!asset.source
|
|
|
|
asset.name: root.toImageSource
|
|
|
|
asset.width: 40
|
|
|
|
asset.height: 40
|
|
|
|
asset.color: "transparent"
|
|
|
|
asset.bgColor: "transparent"
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: headerMainText
|
|
|
|
objectName: "headerText"
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
lineHeight: 22
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: headerSubTextLayout
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
spacing: 4
|
|
|
|
}
|
|
|
|
|
|
|
|
InformationTag {
|
|
|
|
id: infoTag
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
asset.name: "info"
|
|
|
|
tagPrimaryLabel.text: root.infoTagText
|
|
|
|
visible: !!root.infoTagText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusDialogDivider {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
2024-07-11 21:00:15 +00:00
|
|
|
visible: root.showHeaderDivider
|
2024-07-01 15:56:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
id: contentsLayout
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|