2022-03-02 14:24:39 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-03-02 14:24:39 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: modalBody
|
|
|
|
|
|
|
|
property var defaultTokenList
|
|
|
|
property var customTokenList
|
2022-04-04 12:11:39 +00:00
|
|
|
signal toggleVisibleClicked(int chainId, string address)
|
2022-03-02 14:24:39 +00:00
|
|
|
signal removeCustomTokenTriggered(int chainId, string address)
|
|
|
|
signal showTokenDetailsTriggered(int chainId, string address, string name, string symbol, string decimals)
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: tokenComponent
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
id: assetSymbol
|
|
|
|
title: symbol
|
|
|
|
subTitle: name || ""
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: Style.png("tokens/" + (hasIcon ? symbol : "DEFAULT-TOKEN@3x"))
|
|
|
|
asset.isImage: true
|
|
|
|
asset.height: 36
|
2022-03-02 14:24:39 +00:00
|
|
|
components: [StatusCheckBox {
|
|
|
|
id: assetCheck
|
|
|
|
checked: model.isVisible
|
2022-04-04 12:11:39 +00:00
|
|
|
onClicked: toggleVisibleClicked(chainId, address)
|
2022-03-02 14:24:39 +00:00
|
|
|
}]
|
|
|
|
visible: symbol && (searchBox.text == "" || name.toLowerCase().includes(searchBox.text.toLowerCase()) || symbol.toLowerCase().includes(searchBox.text.toLowerCase()))
|
|
|
|
MouseArea {
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: function (event) {
|
|
|
|
if (event.button === Qt.RightButton) {
|
|
|
|
return contextMenu.popup(mouseX, mouseY)
|
|
|
|
}
|
|
|
|
assetCheck.checked = !assetCheck.checked
|
2022-04-04 12:11:39 +00:00
|
|
|
toggleVisibleClicked(chainId, address)
|
2022-03-02 14:24:39 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 16:58:37 +00:00
|
|
|
StatusMenu {
|
2022-03-02 14:24:39 +00:00
|
|
|
id: contextMenu
|
|
|
|
Action {
|
2022-04-04 12:11:39 +00:00
|
|
|
icon.name: "admin"
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Token details")
|
2022-03-02 14:24:39 +00:00
|
|
|
onTriggered: {
|
|
|
|
modalBody.showTokenDetailsTriggered(chainId, address, name, symbol, decimals);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Action {
|
2022-04-04 12:11:39 +00:00
|
|
|
icon.name: "remove"
|
2022-03-02 14:24:39 +00:00
|
|
|
icon.color: Style.current.red
|
|
|
|
enabled: isCustom
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Remove token")
|
2022-03-02 14:24:39 +00:00
|
|
|
onTriggered: removeCustomTokenTriggered(chainId, address)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
2022-03-21 17:43:42 +00:00
|
|
|
input.font.pixelSize: 12
|
2022-03-02 14:24:39 +00:00
|
|
|
anchors.top: modalBody.top
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-03-21 17:43:42 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2022-03-02 14:24:39 +00:00
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-03-02 14:24:39 +00:00
|
|
|
id: sview
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
|
|
|
|
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
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Custom")
|
2022-03-02 14:24:39 +00:00
|
|
|
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
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Default")
|
2022-03-02 14:24:39 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|