2023-03-10 15:55:50 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2023-05-25 14:45:46 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2023-03-10 15:55:50 +00:00
|
|
|
import utils 1.0
|
2023-05-25 14:45:46 +00:00
|
|
|
import shared.controls 1.0
|
2023-03-10 15:55:50 +00:00
|
|
|
|
|
|
|
import AppLayouts.Wallet.views.collectibles 1.0
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property int viewWidth: 560 // by design
|
|
|
|
property var model
|
|
|
|
|
2023-05-26 15:00:51 +00:00
|
|
|
signal itemClicked(string contractUniqueKey,
|
2023-03-31 12:52:51 +00:00
|
|
|
int chainId,
|
|
|
|
string chainName,
|
|
|
|
string accountName,
|
|
|
|
string accountAddress)
|
2023-03-10 15:55:50 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2023-05-25 14:45:46 +00:00
|
|
|
readonly property int delegateAssetsHeight: 64
|
|
|
|
|
|
|
|
function getSubtitle(deployState, remainingTokens, supply, isCollectible) {
|
2023-05-05 11:03:59 +00:00
|
|
|
if(deployState === Constants.ContractTransactionStatus.Failed) {
|
2023-05-17 10:00:52 +00:00
|
|
|
return qsTr("Minting failed")
|
2023-03-10 15:55:50 +00:00
|
|
|
}
|
|
|
|
|
2023-05-05 11:03:59 +00:00
|
|
|
if(deployState === Constants.ContractTransactionStatus.InProgress) {
|
2023-03-10 15:55:50 +00:00
|
|
|
return qsTr("Minting...")
|
|
|
|
}
|
2023-05-11 17:14:11 +00:00
|
|
|
|
|
|
|
// TO REMOVE: Just added bc backend still doesn't have `availableTokens` property in model. Once it is added, the following 2 lines can be removed.
|
2023-05-15 12:49:26 +00:00
|
|
|
if(!remainingTokens)
|
|
|
|
remainingTokens = 0
|
2023-05-11 17:14:11 +00:00
|
|
|
if(supply === 0)
|
|
|
|
supply = "∞"
|
2023-05-25 14:45:46 +00:00
|
|
|
return isCollectible ? qsTr("%1 / %2 remaining").arg(remainingTokens).arg(supply) : ""
|
2023-03-10 15:55:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: mainLayout
|
|
|
|
|
|
|
|
width: root.viewWidth
|
2023-05-25 14:45:46 +00:00
|
|
|
spacing: Style.current.halfPadding
|
2023-03-10 15:55:50 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
2023-05-25 14:45:46 +00:00
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
|
|
|
|
text: qsTr("Assets")
|
|
|
|
font.pixelSize: Theme.primaryTextFontSize
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusListView {
|
|
|
|
id: assetsList
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
|
|
|
|
visible: count > 0
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.model
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "tokenType"
|
|
|
|
value: Constants.TokenType.ERC20
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delegate: StatusListItem {
|
|
|
|
height: 64
|
|
|
|
width: mainLayout.width
|
|
|
|
title: model.name
|
|
|
|
subTitle: model.symbol
|
|
|
|
asset.name: model.image ? model.image : ""
|
|
|
|
asset.isImage: true
|
|
|
|
components: [
|
|
|
|
StatusBaseText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
text: d.getSubtitle(model.deployState, model.remainingTokens, model.supply, false)
|
|
|
|
color: (model.deployState === Constants.ContractTransactionStatus.Failed) ? Theme.palette.dangerColor1 : Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 13
|
|
|
|
},
|
|
|
|
StatusIcon {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
icon: "next"
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
]
|
2023-05-26 15:00:51 +00:00
|
|
|
onClicked: root.itemClicked(model.contractUniqueKey, model.chainId, model.chainName, model.accountName, model.address)
|
2023-05-25 14:45:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Empty placeholder when no assets; dashed rounded rectangle
|
|
|
|
ShapeRectangle {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.preferredWidth: parent.width - 4 // The rectangular path is rendered outside
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
visible: assetsList.count === 0
|
|
|
|
text: qsTr("You currently have no minted assets")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.topMargin: Style.current.halfPadding
|
|
|
|
|
2023-03-10 15:55:50 +00:00
|
|
|
text: qsTr("Collectibles")
|
|
|
|
font.pixelSize: Theme.primaryTextFontSize
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusGridView {
|
2023-05-25 14:45:46 +00:00
|
|
|
id: collectiblesGrid
|
2023-03-10 15:55:50 +00:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-05-25 14:45:46 +00:00
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
|
|
|
|
visible: count > 0
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.model
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "tokenType"
|
|
|
|
value: Constants.TokenType.ERC721
|
|
|
|
}
|
|
|
|
}
|
2023-03-10 15:55:50 +00:00
|
|
|
cellHeight: 229
|
|
|
|
cellWidth: 176
|
2023-05-25 14:45:46 +00:00
|
|
|
leftMargin: 16
|
2023-03-10 15:55:50 +00:00
|
|
|
delegate: CollectibleView {
|
2023-05-25 14:45:46 +00:00
|
|
|
height: collectiblesGrid.cellHeight
|
|
|
|
width: collectiblesGrid.cellWidth
|
2023-03-10 15:55:50 +00:00
|
|
|
title: model.name ? model.name : "..."
|
2023-05-25 14:45:46 +00:00
|
|
|
subTitle: d.getSubtitle(model.deployState, model.remainingTokens, model.supply, true)
|
2023-05-05 11:03:59 +00:00
|
|
|
subTitleColor: (model.deployState === Constants.ContractTransactionStatus.Failed) ? Theme.palette.dangerColor1 : Theme.palette.baseColor1
|
2023-04-03 15:38:05 +00:00
|
|
|
fallbackImageUrl: model.image ? model.image : ""
|
2023-05-25 14:45:46 +00:00
|
|
|
backgroundColor: "transparent"
|
2023-03-17 15:09:27 +00:00
|
|
|
isLoading: false
|
2023-03-10 15:55:50 +00:00
|
|
|
navigationIconVisible: true
|
|
|
|
|
2023-05-26 15:00:51 +00:00
|
|
|
onClicked: root.itemClicked(model.contractUniqueKey, model.chainId, model.chainName, model.accountName, model.address)
|
2023-03-10 15:55:50 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-25 14:45:46 +00:00
|
|
|
|
|
|
|
// Empty placeholder when no collectibles; dashed rounded rectangle
|
|
|
|
ShapeRectangle {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.preferredWidth: parent.width - 4 // The rectangular path is rendered outside
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
visible: collectiblesGrid.count == 0
|
|
|
|
text: qsTr("You currently have no minted collectibles")
|
|
|
|
}
|
2023-03-10 15:55:50 +00:00
|
|
|
}
|
|
|
|
}
|