2021-10-21 08:22:05 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-01-04 12:55:26 +00:00
|
|
|
import shared.panels 1.0
|
2021-10-21 08:22:05 +00:00
|
|
|
|
|
|
|
import "../../stores"
|
2022-08-08 21:12:12 +00:00
|
|
|
import utils 1.0
|
2021-10-21 08:22:05 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
2022-12-16 12:05:19 +00:00
|
|
|
|
|
|
|
property string collectionImageUrl: ""
|
|
|
|
property bool collectiblesLoaded: false
|
|
|
|
property var collectiblesModel
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
width: parent.width
|
|
|
|
height: contentLoader.height
|
|
|
|
|
2022-12-16 12:05:19 +00:00
|
|
|
signal collectibleClicked(int collectibleId)
|
2021-10-21 08:22:05 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: contentLoader
|
|
|
|
width: parent.width
|
|
|
|
anchors.top: parent.top
|
2021-11-02 12:57:52 +00:00
|
|
|
anchors.topMargin: 16
|
2021-10-21 08:22:05 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2022-01-04 12:55:26 +00:00
|
|
|
sourceComponent: {
|
|
|
|
if (!root.collectiblesLoaded) {
|
|
|
|
return loading
|
2022-12-16 12:05:19 +00:00
|
|
|
} else if (root.collectiblesModel.count === 0) {
|
2022-01-04 12:55:26 +00:00
|
|
|
return empty
|
|
|
|
}
|
|
|
|
return loaded
|
|
|
|
}
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loading
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: loadingIndicator
|
|
|
|
height: 164
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
width: 20
|
|
|
|
height: 20
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-04 12:55:26 +00:00
|
|
|
Component {
|
|
|
|
id: empty
|
2022-02-09 09:43:23 +00:00
|
|
|
|
2022-01-04 12:55:26 +00:00
|
|
|
Item {
|
|
|
|
id: emptyContainer
|
|
|
|
height: 164
|
|
|
|
StyledText {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
text: qsTr("No collectibles available")
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
Component {
|
|
|
|
id: loaded
|
|
|
|
|
|
|
|
Flow {
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
bottomPadding: 16
|
|
|
|
spacing: 24
|
|
|
|
|
2022-11-22 19:31:07 +00:00
|
|
|
Component {
|
|
|
|
id: collectibleDelegate
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
StatusRoundedImage {
|
|
|
|
id: image
|
|
|
|
width: 146
|
|
|
|
height: 146
|
|
|
|
radius: 16
|
|
|
|
image.source: model.imageUrl
|
|
|
|
border.color: Theme.palette.baseColor2
|
|
|
|
border.width: 1
|
|
|
|
showLoadingIndicator: true
|
|
|
|
color: model.backgroundColor
|
2022-07-28 20:56:44 +00:00
|
|
|
Rectangle {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: image.width
|
|
|
|
height: image.height
|
|
|
|
radius: image.radius
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.primaryColor1
|
|
|
|
color: Theme.palette.indirectColor3
|
|
|
|
visible: mouse.containsMouse
|
|
|
|
}
|
2021-10-21 08:22:05 +00:00
|
|
|
MouseArea {
|
2022-07-28 20:56:44 +00:00
|
|
|
id: mouse
|
2021-10-21 08:22:05 +00:00
|
|
|
anchors.fill: parent
|
2022-07-28 20:56:44 +00:00
|
|
|
hoverEnabled: true
|
2021-10-21 08:22:05 +00:00
|
|
|
onClicked: {
|
2022-12-16 12:05:19 +00:00
|
|
|
root.collectibleClicked(model.id);
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-22 19:31:07 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
objectName: "collectiblesRepeater"
|
2022-12-16 12:05:19 +00:00
|
|
|
model: root.collectiblesModel
|
2022-11-22 19:31:07 +00:00
|
|
|
delegate: collectibleDelegate
|
|
|
|
}
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|