2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2020-09-08 15:52:09 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2021-10-25 14:33:41 +00:00
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-10-14 11:48:03 +00:00
|
|
|
import "../../../../shared/popups"
|
2021-10-14 13:09:35 +00:00
|
|
|
import "../../../../shared/panels"
|
2021-10-14 12:18:07 +00:00
|
|
|
import "../../../../shared/controls"
|
2020-06-03 16:49:18 +00:00
|
|
|
|
|
|
|
Item {
|
2020-06-18 15:56:53 +00:00
|
|
|
id: modalBody
|
2020-06-03 16:49:18 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
property var defaultTokenList
|
|
|
|
property var customTokenList
|
|
|
|
property var hasAsset: function(symbol) {}
|
|
|
|
signal toggleAssetClicked(string symbol)
|
|
|
|
signal removeCustomTokenTriggered(string address)
|
|
|
|
|
2020-06-18 15:56:53 +00:00
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
customHeight: 36
|
|
|
|
fontPixelSize: 12
|
|
|
|
anchors.top: modalBody.top
|
2020-06-03 16:49:18 +00:00
|
|
|
}
|
|
|
|
|
2020-09-08 15:52:09 +00:00
|
|
|
Component {
|
|
|
|
id: tokenComponent
|
2021-01-12 14:30:01 +00:00
|
|
|
Rectangle {
|
2020-09-08 15:52:09 +00:00
|
|
|
id: tokenContainer
|
2021-01-12 14:30:01 +00:00
|
|
|
property bool hovered: false
|
|
|
|
width: modalBody.width
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
color: hovered ? Style.current.backgroundHover : "transparent"
|
2020-09-08 15:52:09 +00:00
|
|
|
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
|
2021-01-12 14:30:01 +00:00
|
|
|
radius: Style.current.radius
|
2020-09-08 15:52:09 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: assetInfoImage
|
|
|
|
width: 36
|
|
|
|
height: tokenContainer.isVisible !== "" ? 36 : 0
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.png("tokens/" + (hasIcon ? symbol : "DEFAULT-TOKEN@3x"))
|
2020-09-08 15:52:09 +00:00
|
|
|
anchors.left: parent.left
|
2021-01-12 14:30:01 +00:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-09-08 15:52:09 +00:00
|
|
|
}
|
|
|
|
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 || ""
|
2021-01-12 14:30:01 +00:00
|
|
|
anchors.top: assetSymbol.bottom
|
|
|
|
anchors.topMargin: 0
|
2020-09-08 15:52:09 +00:00
|
|
|
anchors.left: assetInfoImage.right
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
2021-02-25 14:35:25 +00:00
|
|
|
color: Style.current.secondaryText
|
2020-09-08 15:52:09 +00:00
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
2020-11-27 19:32:49 +00:00
|
|
|
StatusCheckBox {
|
2020-09-08 15:52:09 +00:00
|
|
|
id: assetCheck
|
2021-10-05 20:50:22 +00:00
|
|
|
checked:modalBody.hasAsset(symbol)
|
2021-01-12 14:30:01 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2021-10-05 20:50:22 +00:00
|
|
|
onClicked: toggleAssetClicked(symbol)
|
2021-01-12 14:30:01 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-09-08 15:52:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
2021-01-12 14:30:01 +00:00
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2020-09-08 15:52:09 +00:00
|
|
|
anchors.fill: parent
|
2021-01-12 14:30:01 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
onClicked: function (event) {
|
|
|
|
if (event.button === Qt.RightButton) {
|
|
|
|
return contextMenu.popup(assetSymbol.x - 100, assetSymbol.y + 25)
|
|
|
|
}
|
|
|
|
assetCheck.checked = !assetCheck.checked
|
2021-10-05 20:50:22 +00:00
|
|
|
toggleAssetClicked(symbol)
|
2021-01-12 14:30:01 +00:00
|
|
|
}
|
|
|
|
onEntered: {
|
|
|
|
tokenContainer.hovered = true
|
|
|
|
}
|
|
|
|
onExited: {
|
|
|
|
tokenContainer.hovered = false
|
|
|
|
}
|
2021-10-14 11:48:03 +00:00
|
|
|
// TODO: replace with StatusPopupMenu
|
2020-09-08 15:52:09 +00:00
|
|
|
PopupMenu {
|
|
|
|
id: contextMenu
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("make-admin")
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Token details"
|
|
|
|
text: qsTrId("token-details")
|
2020-11-02 18:18:13 +00:00
|
|
|
onTriggered: addCustomTokenModal.openWithData(address, name, symbol, decimals)
|
2020-09-08 15:52:09 +00:00
|
|
|
}
|
|
|
|
Action {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source: Style.svg("remove-from-group")
|
2020-09-08 15:52:09 +00:00
|
|
|
icon.color: Style.current.red
|
2020-10-30 19:22:54 +00:00
|
|
|
enabled: isCustom
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Remove token"
|
|
|
|
text: qsTrId("remove-token")
|
2021-10-05 20:50:22 +00:00
|
|
|
onTriggered: removeCustomTokenTriggered(address)
|
2020-09-08 15:52:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: sview
|
2020-07-15 19:38:03 +00:00
|
|
|
clip: true
|
2020-09-08 15:52:09 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
|
|
|
|
contentHeight: tokenList.height
|
|
|
|
|
2020-06-18 15:56:53 +00:00
|
|
|
anchors.top: searchBox.bottom
|
2020-07-15 19:38:03 +00:00
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-06-18 15:56:53 +00:00
|
|
|
anchors.left: parent.left
|
2020-06-03 16:49:18 +00:00
|
|
|
anchors.right: parent.right
|
2020-06-18 15:56:53 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2020-09-08 15:52:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: tokenList
|
|
|
|
height: childrenRect.height
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: customTokens
|
2021-01-12 14:30:01 +00:00
|
|
|
spacing: Style.current.halfPadding
|
2020-09-08 15:52:09 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-09-08 15:52:09 +00:00
|
|
|
id: customLbl
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Custom"
|
|
|
|
text: qsTrId("custom")
|
2020-09-08 15:52:09 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
height: 20
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
2020-09-08 16:40:09 +00:00
|
|
|
id: customTokensRepeater
|
2021-10-05 20:50:22 +00:00
|
|
|
model: modalBody.customTokenList
|
2020-09-08 15:52:09 +00:00
|
|
|
delegate: tokenComponent
|
|
|
|
anchors.top: customLbl.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2020-06-18 15:56:53 +00:00
|
|
|
}
|
2020-09-08 16:40:09 +00:00
|
|
|
|
|
|
|
Connections {
|
2021-10-05 20:50:22 +00:00
|
|
|
target: modalBody.customTokenList
|
2020-09-08 16:40:09 +00:00
|
|
|
onTokensLoaded: {
|
|
|
|
customLbl.visible = cnt > 0
|
|
|
|
}
|
|
|
|
}
|
2020-09-08 15:52:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
anchors.top: customTokens.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
|
|
|
id: defaultTokens
|
2021-01-12 14:30:01 +00:00
|
|
|
spacing: Style.current.halfPadding
|
2020-09-08 15:52:09 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-09-08 15:52:09 +00:00
|
|
|
id: defaultLbl
|
2020-09-14 12:12:47 +00:00
|
|
|
//% "Default"
|
|
|
|
text: qsTrId("default")
|
2020-09-08 15:52:09 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
height: 20
|
2020-06-18 16:38:35 +00:00
|
|
|
}
|
2020-09-08 15:52:09 +00:00
|
|
|
|
|
|
|
Repeater {
|
2021-10-05 20:50:22 +00:00
|
|
|
model: modalBody.defaultTokenList
|
2020-09-08 15:52:09 +00:00
|
|
|
delegate: tokenComponent
|
|
|
|
anchors.top: defaultLbl.bottom
|
|
|
|
anchors.topMargin: Style.current.smallPadding
|
2021-01-12 14:30:01 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-06-03 16:49:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|