2024-05-01 16:15:42 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQml 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2024-07-04 13:33:05 +00:00
|
|
|
import StatusQ.Components 0.1
|
2024-05-01 16:15:42 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2024-07-05 09:32:31 +00:00
|
|
|
import AppLayouts.Wallet.services.dapps.types 1.0
|
|
|
|
|
2024-05-01 16:15:42 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
readonly property bool valid: input.valid && input.text.length > 0
|
|
|
|
readonly property alias text: input.text
|
2024-07-04 13:33:05 +00:00
|
|
|
property alias pending: input.pending
|
2024-07-08 11:18:14 +00:00
|
|
|
property int errorState: Pairing.errors.notChecked
|
2024-05-01 16:15:42 +00:00
|
|
|
|
|
|
|
StatusBaseInput {
|
|
|
|
id: input
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 132
|
|
|
|
|
|
|
|
placeholderText: qsTr("Paste URI")
|
|
|
|
|
|
|
|
verticalAlignment: TextInput.AlignTop
|
|
|
|
|
|
|
|
valid: {
|
|
|
|
let uri = input.text
|
|
|
|
|
2024-07-05 09:32:31 +00:00
|
|
|
errorText.text = ""
|
2024-05-01 16:15:42 +00:00
|
|
|
if(uri.length === 0) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-07-08 11:18:14 +00:00
|
|
|
if(root.errorState === Pairing.errors.tooCool) {
|
2024-05-01 16:15:42 +00:00
|
|
|
errorText.text = qsTr("WalletConnect URI too cool")
|
2024-07-08 11:18:14 +00:00
|
|
|
} else if(root.errorState === Pairing.errors.invalidUri) {
|
2024-05-01 16:15:42 +00:00
|
|
|
errorText.text = qsTr("WalletConnect URI invalid")
|
2024-07-08 11:18:14 +00:00
|
|
|
} else if(root.errorState === Pairing.errors.alreadyUsed) {
|
2024-05-01 16:15:42 +00:00
|
|
|
errorText.text = qsTr("WalletConnect URI already used")
|
2024-07-08 11:18:14 +00:00
|
|
|
} else if(root.errorState === Pairing.errors.expired) {
|
2024-05-01 16:15:42 +00:00
|
|
|
errorText.text = qsTr("WalletConnect URI has expired")
|
2024-07-08 11:18:14 +00:00
|
|
|
} else if(root.errorState === Pairing.errors.unsupportedNetwork) {
|
|
|
|
errorText.text = qsTr("dApp is requesting to connect on an unsupported network")
|
|
|
|
} else if(root.errorState === Pairing.errors.unknownError) {
|
|
|
|
errorText.text = qsTr("Unexpected error occurred. Try again.")
|
2024-07-05 09:32:31 +00:00
|
|
|
}
|
2024-07-08 11:18:14 +00:00
|
|
|
|
2024-07-05 09:32:31 +00:00
|
|
|
if (errorText.text.length > 0) {
|
2024-05-01 16:15:42 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
rightComponent: Item {
|
|
|
|
width: pasteButton.implicitWidth
|
|
|
|
height: pasteButton.implicitHeight
|
|
|
|
|
|
|
|
readonly property bool showIcon: input.valid && input.text.length > 0
|
|
|
|
|
2024-07-04 13:33:05 +00:00
|
|
|
StatusLoadingIndicator {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
color: Theme.palette.blue
|
|
|
|
visible: showIcon && input.pending
|
|
|
|
}
|
|
|
|
|
2024-05-01 16:15:42 +00:00
|
|
|
StatusIcon {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
icon: "tiny/tiny-checkmark"
|
|
|
|
color: Theme.palette.green
|
2024-07-04 13:33:05 +00:00
|
|
|
visible: showIcon && !input.pending
|
2024-05-01 16:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: pasteButton
|
|
|
|
|
|
|
|
text: qsTr("Paste")
|
|
|
|
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
|
|
|
|
visible: !showIcon
|
|
|
|
|
|
|
|
borderWidth: enabled ? 1 : 0
|
|
|
|
borderColor: textColor
|
|
|
|
|
|
|
|
enabled: input.edit.canPaste
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
input.edit.paste()
|
|
|
|
input.edit.focus = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
multiline: true
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: errorText
|
|
|
|
|
|
|
|
visible: !input.valid && input.text.length !== 0
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
}
|