forked from cerc-io/plugeth
Refactored simple send to use states
This commit is contained in:
parent
4d18798468
commit
5768b18a3b
@ -187,52 +187,89 @@ ApplicationWindow {
|
|||||||
anchors.bottomMargin: 5
|
anchors.bottomMargin: 5
|
||||||
id: newTransactionTab
|
id: newTransactionTab
|
||||||
Component.onCompleted:{
|
Component.onCompleted:{
|
||||||
addTab("Send ether", newTransaction)
|
addTab("Simple send", newTransaction)
|
||||||
addTab("Create contract", newContract)
|
addTab("Create contract", newContract)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
id: newTransaction
|
id: newTransaction
|
||||||
Column {
|
Column {
|
||||||
|
id: simpleSendColumn
|
||||||
|
states: [
|
||||||
|
State{
|
||||||
|
name: "ERROR"
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "DONE"
|
||||||
|
PropertyChanges { target: txSimpleValue; visible:false}
|
||||||
|
PropertyChanges { target: txSimpleRecipient; visible:false}
|
||||||
|
PropertyChanges { target:newSimpleTxButton; visible:false}
|
||||||
|
|
||||||
|
PropertyChanges { target: txSimpleResult; visible:true}
|
||||||
|
PropertyChanges { target: txSimpleOutput; visible:true}
|
||||||
|
PropertyChanges { target:newSimpleTxButton; visible:true}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "SETUP"
|
||||||
|
PropertyChanges { target: txSimpleValue; visible:true; text: ""}
|
||||||
|
PropertyChanges { target: txSimpleRecipient; visible:true; text: ""}
|
||||||
|
PropertyChanges { target: txSimpleButton; visible:true}
|
||||||
|
PropertyChanges { target:newSimpleTxButton; visible:false}
|
||||||
|
}
|
||||||
|
]
|
||||||
spacing: 5
|
spacing: 5
|
||||||
anchors.leftMargin: 5
|
anchors.leftMargin: 5
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|
||||||
|
function checkFormState(){
|
||||||
|
if(txSimpleRecipient.text.length == 40 && txSimpleValue.text.length > 0) {
|
||||||
|
txSimpleButton.state = "READY"
|
||||||
|
}else{
|
||||||
|
txSimpleButton.state = "NOTREADY"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: txSimpleRecipient
|
id: txSimpleRecipient
|
||||||
placeholderText: "Recipient address"
|
placeholderText: "Recipient address"
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
|
validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
|
||||||
width: 530
|
width: 530
|
||||||
|
onTextChanged: { checkFormState() }
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: txSimpleValue
|
id: txSimpleValue
|
||||||
placeholderText: "Amount"
|
placeholderText: "Amount"
|
||||||
anchors.rightMargin: 5
|
anchors.rightMargin: 5
|
||||||
validator: IntValidator { }
|
validator: IntValidator { }
|
||||||
|
onTextChanged: { checkFormState() }
|
||||||
}
|
}
|
||||||
Button {
|
Button {
|
||||||
id: txSimpleButton
|
id: txSimpleButton
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "READY"
|
||||||
|
PropertyChanges { target: txSimpleButton; enabled: true}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "NOTREADY"
|
||||||
|
PropertyChanges { target: txSimpleButton; enabled: false}
|
||||||
|
}
|
||||||
|
]
|
||||||
text: "Send"
|
text: "Send"
|
||||||
|
enabled: false
|
||||||
onClicked: {
|
onClicked: {
|
||||||
//this.enabled = false
|
//this.enabled = false
|
||||||
var res = eth.createTx(txSimpleRecipient.text, txSimpleValue.text,"","","")
|
var res = eth.createTx(txSimpleRecipient.text, txSimpleValue.text,"","","")
|
||||||
if(res[1]) {
|
if(res[1]) {
|
||||||
txSimpleResult.text = "There has been an error broadcasting your transaction:" + res[1].error()
|
txSimpleResult.text = "There has been an error broadcasting your transaction:" + res[1].error()
|
||||||
txSimpleResult.visible = true
|
|
||||||
} else {
|
} else {
|
||||||
txSimpleResult.text = "Your transaction has been broadcasted over the network.\nYour transaction id is:"
|
txSimpleResult.text = "Your transaction has been broadcasted over the network.\nYour transaction id is:"
|
||||||
txSimpleOutput.text = res[0]
|
txSimpleOutput.text = res[0]
|
||||||
txSimpleOutput.visible = true
|
|
||||||
txSimpleResult.visible = true
|
|
||||||
txSimpleValue.visible = false
|
|
||||||
txSimpleRecipient.visible = false
|
|
||||||
txSimpleValue.text = ""
|
|
||||||
txSimpleRecipient.text = ""
|
|
||||||
txSimpleRecipient.focus = true
|
|
||||||
newSimpleTxButton.visible = true
|
|
||||||
this.visible = false
|
this.visible = false
|
||||||
|
simpleSendColumn.state = "DONE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,13 +289,7 @@ ApplicationWindow {
|
|||||||
text: "Create an other transaction"
|
text: "Create an other transaction"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
this.visible = false
|
this.visible = false
|
||||||
txSimpleResult.text = ""
|
simpleSendColumn.state = "SETUP"
|
||||||
txSimpleOutput.text = ""
|
|
||||||
txSimpleResult.visible = false
|
|
||||||
txSimpleOutput.visible = false
|
|
||||||
txSimpleValue.visible = true
|
|
||||||
txSimpleRecipient.visible = true
|
|
||||||
txSimpleButton.visible = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user