2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
2021-10-21 08:22:05 +00:00
|
|
|
import QtQuick.Controls 2.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
2023-01-20 00:44:35 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-03-06 16:46:32 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2023-01-31 10:49:07 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
2023-01-31 10:49:07 +00:00
|
|
|
import utils 1.0
|
2021-10-21 08:22:05 +00:00
|
|
|
|
|
|
|
import "collectibles"
|
|
|
|
|
2020-05-28 14:54:42 +00:00
|
|
|
Item {
|
2020-08-18 18:46:11 +00:00
|
|
|
id: root
|
2023-01-20 00:44:35 +00:00
|
|
|
property var collectiblesModel
|
2021-10-21 08:22:05 +00:00
|
|
|
width: parent.width
|
2023-01-20 00:44:35 +00:00
|
|
|
|
2023-09-11 10:20:36 +00:00
|
|
|
signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid)
|
2023-01-20 00:44:35 +00:00
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
Loader {
|
|
|
|
id: contentLoader
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
2020-07-30 20:46:25 +00:00
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
sourceComponent: {
|
2023-07-17 23:56:40 +00:00
|
|
|
/* TODO: Issue #11635
|
|
|
|
if (!root.collectiblesModel.hasMore && root.collectiblesModel.count === 0)
|
2021-10-21 08:22:05 +00:00
|
|
|
return empty;
|
2023-07-17 23:56:40 +00:00
|
|
|
*/
|
2021-10-21 08:22:05 +00:00
|
|
|
return loaded;
|
|
|
|
}
|
2020-08-19 15:58:25 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
Component {
|
|
|
|
id: empty
|
|
|
|
Item {
|
|
|
|
StyledText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
text: qsTr("Collectibles will appear here")
|
|
|
|
font.pixelSize: 15
|
2020-08-20 21:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 18:46:11 +00:00
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
Component {
|
|
|
|
id: loaded
|
2023-01-20 00:44:35 +00:00
|
|
|
StatusGridView {
|
|
|
|
id: gridView
|
|
|
|
anchors.fill: parent
|
2023-03-06 16:46:32 +00:00
|
|
|
model: root.collectiblesModel
|
2023-01-20 00:44:35 +00:00
|
|
|
cellHeight: 229
|
|
|
|
cellWidth: 176
|
2023-01-31 10:49:07 +00:00
|
|
|
delegate: CollectibleView {
|
2023-01-20 00:44:35 +00:00
|
|
|
height: gridView.cellHeight
|
|
|
|
width: gridView.cellWidth
|
2023-03-09 16:40:34 +00:00
|
|
|
title: model.name ? model.name : "..."
|
2023-08-03 16:05:04 +00:00
|
|
|
subTitle: model.collectionName ?? ""
|
|
|
|
mediaUrl: model.mediaUrl ?? ""
|
|
|
|
mediaType: model.mediaType ?? ""
|
|
|
|
fallbackImageUrl: model.imageUrl ?? ""
|
2023-03-09 16:40:34 +00:00
|
|
|
backgroundColor: model.backgroundColor ? model.backgroundColor : "transparent"
|
2023-08-03 16:05:04 +00:00
|
|
|
isLoading: !!model.isLoading
|
2023-09-20 13:01:37 +00:00
|
|
|
privilegesLevel: model.communityPrivilegesLevel ?? Constants.TokenPrivilegesLevel.Community
|
|
|
|
ornamentColor: model.communityColor ?? "transparent"
|
2023-09-27 14:03:49 +00:00
|
|
|
communityId: model.communityId
|
2023-03-09 16:40:34 +00:00
|
|
|
|
2023-09-11 10:20:36 +00:00
|
|
|
onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.uid)
|
2020-08-19 15:58:25 +00:00
|
|
|
}
|
2023-03-06 16:46:32 +00:00
|
|
|
|
|
|
|
ScrollBar.vertical: StatusScrollBar {}
|
2023-08-03 16:05:04 +00:00
|
|
|
|
|
|
|
// For some reason fetchMore is not working properly.
|
|
|
|
// Adding some logic here as a workaround.
|
|
|
|
visibleArea.onYPositionChanged: checkLoadMore()
|
|
|
|
visibleArea.onHeightRatioChanged: checkLoadMore()
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: gridView
|
|
|
|
function onVisibleChanged() {
|
|
|
|
checkLoadMore()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.collectiblesModel
|
|
|
|
function onHasMoreChanged() {
|
|
|
|
checkLoadMore()
|
|
|
|
}
|
|
|
|
function onIsFetchingChanged() {
|
|
|
|
checkLoadMore()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkLoadMore() {
|
|
|
|
// If there is no more items to load or we're already fetching, return
|
|
|
|
if (!gridView.visible || !root.collectiblesModel.hasMore || root.collectiblesModel.isFetching)
|
|
|
|
return
|
|
|
|
// Only trigger if close to the bottom of the list
|
|
|
|
if (visibleArea.yPosition + visibleArea.heightRatio > 0.9)
|
|
|
|
root.collectiblesModel.loadMore()
|
|
|
|
}
|
2020-08-18 18:46:11 +00:00
|
|
|
}
|
2020-07-28 18:19:46 +00:00
|
|
|
}
|
2020-05-28 14:54:42 +00:00
|
|
|
}
|