clean(@wallet): remove old manage assets
this has been moved to the wallet settings
This commit is contained in:
parent
9f7a90d486
commit
7754822bc8
|
@ -1,197 +0,0 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
import shared.panels 1.0
|
||||
import shared.popups 1.0
|
||||
import shared.controls 1.0
|
||||
|
||||
Item {
|
||||
id: modalBody
|
||||
|
||||
property var defaultTokenList
|
||||
property var customTokenList
|
||||
signal toggleVisibleClicked(int chainId, string symbol)
|
||||
signal removeCustomTokenTriggered(int chainId, string address)
|
||||
signal showTokenDetailsTriggered(int chainId, string address, string name, string symbol, string decimals)
|
||||
|
||||
SearchBox {
|
||||
id: searchBox
|
||||
customHeight: 36
|
||||
fontPixelSize: 12
|
||||
anchors.top: modalBody.top
|
||||
}
|
||||
|
||||
Component {
|
||||
id: tokenComponent
|
||||
Rectangle {
|
||||
id: tokenContainer
|
||||
property bool hovered: false
|
||||
width: modalBody.width
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
color: hovered ? Style.current.backgroundHover : "transparent"
|
||||
property bool isVisible: symbol && (searchBox.text == "" || name.toLowerCase().includes(searchBox.text.toLowerCase()) || symbol.toLowerCase().includes(searchBox.text.toLowerCase()))
|
||||
|
||||
visible: isVisible
|
||||
height: isVisible ? 40 + Style.current.smallPadding : 0
|
||||
radius: Style.current.radius
|
||||
|
||||
Image {
|
||||
id: assetInfoImage
|
||||
width: 36
|
||||
height: tokenContainer.isVisible !== "" ? 36 : 0
|
||||
source: Style.png("tokens/" + (hasIcon ? symbol : "DEFAULT-TOKEN@3x"))
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
onStatusChanged: {
|
||||
if (assetInfoImage.status == Image.Error) {
|
||||
assetInfoImage.source = Style.png("tokens/DEFAULT-TOKEN@3x")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
StyledText {
|
||||
id: assetSymbol
|
||||
text: symbol
|
||||
anchors.left: assetInfoImage.right
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
anchors.top: assetInfoImage.top
|
||||
anchors.topMargin: 0
|
||||
font.pixelSize: 15
|
||||
}
|
||||
StyledText {
|
||||
id: assetFullTokenName
|
||||
text: name || ""
|
||||
anchors.top: assetSymbol.bottom
|
||||
anchors.topMargin: 0
|
||||
anchors.left: assetInfoImage.right
|
||||
anchors.leftMargin: Style.current.smallPadding
|
||||
color: Style.current.secondaryText
|
||||
font.pixelSize: 15
|
||||
}
|
||||
StatusCheckBox {
|
||||
id: assetCheck
|
||||
checked: model.isVisible
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.smallPadding
|
||||
onClicked: toggleVisibleClicked(chainId, symbol)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: function (event) {
|
||||
if (event.button === Qt.RightButton) {
|
||||
return contextMenu.popup(assetSymbol.x - 100, assetSymbol.y + 25)
|
||||
}
|
||||
assetCheck.checked = !assetCheck.checked
|
||||
toggleVisibleClicked(chainId, symbol)
|
||||
}
|
||||
onEntered: {
|
||||
tokenContainer.hovered = true
|
||||
}
|
||||
onExited: {
|
||||
tokenContainer.hovered = false
|
||||
}
|
||||
// TODO: replace with StatusPopupMenu
|
||||
PopupMenu {
|
||||
id: contextMenu
|
||||
Action {
|
||||
icon.source: Style.svg("make-admin")
|
||||
//% "Token details"
|
||||
text: qsTrId("token-details")
|
||||
onTriggered: {
|
||||
modalBody.showTokenDetailsTriggered(chainId, address, name, symbol, decimals);
|
||||
}
|
||||
}
|
||||
Action {
|
||||
icon.source: Style.svg("remove-from-group")
|
||||
icon.color: Style.current.red
|
||||
enabled: isCustom
|
||||
//% "Remove token"
|
||||
text: qsTrId("remove-token")
|
||||
onTriggered: removeCustomTokenTriggered(chainId, address)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
id: sview
|
||||
clip: true
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
||||
|
||||
contentHeight: tokenList.height
|
||||
|
||||
anchors.top: searchBox.bottom
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
|
||||
Item {
|
||||
id: tokenList
|
||||
height: childrenRect.height
|
||||
|
||||
Column {
|
||||
id: customTokens
|
||||
spacing: Style.current.halfPadding
|
||||
visible: { modalBody.customTokenList.count > 0 }
|
||||
|
||||
StyledText {
|
||||
id: customLbl
|
||||
//% "Custom"
|
||||
text: qsTrId("custom")
|
||||
font.pixelSize: 13
|
||||
color: Style.current.secondaryText
|
||||
height: 20
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: customTokensRepeater
|
||||
model: modalBody.customTokenList
|
||||
delegate: tokenComponent
|
||||
anchors.top: customLbl.bottom
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.top: customTokens.bottom
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
id: defaultTokens
|
||||
spacing: Style.current.halfPadding
|
||||
|
||||
StyledText {
|
||||
id: defaultLbl
|
||||
//% "Default"
|
||||
text: qsTrId("default")
|
||||
font.pixelSize: 13
|
||||
color: Style.current.secondaryText
|
||||
height: 20
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: modalBody.defaultTokenList
|
||||
delegate: tokenComponent
|
||||
anchors.top: defaultLbl.bottom
|
||||
anchors.topMargin: Style.current.smallPadding
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -106,15 +106,6 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: tokenSettingsModalComponent
|
||||
TokenSettingsModal {
|
||||
onClosed: {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: accountSettingsModalComponent
|
||||
AccountSettingsModal {
|
||||
|
@ -200,16 +191,6 @@ Item {
|
|||
icon.height: 16
|
||||
onTriggered: Global.openPopup(accountSettingsModalComponent)
|
||||
}
|
||||
Action {
|
||||
//% "Manage Assets"
|
||||
text: qsTrId("manage-assets")
|
||||
icon.source: Style.svg("add_remove_token")
|
||||
icon.width: 16
|
||||
icon.height: 16
|
||||
onTriggered: {
|
||||
Global.openPopup(tokenSettingsModalComponent)
|
||||
}
|
||||
}
|
||||
Action {
|
||||
//% "Set Currency"
|
||||
text: qsTrId("set-currency")
|
||||
|
|
|
@ -1,182 +0,0 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Dialogs 1.3
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
import shared.popups 1.0
|
||||
import shared.controls 1.0
|
||||
import "../stores"
|
||||
|
||||
// TODO: replace with StatusModal
|
||||
ModalPopup {
|
||||
id: popup
|
||||
|
||||
property bool editable: true
|
||||
property int marginBetweenInputs: 35
|
||||
property string validationError: ""
|
||||
|
||||
title: editable ?
|
||||
//% "Add custom token"
|
||||
qsTrId("add-custom-token")
|
||||
: nameInput.text
|
||||
|
||||
height: editable ? 450 : 380
|
||||
|
||||
onOpened: {
|
||||
addressInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
||||
function openEditable(){
|
||||
addressInput.text = "";
|
||||
nameInput.text = "";
|
||||
symbolInput.text = "";
|
||||
decimalsInput.text = "";
|
||||
editable = true;
|
||||
open();
|
||||
}
|
||||
|
||||
function openWithData(address, name, symbol, decimals){
|
||||
addressInput.text = address;
|
||||
nameInput.text = name;
|
||||
symbolInput.text = symbol;
|
||||
decimalsInput.text = decimals;
|
||||
editable = false;
|
||||
open();
|
||||
}
|
||||
|
||||
|
||||
function validate() {
|
||||
if (addressInput.text !== "" && !Utils.isAddress(addressInput.text)) {
|
||||
//% "This needs to be a valid address"
|
||||
validationError = qsTrId("this-needs-to-be-a-valid-address");
|
||||
}
|
||||
return validationError === ""
|
||||
}
|
||||
|
||||
property var getTokenDetails: Backpressure.debounce(popup, 500, function (tokenAddress){
|
||||
RootStore.walletTokensModule.getTokenDetails(tokenAddress)
|
||||
});
|
||||
|
||||
function onKeyReleased(){
|
||||
validationError = "";
|
||||
if (!validate() || addressInput.text === "") {
|
||||
return;
|
||||
}
|
||||
Qt.callLater(getTokenDetails, addressInput.text)
|
||||
}
|
||||
|
||||
Item {
|
||||
Connections {
|
||||
target: RootStore.walletTokensModule
|
||||
onTokenDetailsWereResolved: {
|
||||
const jsonObj = JSON.parse(tokenDetails)
|
||||
if (jsonObj.error) {
|
||||
validationError = jsonObj.error
|
||||
return
|
||||
}
|
||||
if (jsonObj.name === "" && jsonObj.symbol === "" && jsonObj.decimals === "") {
|
||||
//% "Invalid ERC20 address"
|
||||
validationError = qsTrId("invalid-erc20-address")
|
||||
return;
|
||||
}
|
||||
|
||||
if (addressInput.text.toLowerCase() === jsonObj.address.toLowerCase()) {
|
||||
symbolInput.text = jsonObj.symbol;
|
||||
decimalsInput.text = jsonObj.decimals;
|
||||
nameInput.text = jsonObj.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Input {
|
||||
id: addressInput
|
||||
readOnly: !editable
|
||||
textField.maximumLength: 42
|
||||
//% "Enter contract address..."
|
||||
placeholderText: qsTrId("enter-contract-address...")
|
||||
//% "Contract address"
|
||||
label: qsTrId("contract-address")
|
||||
validationError: popup.validationError
|
||||
Keys.onReleased: onKeyReleased()
|
||||
}
|
||||
|
||||
Input {
|
||||
id: nameInput
|
||||
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")
|
||||
}
|
||||
|
||||
Input {
|
||||
id: symbolInput
|
||||
readOnly: !editable
|
||||
//% "ABC"
|
||||
placeholderText: qsTrId("abc")
|
||||
//% "Symbol"
|
||||
label: qsTrId("symbol")
|
||||
anchors.top: nameInput.bottom
|
||||
anchors.topMargin: marginBetweenInputs
|
||||
anchors.left: parent.left
|
||||
anchors.right: undefined
|
||||
width: parent.width / 2 - 20
|
||||
}
|
||||
|
||||
Input {
|
||||
id: decimalsInput
|
||||
readOnly: !editable
|
||||
placeholderText: "18"
|
||||
//% "Decimals"
|
||||
label: qsTrId("decimals")
|
||||
text: "18"
|
||||
anchors.top: nameInput.bottom
|
||||
anchors.topMargin: marginBetweenInputs
|
||||
anchors.right: parent.right
|
||||
anchors.left: undefined
|
||||
width: parent.width / 2 - 20
|
||||
}
|
||||
|
||||
footer: Item {
|
||||
width: parent.width
|
||||
height: addBtn.height
|
||||
visible: editable
|
||||
|
||||
MessageDialog {
|
||||
id: changeError
|
||||
title: qsTr("Changing settings failed")
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
id: addBtn
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Style.current.padding
|
||||
//% "Add"
|
||||
text: qsTrId("add")
|
||||
|
||||
enabled: validationError === "" && addressInput.text !== "" && nameInput.text !== "" && symbolInput.text !== "" && decimalsInput.text !== ""
|
||||
|
||||
onClicked : {
|
||||
// TODO(alaibe): replace the placeholder 0 with the value of the chain selector
|
||||
const error = RootStore.addCustomToken(0, addressInput.text, nameInput.text, symbolInput.text, decimalsInput.text);
|
||||
|
||||
if (error) {
|
||||
Global.playErrorSound();
|
||||
changeError.text = error;
|
||||
changeError.open();
|
||||
return;
|
||||
}
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
|
||||
import utils 1.0
|
||||
|
||||
import StatusQ.Controls 0.1
|
||||
|
||||
import shared.popups 1.0
|
||||
import "../panels"
|
||||
import "../stores"
|
||||
|
||||
// TODO: replace with StatusModal
|
||||
ModalPopup {
|
||||
id: popup
|
||||
//% "Manage Assets"
|
||||
title: qsTrId("manage-assets")
|
||||
|
||||
TokenSettingsModalContent {
|
||||
id: settingsModalContent
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: parent.top
|
||||
anchors.leftMargin: Style.current.padding
|
||||
anchors.rightMargin: Style.current.padding
|
||||
defaultTokenList: RootStore.defaultTokenList
|
||||
customTokenList: RootStore.customTokenList
|
||||
|
||||
onToggleVisibleClicked: {
|
||||
RootStore.toggleVisible(chainId, symbol)
|
||||
}
|
||||
onRemoveCustomTokenTriggered: {
|
||||
RootStore.removeCustomToken(chainId, address)
|
||||
}
|
||||
onShowTokenDetailsTriggered: {
|
||||
addShowTokenModal.openWithData(chainId, address, name, symbol, decimals);
|
||||
}
|
||||
|
||||
AddShowTokenModal{
|
||||
id: addShowTokenModal
|
||||
}
|
||||
}
|
||||
|
||||
footer: StatusButton {
|
||||
anchors.right: parent.right
|
||||
//% "Add custom token"
|
||||
text: qsTrId("add-custom-token")
|
||||
anchors.top: parent.top
|
||||
onClicked: {
|
||||
addShowTokenModal.openEditable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -20,8 +20,6 @@ QtObject {
|
|||
property string mnemonicBackedUp: walletSection.isMnemonicBackedUp
|
||||
|
||||
property var walletTokensModule: walletSectionAllTokens
|
||||
property var defaultTokenList: walletSectionAllTokens.default
|
||||
property var customTokenList: walletSectionAllTokens.custom
|
||||
property var tokens: walletSectionAllTokens.all
|
||||
|
||||
property var assets: walletSectionAccountTokens.model
|
||||
|
@ -135,18 +133,6 @@ QtObject {
|
|||
walletSection.updateCurrency(newCurrency)
|
||||
}
|
||||
|
||||
function addCustomToken(chainId, address, name, symbol, decimals) {
|
||||
return walletSectionAllTokens.addCustomToken(chainId, address, name, symbol, decimals)
|
||||
}
|
||||
|
||||
function toggleVisible(chainId, symbol) {
|
||||
walletSectionAllTokens.toggleVisible(chainId, symbol)
|
||||
}
|
||||
|
||||
function removeCustomToken(chainId, address) {
|
||||
walletSectionAllTokens.removeCustomToken(chainId, address)
|
||||
}
|
||||
|
||||
function getQrCode(address) {
|
||||
return globalUtils.qrCode(address)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue