feat(@desktop/wallet): Loading animation for input data decoding (#11378)

closes #11333
This commit is contained in:
Cuteivist 2023-07-10 15:36:29 +02:00 committed by GitHub
parent 11389facc0
commit 9b293f9c34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 14 deletions

View File

@ -146,9 +146,11 @@ QML_DEBUG ?= false
QML_DEBUG_PORT ?= 49152 QML_DEBUG_PORT ?= 49152
ifneq ($(QML_DEBUG), false) ifneq ($(QML_DEBUG), false)
STATUSQ_BUILD_TYPE=Debug
DOTHERSIDE_CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=Debug -DQML_DEBUG_PORT=$(QML_DEBUG_PORT) DOTHERSIDE_CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=Debug -DQML_DEBUG_PORT=$(QML_DEBUG_PORT)
DOTHERSIDE_BUILD_CMD := cmake --build . --config Debug DOTHERSIDE_BUILD_CMD := cmake --build . --config Debug
else else
STATUSQ_BUILD_TYPE=Release
DOTHERSIDE_CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=Release DOTHERSIDE_CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=Release
DOTHERSIDE_BUILD_CMD := cmake --build . --config Release DOTHERSIDE_BUILD_CMD := cmake --build . --config Release
endif endif
@ -259,7 +261,7 @@ STATUSQ_CMAKE_CACHE := $(STATUSQ_BUILD_PATH)/CMakeCache.txt
$(STATUSQ_CMAKE_CACHE): | deps $(STATUSQ_CMAKE_CACHE): | deps
echo -e "\033[92mConfiguring:\033[39m StatusQ" echo -e "\033[92mConfiguring:\033[39m StatusQ"
cmake -DCMAKE_INSTALL_PREFIX=$(STATUSQ_INSTALL_PATH) \ cmake -DCMAKE_INSTALL_PREFIX=$(STATUSQ_INSTALL_PATH) \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=$(STATUSQ_BUILD_TYPE) \
-DSTATUSQ_BUILD_SANDBOX=OFF \ -DSTATUSQ_BUILD_SANDBOX=OFF \
-DSTATUSQ_BUILD_SANITY_CHECKER=OFF \ -DSTATUSQ_BUILD_SANITY_CHECKER=OFF \
-DSTATUSQ_BUILD_TESTS=OFF \ -DSTATUSQ_BUILD_TESTS=OFF \
@ -275,7 +277,7 @@ statusq-build: | statusq-configure
echo -e "\033[92mBuilding:\033[39m StatusQ" echo -e "\033[92mBuilding:\033[39m StatusQ"
cmake --build $(STATUSQ_BUILD_PATH) \ cmake --build $(STATUSQ_BUILD_PATH) \
--target StatusQ \ --target StatusQ \
--config Release \ --config $(STATUSQ_BUILD_TYPE) \
$(HANDLE_OUTPUT) $(HANDLE_OUTPUT)
statusq-install: | statusq-build statusq-install: | statusq-build

View File

@ -86,6 +86,8 @@ Rectangle {
property alias errorIcon: errorIcon property alias errorIcon: errorIcon
property alias statusListItemTagsRowLayout: statusListItemSubtitleTagsRow property alias statusListItemTagsRowLayout: statusListItemSubtitleTagsRow
property int subTitleBadgeLoaderAlignment: Qt.AlignVCenter
signal clicked(string itemId, var mouse) signal clicked(string itemId, var mouse)
signal titleClicked(string titleId) signal titleClicked(string titleId)
signal iconClicked(var mouse) signal iconClicked(var mouse)
@ -279,7 +281,7 @@ Rectangle {
Loader { Loader {
id: subTitleBadgeLoader id: subTitleBadgeLoader
Layout.alignment: Qt.AlignVCenter Layout.alignment: root.subTitleBadgeLoaderAlignment
visible: sourceComponent visible: sourceComponent
} }

View File

@ -34,6 +34,7 @@ Item {
d.decodedInputData = "" d.decodedInputData = ""
if (!transaction || !transaction.input || !RootStore.history) if (!transaction || !transaction.input || !RootStore.history)
return return
d.loadingInputDate = true
RootStore.history.fetchDecodedTxData(transaction.txHash, transaction.input) RootStore.history.fetchDecodedTxData(transaction.txHash, transaction.input)
} }
@ -60,6 +61,7 @@ Item {
readonly property string toNetworkName: "" // TODO fill network name for bridge readonly property string toNetworkName: "" // TODO fill network name for bridge
property string decodedInputData: "" property string decodedInputData: ""
property bool loadingInputDate: false
function getNameForSavedWalletAddress(address) { function getNameForSavedWalletAddress(address) {
return RootStore.getNameForSavedWalletAddress(address) return RootStore.getNameForSavedWalletAddress(address)
@ -73,8 +75,13 @@ Item {
Connections { Connections {
target: RootStore.history target: RootStore.history
function onTxDecoded(txHash: string, dataDecoded: string) { function onTxDecoded(txHash: string, dataDecoded: string) {
if (!root.isTransactionValid || txHash !== root.transaction.txHash || !dataDecoded) if (!root.isTransactionValid || txHash !== root.transaction.txHash)
return return
if (!dataDecoded) {
d.loadingInputDate = false
return
}
try { try {
const decodedObject = JSON.parse(dataDecoded) const decodedObject = JSON.parse(dataDecoded)
let text = qsTr("Function: %1").arg(decodedObject.signature) let text = qsTr("Function: %1").arg(decodedObject.signature)
@ -86,6 +93,7 @@ Item {
} catch(e) { } catch(e) {
console.error("Failed to parse decoded tx data. Data:", dataDecoded) console.error("Failed to parse decoded tx data. Data:", dataDecoded)
} }
d.loadingInputDate = false
} }
} }
@ -339,7 +347,7 @@ Item {
width: progressBlock.width width: progressBlock.width
RowLayout { RowLayout {
width: parent.width width: parent.width
height: Math.max(implicitHeight, 85) height: networkNameTile.statusListItemSubTitle.lineCount > 1 ? 85 : 70
spacing: 0 spacing: 0
TransactionDataTile { TransactionDataTile {
id: multichainNetworksTile id: multichainNetworksTile
@ -370,11 +378,13 @@ Item {
} }
} }
TransactionDataTile { TransactionDataTile {
id: networkNameTile
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
title: qsTr("Network") title: qsTr("Network")
subTitle: transactionHeader.networkName subTitle: transactionHeader.networkName
asset.name: !!d.networkIcon ? Style.svg("%1".arg(d.networkIcon)) : "" asset.name: !!d.networkIcon ? Style.svg(d.networkIcon) : ""
subTitleBadgeLoaderAlignment: Qt.AlignTop
smallIcon: true smallIcon: true
visible: d.transactionType !== Constants.TransactionType.Bridge visible: d.transactionType !== Constants.TransactionType.Bridge
} }
@ -394,23 +404,24 @@ Item {
} }
} }
TransactionDataTile { TransactionDataTile {
id: inputDataTile
width: parent.width width: parent.width
height: Math.min(implicitHeight + bottomPadding, 112) height: d.loadingInputDate ? 112 : Math.min(implicitHeight + bottomPadding, 112)
title: qsTr("Input data") title: qsTr("Input data")
// Input string can be really long. Getting substring just for 3+ lines to speedup formatting.
subTitle: { subTitle: {
if (!!d.decodedInputData) { if (d.loadingInputDate) {
return d.decodedInputData return ""
} else if (!!d.decodedInputData) {
return d.decodedInputData.substring(0, 100)
} else if (root.isTransactionValid) { } else if (root.isTransactionValid) {
return root.transaction.input return String(root.transaction.input).substring(0, 100)
} }
return "" return ""
} }
visible: !!subTitle visible: !!subTitle || d.loadingInputDate
buttonIconName: "more" buttonIconName: d.loadingInputDate ? "" : "more"
statusListItemSubTitle.maximumLineCount: 4 statusListItemSubTitle.maximumLineCount: 4
statusListItemSubTitle.lineHeight: 1.21 statusListItemSubTitle.lineHeight: 1.21
onButtonClicked: addressMenu.openInputDataMenu(this, subTitle)
statusListItemSubTitle.layer.enabled: statusListItemSubTitle.lineCount > 3 statusListItemSubTitle.layer.enabled: statusListItemSubTitle.lineCount > 3
statusListItemSubTitle.layer.effect: OpacityMask { statusListItemSubTitle.layer.effect: OpacityMask {
maskSource: Rectangle { maskSource: Rectangle {
@ -423,6 +434,35 @@ Item {
} }
} }
} }
tertiaryTitle: !d.loadingInputDate && !d.decodedInputData ? qsTr("Data could not be decoded") : ""
statusListItemTertiaryTitle.anchors.baseline: statusListItemTitle.baseline
statusListItemTertiaryTitle.font: statusListItemTitle.font
onButtonClicked: addressMenu.openInputDataMenu(this, !!d.decodedInputData ? d.decodedInputData : root.transaction.input)
Loader {
anchors {
left: parent.left
bottom: parent.bottom
right: parent.right
margins: 12
}
active: d.loadingInputDate
sourceComponent: Column {
spacing: 10
Repeater {
model: 3
LoadingComponent {
anchors {
left: parent.left
right: index === 2 ? parent.horizontalCenter : parent.right
}
height: 11
radius: 4
enabled: false
}
}
}
}
} }
TransactionDataTile { TransactionDataTile {
width: parent.width width: parent.width

View File

@ -89,6 +89,7 @@ StatusListItem {
statusListItemTagsRowLayout.spacing: 8 statusListItemTagsRowLayout.spacing: 8
subTitleBadgeComponent: !!asset.name ? iconComponent : null subTitleBadgeComponent: !!asset.name ? iconComponent : null
statusListItemIcon.asset: StatusAssetSettings {} statusListItemIcon.asset: StatusAssetSettings {}
statusListItemIcon.name: ""
Component { Component {
id: iconComponent id: iconComponent