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

View File

@ -3,122 +3,50 @@ import "../../../../imports"
import "../../../../shared"
Item {
id: element
property alias valueInput: txtValue
id: sendModalContent
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"
StyledText {
id: modalDialogTitle
text: "Send"
anchors.left: parent.left
anchors.right: parent.right
Input {
id: txtAmount
label: qsTr("Amount")
icon: "../../../img/token-icons/eth.svg"
anchors.top: parent.top
anchors.left: parent.left
font.bold: true
font.pixelSize: 17
anchors.leftMargin: 16
anchors.topMargin: 16
placeholderText: qsTr("Enter ETH")
}
SVGImage {
id: closeModalImg
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: 16
anchors.topMargin: 16
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
Input {
id: txtFrom
label: qsTr("From account")
text: defaultAccount
placeholderText: qsTr("Send from (account)")
anchors.top: txtAmount.bottom
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 {
id: footerSeparator
anchors.bottom: parent.bottom
anchors.bottomMargin: 76
Input {
id: txtTo
label: qsTr("Recipient")
text: defaultAccount
placeholderText: qsTr("Send to")
anchors.top: txtFrom.bottom
anchors.topMargin: Theme.padding
}
StyledButton {
anchors.right: parent.right
anchors.rightMargin: Theme.padding
label: "Send"
anchors.bottom: parent.bottom
anchors.bottomMargin: Theme.padding
onClicked: {
let result = walletModel.onSendTransaction(txtFrom.text,
txtTo.text,
txtValue.text,
txtPassword.text)
console.log(result)
}
Input {
id: txtPassword
label: qsTr("Password")
placeholderText: qsTr("Enter Password")
anchors.top: txtTo.bottom
anchors.topMargin: Theme.padding
textField.echoMode: TextInput.Password
}
}

View File

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