2023-10-25 10:40:10 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import shared.controls 1.0
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import AppLayouts.Profile.popups 1.0
|
|
|
|
|
|
|
|
StatusListView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property var sourcesOfTokensModel // Expected roles: key, name, updatedAt, source, version, tokensCount, image
|
|
|
|
required property var tokensListModel // Expected roles: name, symbol, image, chainName, explorerUrl
|
|
|
|
|
|
|
|
signal itemClicked(string key)
|
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
implicitHeight: contentHeight
|
2023-10-25 10:40:10 +00:00
|
|
|
model: root.sourcesOfTokensModel
|
|
|
|
spacing: 8
|
|
|
|
delegate: StatusListItem {
|
|
|
|
height: 76
|
2023-11-17 14:08:43 +00:00
|
|
|
width: ListView.view.width
|
2023-10-25 10:40:10 +00:00
|
|
|
title: model.name
|
2024-01-03 11:04:53 +00:00
|
|
|
sensor.enabled: false
|
2024-01-22 16:29:05 +00:00
|
|
|
//TODO will be re-implemented post-MVP
|
|
|
|
// subTitle: qsTr("%n token(s) · Last updated %1 @%2",
|
|
|
|
// "",
|
|
|
|
// model.tokensCount).arg(LocaleUtils.formatDate(model.updatedAt * 1000)).arg(LocaleUtils.formatTime(model.updatedAt, Locale.ShortFormat))
|
2024-10-15 19:26:12 +00:00
|
|
|
statusListItemSubTitle.font.pixelSize: Theme.additionalTextSize
|
2023-10-25 10:40:10 +00:00
|
|
|
asset.name: model.image
|
|
|
|
asset.isImage: true
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.baseColor5
|
2024-02-12 15:38:52 +00:00
|
|
|
highlighted: viewButton.hovered
|
2023-10-25 10:40:10 +00:00
|
|
|
components: [
|
2024-01-04 12:05:54 +00:00
|
|
|
StatusFlatButton {
|
2024-02-12 15:38:52 +00:00
|
|
|
id: viewButton
|
2023-10-25 10:40:10 +00:00
|
|
|
|
2024-02-12 15:38:52 +00:00
|
|
|
text: qsTr("View")
|
2023-10-25 10:40:10 +00:00
|
|
|
onClicked: keyFilter.value = model.key
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
width: parent.width
|
2024-02-12 15:38:52 +00:00
|
|
|
height: root.count > 0 ? shapeRect.implicitHeight + 20 : shapeRect.implicitHeight
|
2023-10-25 10:40:10 +00:00
|
|
|
|
|
|
|
ShapeRectangle {
|
|
|
|
id: shapeRect
|
|
|
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
width: parent.width - 4 // The rectangular path is rendered outside
|
|
|
|
|
|
|
|
icon: "add"
|
2024-01-04 12:05:54 +00:00
|
|
|
text: qsTr("Add a Token List (coming soon)")
|
2023-10-25 10:40:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Instantiator {
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: sourcesOfTokensModel
|
|
|
|
|
|
|
|
filters: ValueFilter {
|
|
|
|
id: keyFilter
|
|
|
|
|
|
|
|
roleName: "key"
|
|
|
|
value : ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: QtObject {
|
|
|
|
id: delegate
|
|
|
|
|
|
|
|
required property string name
|
|
|
|
required property string image
|
|
|
|
required property string source
|
|
|
|
required property int updatedAt
|
|
|
|
required property string version
|
|
|
|
required property int tokensCount
|
|
|
|
|
|
|
|
readonly property TokenListPopup popup: TokenListPopup {
|
|
|
|
parent: root
|
|
|
|
|
|
|
|
sourceImage: delegate.image
|
|
|
|
sourceUrl: delegate.source
|
|
|
|
sourceVersion: delegate.version
|
|
|
|
tokensCount: delegate.tokensCount
|
|
|
|
|
2024-07-19 15:41:40 +00:00
|
|
|
title: {
|
|
|
|
// Similar to Constants.getSupportedTokenSourceImage
|
|
|
|
if (delegate.name === Constants.supportedTokenSources.uniswap ||
|
|
|
|
delegate.name === Constants.supportedTokenSources.status)
|
|
|
|
return delegate.name;
|
|
|
|
|
|
|
|
return qsTr("%1 Token List").arg(delegate.name)
|
|
|
|
}
|
|
|
|
|
2023-10-25 10:40:10 +00:00
|
|
|
tokensListModel: SortFilterProxyModel {
|
|
|
|
sourceModel: root.tokensListModel
|
|
|
|
|
|
|
|
// Filter by source
|
2023-10-20 08:19:48 +00:00
|
|
|
filters: RegExpFilter {
|
|
|
|
roleName: "sources"
|
|
|
|
pattern: "\;" + keyFilter.value + "\;"
|
2023-10-25 10:40:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLinkClicked: Global.openLink(link)
|
|
|
|
onClosed: keyFilter.value = ""
|
|
|
|
Component.onCompleted: open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|