status-desktop/ui/app/AppLayouts/Wallet/AddCustomTokenModal.qml

125 lines
3.1 KiB
QML
Raw Normal View History

2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import "../../../imports"
import "../../../shared"
ModalPopup {
id: popup
2020-10-30 19:22:54 +00:00
property bool editable: true
property int marginBetweenInputs: 35
2020-10-30 19:22:54 +00:00
title: editable ?
//% "Add custom token"
qsTrId("add-custom-token")
: nameInput.text
height: editable ? 450 : 380
onOpened: {
2020-11-02 18:18:13 +00:00
addressInput.forceActiveFocus(Qt.MouseFocusReason)
}
function openEditable(){
2020-10-30 19:22:54 +00:00
addressInput.text = "";
nameInput.text = "";
symbolInput.text = "";
decimalsInput.text = "";
2020-11-02 18:18:13 +00:00
editable = true;
open();
}
2020-11-02 18:18:13 +00:00
function openWithData(address, name, symbol, decimals){
2020-10-30 19:22:54 +00:00
addressInput.text = address;
nameInput.text = name;
symbolInput.text = symbol;
decimalsInput.text = decimals;
editable = false;
2020-11-02 18:18:13 +00:00
open();
2020-10-30 19:22:54 +00:00
}
Input {
id: addressInput
2020-10-30 19:22:54 +00:00
readOnly: !editable
//% "Enter contract address..."
placeholderText: qsTrId("enter-contract-address...")
//% "Contract address"
label: qsTrId("contract-address")
}
Input {
id: nameInput
2020-10-30 19:22:54 +00:00
readOnly: !editable
anchors.top: addressInput.bottom
anchors.topMargin: marginBetweenInputs
//% "The name of your token..."
placeholderText: qsTrId("the-name-of-your-token...")
//% "Name"
label: qsTrId("name")
}
2020-11-02 18:18:13 +00:00
Input {
id: symbolInput
readOnly: !editable
//% "ABC"
placeholderText: qsTrId("abc")
//% "Symbol"
label: qsTrId("symbol")
anchors.top: nameInput.bottom
anchors.topMargin: marginBetweenInputs
2020-10-30 19:22:54 +00:00
anchors.left: parent.left
2020-11-02 18:18:13 +00:00
anchors.right: undefined
width: parent.width / 2 - 20
}
2020-11-02 18:18:13 +00:00
Input {
id: decimalsInput
readOnly: !editable
placeholderText: "18"
//% "Decimals"
label: qsTrId("decimals")
text: "18"
2020-10-30 19:22:54 +00:00
anchors.top: nameInput.bottom
anchors.topMargin: marginBetweenInputs
2020-10-30 19:22:54 +00:00
anchors.right: parent.right
2020-11-02 18:18:13 +00:00
anchors.left: undefined
width: parent.width / 2 - 20
}
2020-11-02 18:18:13 +00:00
footer: Item {
2020-10-30 19:22:54 +00:00
visible: editable
anchors.fill: parent
StyledButton {
id: addBtn
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
//% "Add"
label: qsTrId("add")
disabled: addressInput.text === "" || nameInput.text === "" || symbolInput.text === "" || decimalsInput.text === ""
onClicked : {
const error = walletModel.addCustomToken(addressInput.text, nameInput.text, symbolInput.text, decimalsInput.text);
if (error) {
errorSound.play()
changeError.text = error
changeError.open()
return
}
walletModel.loadCustomTokens()
popup.close();
}
}
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/