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
import utils 1.0
import AppLayouts . Wallet . views . collectibles 1.0
StatusScrollView {
id: root
property int viewWidth: 560 // by design
property var model
2023-03-31 12:52:51 +00:00
signal itemClicked ( int index ,
int chainId ,
string chainName ,
string accountName ,
string accountAddress )
2023-03-10 15:55:50 +00:00
QtObject {
id: d
2023-05-15 12:49:26 +00:00
function getSubtitle ( deployState , remainingTokens , supply ) {
2023-05-16 14:50:43 +00:00
if ( deployState === Constants . BackendProcessState . Failed ) {
2023-05-17 10:00:52 +00:00
return qsTr ( "Minting failed" )
2023-03-10 15:55:50 +00:00
}
2023-05-16 14:50:43 +00:00
if ( deployState === Constants . BackendProcessState . 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-15 12:49:26 +00:00
return qsTr ( "%1 / %2 remaining" ) . arg ( remainingTokens ) . arg ( supply )
2023-03-10 15:55:50 +00:00
}
}
contentWidth: mainLayout . width
contentHeight: mainLayout . height
padding: 0
ColumnLayout {
id: mainLayout
width: root . viewWidth
spacing: Style . current . padding
StatusBaseText {
text: qsTr ( "Collectibles" )
font.pixelSize: Theme . primaryTextFontSize
color: Theme . palette . baseColor1
}
StatusGridView {
id: gridView
Layout.fillWidth: true
Layout.preferredHeight: 500 // TODO
model: root . model
cellHeight: 229
cellWidth: 176
delegate: CollectibleView {
height: gridView . cellHeight
width: gridView . cellWidth
title: model . name ? model.name : "..."
2023-05-15 12:49:26 +00:00
subTitle: d . getSubtitle ( model . deployState , model . remainingTokens , model . supply )
2023-05-17 10:00:52 +00:00
subTitleColor: ( model . deployState === Constants . BackendProcessState . Failed ) ? Theme.palette.dangerColor1 : Theme . palette . baseColor1
2023-04-03 15:38:05 +00:00
fallbackImageUrl: model . image ? model.image : ""
2023-03-10 15:55:50 +00:00
backgroundColor: model . backgroundColor ? model.backgroundColor : "transparent" // TODO BACKEND
2023-03-17 15:09:27 +00:00
isLoading: false
2023-03-10 15:55:50 +00:00
navigationIconVisible: true
2023-03-31 12:52:51 +00:00
onClicked: root . itemClicked ( model . index , model . chainId , model . chainName , model . accountName , model . address ) // TODO: Replace to model.key when role exists in backend
2023-03-10 15:55:50 +00:00
}
}
}
}