refator: change send modal to use the shared component

This commit is contained in:
Jonathan Rainville 2020-06-26 12:08:51 -04:00 committed by Iuri Matias
parent 0e5d6225f0
commit 6d77c81048
3 changed files with 57 additions and 133 deletions

View File

@ -6,37 +6,33 @@ import "../../../imports"
import "../../../shared" import "../../../shared"
import "./components" import "./components"
Item { ModalPopup {
function open() { id: popup
popup.open()
sendModalContent.valueInput.text = "" title: qsTr("Send")
sendModalContent.valueInput.forceActiveFocus(Qt.MouseFocusReason)
onOpened: {
sendModalContent.amountInput.text = ""
sendModalContent.amountInput.forceActiveFocus(Qt.MouseFocusReason)
sendModalContent.defaultAccount = walletModel.getDefaultAccount() sendModalContent.defaultAccount = walletModel.getDefaultAccount()
} }
function close() { SendModalContent {
popup.close() id: sendModalContent
} }
Popup { footer: StyledButton {
id: popup anchors.top: parent.top
modal: true anchors.right: parent.right
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside anchors.rightMargin: Theme.padding
Overlay.modal: Rectangle { label: qsTr("Send")
color: "#60000000"
} onClicked: {
parent: Overlay.overlay let result = walletModel.onSendTransaction(sendModalContent.fromText,
x: Math.round((parent.width - width) / 2) sendModalContent.toText,
y: Math.round((parent.height - height) / 2) sendModalContent.amountText,
width: 480 sendModalContent.passwordText)
height: 510 console.log(result)
background: Rectangle {
color: Theme.white
radius: Theme.radius
}
padding: 0
contentItem: SendModalContent {
id: sendModalContent
} }
} }
} }

View File

@ -3,122 +3,50 @@ import "../../../../imports"
import "../../../../shared" import "../../../../shared"
Item { Item {
id: element id: sendModalContent
property alias valueInput: txtValue property alias amountInput: txtAmount
property alias amountText: txtAmount.text
property alias fromText: txtFrom.text
property alias toText: txtTo.text
property alias passwordText: txtPassword.text
property string defaultAccount: "0x1234" property string defaultAccount: "0x1234"
StyledText { anchors.left: parent.left
id: modalDialogTitle anchors.right: parent.right
text: "Send"
Input {
id: txtAmount
label: qsTr("Amount")
icon: "../../../img/token-icons/eth.svg"
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left placeholderText: qsTr("Enter ETH")
font.bold: true
font.pixelSize: 17
anchors.leftMargin: 16
anchors.topMargin: 16
} }
SVGImage { Input {
id: closeModalImg id: txtFrom
anchors.top: parent.top label: qsTr("From account")
anchors.right: parent.right text: defaultAccount
anchors.rightMargin: 16 placeholderText: qsTr("Send from (account)")
anchors.topMargin: 16 anchors.top: txtAmount.bottom
source: "../../../../shared/img/close.svg"
width: 25
height: 25
MouseArea {
id: closeModalMouseArea
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
popup.close()
}
}
}
Separator {
id: headerSeparator
anchors.top: modalDialogTitle.bottom
}
Item {
id: modalBody
anchors.right: parent.right
anchors.rightMargin: 32
anchors.top: headerSeparator.bottom
anchors.topMargin: Theme.padding anchors.topMargin: Theme.padding
anchors.bottom: footerSeparator.top
anchors.bottomMargin: 16
anchors.left: parent.left
anchors.leftMargin: 32
Input {
id: txtValue
label: "Amount"
icon: "../../../img/token-icons/eth.svg"
anchors.top: parent.top
placeholderText: qsTr("Enter ETH")
}
Input {
id: txtFrom
label: "From account"
text: defaultAccount
placeholderText: qsTr("Send from (account)")
anchors.top: txtValue.bottom
anchors.topMargin: Theme.padding
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
}
Input {
id: txtTo
label: "Recipient"
text: defaultAccount
placeholderText: qsTr("Send to")
anchors.top: txtFrom.bottom
anchors.topMargin: Theme.padding
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
}
Input {
id: txtPassword
label: "Password"
placeholderText: "Enter Password"
anchors.top: txtTo.bottom
anchors.topMargin: Theme.padding
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
}
} }
Separator { Input {
id: footerSeparator id: txtTo
anchors.bottom: parent.bottom label: qsTr("Recipient")
anchors.bottomMargin: 76 text: defaultAccount
placeholderText: qsTr("Send to")
anchors.top: txtFrom.bottom
anchors.topMargin: Theme.padding
} }
StyledButton { Input {
anchors.right: parent.right id: txtPassword
anchors.rightMargin: Theme.padding label: qsTr("Password")
label: "Send" placeholderText: qsTr("Enter Password")
anchors.bottom: parent.bottom anchors.top: txtTo.bottom
anchors.bottomMargin: Theme.padding anchors.topMargin: Theme.padding
onClicked: { textField.echoMode: TextInput.Password
let result = walletModel.onSendTransaction(txtFrom.text,
txtTo.text,
txtValue.text,
txtPassword.text)
console.log(result)
}
} }
} }

View File

@ -66,7 +66,7 @@ Item {
anchors.rightMargin: parent.rightMargin anchors.rightMargin: parent.rightMargin
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 0 anchors.leftMargin: 0
leftPadding: inputBox.hasIcon ? 36 : Theme.padding leftPadding: inputBox.hasIcon ? iconWidth + 20 : Theme.padding
selectByMouse: true selectByMouse: true
font.pixelSize: fontPixelSize font.pixelSize: fontPixelSize
background: Rectangle { background: Rectangle {