2023-05-16 08:25:40 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2023-09-04 10:19:02 +00:00
|
|
|
import utils 1.0
|
|
|
|
import AppLayouts.Wallet 1.0
|
|
|
|
|
2023-05-16 08:25:40 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
2023-09-04 10:19:02 +00:00
|
|
|
property int networkLayer: 0
|
2023-05-16 08:25:40 +00:00
|
|
|
property bool error: false
|
2023-08-02 04:36:54 +00:00
|
|
|
property bool pending: false
|
2023-05-24 06:22:29 +00:00
|
|
|
property int steps: isLayer1 ? 64 : 1
|
2023-05-16 08:25:40 +00:00
|
|
|
property int confirmations: 0
|
2023-05-24 06:22:29 +00:00
|
|
|
property int confirmationBlocks: isLayer1 ? 4 : 1
|
2023-05-16 08:25:40 +00:00
|
|
|
property string chainName
|
2023-09-04 10:19:02 +00:00
|
|
|
property int timestamp: 0
|
2023-05-16 08:25:40 +00:00
|
|
|
|
|
|
|
property color fillColor: Theme.palette.blockProgressBarColor
|
|
|
|
property color confirmationColor: Theme.palette.successColor1
|
|
|
|
|
|
|
|
property alias blockProgressBar: blockProgressBar
|
|
|
|
property alias titleText: title.text
|
|
|
|
property alias subText: subText.text
|
|
|
|
|
2023-09-04 10:19:02 +00:00
|
|
|
readonly property bool isValid: root.networkLayer > 0 && !!root.chainName
|
|
|
|
readonly property double confirmationTimeStamp: WalletUtils.calculateConfirmationTimestamp(root.networkLayer, root.timestamp)
|
|
|
|
readonly property double finalisationTimeStamp: WalletUtils.calculateFinalisationTimestamp(root.networkLayer, root.timestamp)
|
|
|
|
|
|
|
|
readonly property bool finalized: (isLayer1 ? confirmations >= steps : progress >= duration) && !error && !pending
|
|
|
|
readonly property bool confirmed: confirmations >= confirmationBlocks && !error && !pending
|
|
|
|
|
|
|
|
readonly property bool isLayer1: networkLayer === 1
|
|
|
|
|
2023-05-16 08:25:40 +00:00
|
|
|
// Below properties only needed when not a mainnet tx
|
2023-09-04 10:19:02 +00:00
|
|
|
property int duration: Constants.time.hoursIn7Days
|
2023-05-16 08:25:40 +00:00
|
|
|
property alias progress: progressBar.value
|
|
|
|
|
|
|
|
spacing: 8
|
2023-09-04 10:19:02 +00:00
|
|
|
visible: isValid
|
2023-05-16 08:25:40 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
lineHeight: 22
|
|
|
|
lineHeightMode: Text.FixedHeight
|
2023-08-02 04:36:54 +00:00
|
|
|
text: {
|
|
|
|
if (error) {
|
|
|
|
return qsTr("Failed on %1").arg(root.chainName)
|
|
|
|
} else if (pending) {
|
|
|
|
return qsTr("Confirmation in progress on %1...").arg(root.chainName)
|
2023-09-04 10:19:02 +00:00
|
|
|
} else if (root.finalized) {
|
2023-08-02 04:36:54 +00:00
|
|
|
return qsTr("Finalised on %1").arg(root.chainName)
|
2023-09-04 10:19:02 +00:00
|
|
|
} else if (root.confirmed) {
|
2023-08-02 04:36:54 +00:00
|
|
|
return qsTr("Confirmed on %1, finalisation in progress...").arg(root.chainName)
|
|
|
|
}
|
|
|
|
return qsTr("Pending on %1...").arg(root.chainName)
|
|
|
|
}
|
2023-05-16 08:25:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 2
|
|
|
|
Layout.preferredHeight: 12
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
StatusBlockProgressBar {
|
|
|
|
id: blockProgressBar
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-05-24 06:22:29 +00:00
|
|
|
visible: root.isLayer1
|
2023-05-16 08:25:40 +00:00
|
|
|
steps: root.steps
|
|
|
|
completedSteps: root.confirmations
|
|
|
|
blockSet: root.confirmationBlocks
|
|
|
|
error: root.error
|
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
spacing: 2
|
2023-05-24 06:22:29 +00:00
|
|
|
visible: !root.isLayer1
|
2023-05-16 08:25:40 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.preferredWidth: 3
|
|
|
|
Layout.fillHeight: true
|
|
|
|
color: error ? Theme.palette.dangerColor1 : confirmations > 0 ? confirmationColor : fillColor
|
|
|
|
radius: 100
|
|
|
|
}
|
|
|
|
StatusProgressBar {
|
|
|
|
id: progressBar
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
from: 0
|
2023-09-04 10:19:02 +00:00
|
|
|
to: root.duration
|
|
|
|
value: root.pending || root.error ? 0 : (Math.floor(Date.now() / 1000) - root.timestamp) / Constants.time.secondsInHour
|
2023-05-16 08:25:40 +00:00
|
|
|
backgroundColor: root.fillColor
|
|
|
|
backgroundBorderColor: "transparent"
|
|
|
|
fillColor: error ? "transparent": Theme.palette.primaryColor1
|
|
|
|
backgroundRadius: 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: subText
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
lineHeight: 18
|
|
|
|
lineHeightMode: Text.FixedHeight
|
2023-08-02 04:36:54 +00:00
|
|
|
text: {
|
2023-09-04 10:19:02 +00:00
|
|
|
if (root.finalized) {
|
2023-08-02 04:36:54 +00:00
|
|
|
return qsTr("In epoch %1").arg(root.confirmations)
|
2023-09-04 10:19:02 +00:00
|
|
|
} else if (root.confirmed && !root.isLayer1) {
|
|
|
|
return qsTr("%n day(s) until finality", "", Math.ceil((root.duration - root.progress) / Constants.time.hoursInDay))
|
2023-08-02 04:36:54 +00:00
|
|
|
}
|
|
|
|
return qsTr("%1 / %2 confirmations").arg(root.confirmations).arg(root.steps)
|
|
|
|
}
|
2023-05-16 08:25:40 +00:00
|
|
|
}
|
|
|
|
}
|