2023-03-07 11:32:45 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.controls 1.0
|
|
|
|
|
|
|
|
Control {
|
|
|
|
id: root
|
|
|
|
|
2023-03-31 10:20:23 +00:00
|
|
|
// Expected roles: ensName, walletAddress, imageSource, amount, selfDestructAmount and selfDestruct
|
2023-03-07 11:32:45 +00:00
|
|
|
property var model
|
|
|
|
|
|
|
|
property string tokenName
|
2023-03-31 10:20:23 +00:00
|
|
|
property bool isSelectorMode: false
|
|
|
|
|
|
|
|
signal selfDestructChanged()
|
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int red2Color: 4
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: filteredModel
|
|
|
|
|
|
|
|
sourceModel: root.model
|
|
|
|
filters: ExpressionFilter {
|
|
|
|
enabled: searcher.enabled
|
|
|
|
expression: {
|
|
|
|
searcher.text
|
|
|
|
return model.ensName.toLowerCase().includes(searcher.text.toLowerCase()) ||
|
|
|
|
model.walletAddress.toLowerCase().includes(searcher.text.toLowerCase())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searcher
|
2023-03-31 10:20:23 +00:00
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
Layout.fillWidth: true
|
2023-03-31 10:20:23 +00:00
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
topPadding: 0
|
|
|
|
bottomPadding: 0
|
|
|
|
minimumHeight: 36 // by design
|
|
|
|
maximumHeight: minimumHeight
|
|
|
|
enabled: root.model.count > 0
|
|
|
|
placeholderText: enabled ? qsTr("Search") : qsTr("No placeholders to search")
|
|
|
|
}
|
|
|
|
|
2023-03-31 10:20:23 +00:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
2023-03-07 11:32:45 +00:00
|
|
|
|
2023-03-31 10:20:23 +00:00
|
|
|
visible: !root.preview
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
text: searcher.text.length > 0 ? qsTr("Search results") : qsTr("All %1 token holders").arg(root.tokenName)
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusListView {
|
2023-03-07 11:32:45 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
|
2023-03-31 10:20:23 +00:00
|
|
|
model: filteredModel
|
|
|
|
delegate: RowLayout {
|
2023-03-07 11:32:45 +00:00
|
|
|
width: ListView.view.width
|
2023-03-31 10:20:23 +00:00
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
StatusListItem {
|
|
|
|
readonly property bool unknownHolder: model.ensName === ""
|
|
|
|
readonly property string formattedTitle: unknownHolder ? "?" : model.ensName
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
leftPadding: 0
|
|
|
|
rightPadding: 0
|
|
|
|
sensor.enabled: false
|
|
|
|
title: formattedTitle
|
|
|
|
statusListItemTitle.visible: !unknownHolder
|
|
|
|
subTitle: model.walletAddress
|
|
|
|
asset.name: model.imageSource
|
|
|
|
asset.isImage: true
|
|
|
|
asset.isLetterIdenticon: unknownHolder
|
|
|
|
asset.color: Theme.palette.userCustomizationColors[d.red2Color]
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusComboBox {
|
|
|
|
id: combo
|
|
|
|
|
|
|
|
Layout.preferredWidth: 70
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
|
|
|
|
visible: root.isSelectorMode && amount > 1
|
|
|
|
control.spacing: Style.current.halfPadding / 2
|
|
|
|
model: amount
|
|
|
|
size: StatusComboBox.Size.Small
|
|
|
|
type: StatusComboBox.Type.Secondary
|
|
|
|
delegate: StatusItemDelegate {
|
|
|
|
width: combo.control.width
|
2023-04-20 13:29:14 +00:00
|
|
|
centerTextHorizontally: true
|
2023-03-31 10:20:23 +00:00
|
|
|
highlighted: combo.control.highlightedIndex === index
|
|
|
|
font: combo.control.font
|
|
|
|
text: Number(modelData) + 1
|
|
|
|
}
|
|
|
|
contentItem: StatusBaseText {
|
|
|
|
font: combo.control.font
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
elide: Text.ElideRight
|
|
|
|
text: Number(combo.control.displayText) + 1
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
control.onDisplayTextChanged: {
|
|
|
|
selfDestructAmount = combo.currentIndex + 1
|
|
|
|
root.selfDestructChanged()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusCheckBox {
|
|
|
|
id: checkBox
|
|
|
|
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
visible: root.isSelectorMode
|
|
|
|
checked: root.isSelectorMode ? selfDestruct : false
|
|
|
|
padding: 0
|
|
|
|
onCheckStateChanged: {
|
|
|
|
selfDestruct = checked
|
|
|
|
root.selfDestructChanged()
|
|
|
|
}
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|