wowlet/src/vr/qml/wallet/send/SendPageTransfer.qml

280 lines
8.1 KiB
QML
Raw Normal View History

2021-04-05 11:37:41 +00:00
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
2021-04-08 01:40:44 +00:00
2021-04-05 11:37:41 +00:00
import "../../common"
ColumnLayout {
id: root
spacing: 30
2021-04-08 01:40:44 +00:00
property string txDialogText: ""
2021-04-09 16:00:12 +00:00
property string amount: ""
property string amount_type: "wow"
2021-04-05 11:37:41 +00:00
property bool canSend: false
Layout.fillWidth: true
MyText {
Layout.fillWidth: true
wrap: true
2021-04-08 01:40:44 +00:00
fontColor: Style.fontColorBright
2021-04-05 11:37:41 +00:00
text: "How much would you like to send?"
}
2021-04-09 16:00:12 +00:00
function count(input, needle) {
return input.split(".").length - 1;
2021-04-05 11:37:41 +00:00
}
RowLayout {
2021-04-09 16:00:12 +00:00
spacing: 40
ColumnLayout {
Layout.preferredWidth: 320
Layout.preferredHeight: 400
MyNumPad {
id: numPad
compact: true
onButtonPress: {
let periods = count(root.amount, ".");
if(periods == 1 && val === ".") return;
if(root.amount === "" && val === ".") return;
if(root.amount.length > 7) return;
root.amount += val;
}
onClearPress: {
root.amount = "";
}
}
Rectangle {
Layout.fillHeight: true
Layout.preferredWidth: parent.Layout.preferredWidth
color: "transparent"
}
}
ColumnLayout {
spacing: 14
Layout.fillHeight: true
Layout.preferredWidth: 280
MyPushButton {
id: wowButton
opacity: enabled ? 1.0 : 0.4
enabled: root.amount_type === "fiat"
Layout.preferredWidth: 280
Layout.preferredHeight: 108
text: "Wownero"
onClicked: {
root.amount_type = "wow"
}
}
MyPushButton {
id: fiatBtn
opacity: enabled ? 1.0 : 0.4
enabled: root.amount_type === "wow"
Layout.preferredWidth: 280
Layout.preferredHeight: 108
text: "Fiat"
onClicked: {
root.amount_type = "fiat"
}
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
}
2021-04-05 11:37:41 +00:00
ColumnLayout {
spacing: 10
Layout.fillHeight: true
2021-04-09 16:00:12 +00:00
2021-04-05 11:37:41 +00:00
RowLayout {
spacing: 30
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle {
color: "transparent"
Layout.preferredWidth: 192
Layout.preferredHeight: 48
MyText {
fontBold: true
text: "Amount:"
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle {
color: "transparent"
Layout.fillWidth: true
2021-04-08 01:40:44 +00:00
Layout.preferredHeight: 68
2021-04-05 11:37:41 +00:00
MyText {
fontSize: 32
2021-04-08 01:40:44 +00:00
fontColor: Style.fontColorBright
2021-04-09 16:00:12 +00:00
text: {
let rtn = "";
if(root.amount === "") rtn += "0.0"
else if(root.amount_type === "wow") {
rtn += root.amount;
} else {
try {
rtn += WowletVR.fiatToWow(root.amount);
} catch(err) {
return "ERROR";
}
}
return rtn + " WOW";
}
2021-04-05 11:37:41 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
}
}
}
RowLayout {
spacing: 30
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle {
color: "transparent"
Layout.preferredWidth: 192
Layout.preferredHeight: 48
MyText {
fontBold: true
text: "Fiat:"
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle {
color: "transparent"
Layout.fillWidth: true
Layout.preferredHeight: 48
MyText {
2021-04-08 01:40:44 +00:00
id: fiatText
fontSize: 26
2021-04-08 01:40:44 +00:00
fontColor: Style.fontColorBright
2021-04-09 16:00:12 +00:00
text: {
let rtn = "";
if(root.amount === "") rtn += "0.0"
else if(root.amount_type === "fiat") {
rtn += root.amount;
} else {
try {
rtn += WowletVR.wowToFiat(root.amount);
} catch(err) {
return "ERROR";
}
}
return rtn + " " + appWindow.fiatSymbol
}
2021-04-05 11:37:41 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
}
}
}
RowLayout {
spacing: 30
Layout.fillWidth: true
Layout.fillHeight: true
Rectangle {
color: "transparent"
Layout.preferredWidth: 192
Layout.preferredHeight: 48
MyText {
fontBold: true
text: "Destination:"
anchors.verticalCenter: parent.verticalCenter
}
}
Rectangle {
color: "transparent"
Layout.fillWidth: true
Layout.preferredHeight: 48
MyText {
2021-04-08 01:40:44 +00:00
text: destinationAddress.slice(0, 12) + "...";
fontColor: Style.fontColorBright
2021-04-05 11:37:41 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
}
}
}
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
2021-04-09 16:00:12 +00:00
MyPushButton {
id: sendButton
2021-04-05 11:37:41 +00:00
2021-04-09 16:00:12 +00:00
Layout.preferredWidth: 420
Layout.alignment: Qt.AlignRight
2021-04-05 11:37:41 +00:00
2021-04-09 16:00:12 +00:00
text: "Create transaction"
2021-04-05 11:37:41 +00:00
2021-04-09 16:00:12 +00:00
onClicked: {
if(amount === "") return;
2021-04-05 11:37:41 +00:00
2021-04-09 16:00:12 +00:00
let _amount = parseFloat(amount);
if(root.amount_type == "fiat") {
try {
_amount = WowletVR.fiatToWow(_amount);
} catch(err) {
messagePopup.showMessage("Error", "Could not convert fiat to wow.");
return;
}
}
2021-04-08 01:40:44 +00:00
2021-04-09 16:00:12 +00:00
if(amount <= 0) {
messagePopup.showMessage("Error", "Amount was zero.");
return;
}
2021-04-06 00:20:42 +00:00
2021-04-09 16:00:12 +00:00
WowletVR.onCreateTransaction(destinationAddress, _amount.toString(), "", false); // no description
sendButton.enabled = false;
}
2021-04-05 11:37:41 +00:00
}
}
}
2021-04-09 16:00:12 +00:00
function onPageCompleted() {
root.amount = "";
root.amount_type = "wow";
root.txDialogText = "";
2021-04-08 01:40:44 +00:00
}
2021-04-09 16:00:12 +00:00
Item {
Layout.fillWidth: true
Layout.fillHeight: true
2021-04-08 01:40:44 +00:00
}
Component.onCompleted: {
}
2021-04-05 11:37:41 +00:00
}