2020-08-17 20:46:13 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
import "../../../../../imports"
|
|
|
|
import "../../../../../shared"
|
|
|
|
|
|
|
|
Popup {
|
2020-09-03 20:43:08 +00:00
|
|
|
id: root
|
|
|
|
width: buttonRow.width
|
|
|
|
height: buttonRow.height
|
|
|
|
padding: 0
|
|
|
|
margins: 0
|
2020-08-17 20:46:13 +00:00
|
|
|
|
2020-09-03 20:43:08 +00:00
|
|
|
background: Rectangle {
|
|
|
|
color: Style.current.background
|
|
|
|
radius: Style.current.radius
|
|
|
|
border.width: 0
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow {
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
2020-08-17 20:46:13 +00:00
|
|
|
|
2020-09-08 21:22:47 +00:00
|
|
|
function requestAddressForTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
|
2020-09-09 18:15:14 +00:00
|
|
|
amount = walletModel.eth2Wei(amount.toString(), tokenDecimals)
|
2020-09-08 21:22:47 +00:00
|
|
|
chatsModel.requestAddressForTransaction(chatsModel.activeChannel.id,
|
|
|
|
address,
|
|
|
|
amount,
|
|
|
|
tokenAddress)
|
|
|
|
chatCommandModal.close()
|
|
|
|
}
|
|
|
|
function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
|
2020-09-09 18:15:14 +00:00
|
|
|
amount = walletModel.eth2Wei(amount.toString(), tokenDecimals)
|
2020-09-08 21:22:47 +00:00
|
|
|
chatsModel.requestTransaction(chatsModel.activeChannel.id,
|
|
|
|
address,
|
|
|
|
amount,
|
|
|
|
tokenAddress)
|
|
|
|
chatCommandModal.close()
|
|
|
|
}
|
|
|
|
|
2020-09-03 20:43:08 +00:00
|
|
|
Row {
|
|
|
|
id: buttonRow
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 0
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 0
|
|
|
|
padding: Style.current.halfPadding
|
|
|
|
spacing: Style.current.halfPadding
|
2020-08-17 20:46:13 +00:00
|
|
|
|
2020-09-08 21:22:47 +00:00
|
|
|
|
2020-09-03 20:43:08 +00:00
|
|
|
ChatCommandButton {
|
|
|
|
iconColor: Style.current.purple
|
|
|
|
iconSource: "../../../../img/send.svg"
|
|
|
|
//% "Send transaction"
|
|
|
|
text: qsTrId("send-transaction")
|
|
|
|
onClicked: function () {
|
2020-09-08 21:22:47 +00:00
|
|
|
chatCommandModal.sendChatCommand = root.requestAddressForTransaction
|
|
|
|
chatCommandModal.isRequested = false
|
2020-09-03 20:14:44 +00:00
|
|
|
chatCommandModal.commandTitle = qsTr("Send")
|
|
|
|
chatCommandModal.title = chatCommandModal.commandTitle
|
|
|
|
chatCommandModal.finalButtonLabel = qsTr("Request Address")
|
|
|
|
chatCommandModal.selectedRecipient = {
|
|
|
|
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
|
2020-09-03 20:43:08 +00:00
|
|
|
identicon: chatsModel.activeChannel.identicon,
|
|
|
|
name: chatsModel.activeChannel.name,
|
|
|
|
type: RecipientSelector.Type.Contact
|
|
|
|
}
|
2020-09-03 20:14:44 +00:00
|
|
|
chatCommandModal.open()
|
|
|
|
root.close()
|
2020-09-03 20:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-17 20:46:13 +00:00
|
|
|
|
2020-09-08 21:22:47 +00:00
|
|
|
|
2020-09-03 20:43:08 +00:00
|
|
|
ChatCommandButton {
|
|
|
|
iconColor: Style.current.orange
|
|
|
|
iconSource: "../../../../img/send.svg"
|
|
|
|
rotatedImage: true
|
|
|
|
//% "Request transaction"
|
|
|
|
text: qsTrId("request-transaction")
|
2020-09-03 20:14:44 +00:00
|
|
|
onClicked: function () {
|
2020-09-08 21:22:47 +00:00
|
|
|
chatCommandModal.sendChatCommand = root.requestTransaction
|
|
|
|
chatCommandModal.isRequested = true
|
2020-09-03 20:14:44 +00:00
|
|
|
chatCommandModal.commandTitle = qsTr("Request")
|
|
|
|
chatCommandModal.title = chatCommandModal.commandTitle
|
|
|
|
chatCommandModal.finalButtonLabel = qsTr("Request")
|
|
|
|
chatCommandModal.selectedRecipient = {
|
|
|
|
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
|
|
|
|
identicon: chatsModel.activeChannel.identicon,
|
|
|
|
name: chatsModel.activeChannel.name,
|
|
|
|
type: RecipientSelector.Type.Contact
|
|
|
|
}
|
|
|
|
chatCommandModal.open()
|
|
|
|
root.close()
|
|
|
|
}
|
2020-09-03 20:43:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-03 20:14:44 +00:00
|
|
|
ChatCommandModal {
|
|
|
|
id: chatCommandModal
|
2020-09-03 20:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-17 20:46:13 +00:00
|
|
|
}
|