status-desktop/ui/app/AppLayouts/Wallet/panels/CollectiblesContent.qml

115 lines
3.8 KiB
QML
Raw Permalink Normal View History

2020-08-18 20:11:36 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import QtQml.Models 2.13
import StatusQ.Core 0.1
import StatusQ.Controls 0.1
import utils 1.0
import shared.panels 1.0
StatusScrollView {
id: collectiblesContent
2020-08-18 20:11:36 +00:00
readonly property int imageSize: 164
property var collectiblesModal
property string buttonText: "View in Cryptokitties"
property var getLink: function () {}
property var collectibles: []
2020-08-18 20:11:36 +00:00
signal reloadCollectibles(string collectibleType)
height: visible ? contentLoader.item.height : 0
2020-08-18 20:11:36 +00:00
width: parent.width
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
contentWidth: availableWidth
2020-08-18 20:11:36 +00:00
Loader {
id: contentLoader
active: true
width: collectiblesContent.availableWidth
height: collectiblesContent.imageSize
sourceComponent: !!error ? errorComponent : collectiblesContentComponent
}
Component {
id: errorComponent
2020-08-18 20:11:36 +00:00
Item {
width: parent.width
height: collectiblesContent.imageSize
2020-08-18 20:11:36 +00:00
Item {
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
height: childrenRect.height
width: somethingWentWrongText.width
2020-08-18 20:11:36 +00:00
StyledText {
id: somethingWentWrongText
text: qsTr("Something went wrong")
anchors.horizontalCenter: parent.horizontalCenter
color: Style.current.secondaryText
font.pixelSize: 13
2020-08-18 20:11:36 +00:00
}
StatusButton {
text: qsTr("Reload")
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: somethingWentWrongText.bottom
anchors.topMargin: Style.current.halfPadding
onClicked: {
reloadCollectibles(collectibleType);
}
}
}
}
}
Component {
id: collectiblesContentComponent
Row {
id: contentRow
bottomPadding: Style.current.padding
spacing: Style.current.padding
Repeater {
model: collectibles
2020-08-27 14:41:50 +00:00
Item {
width: collectibleImage.width
height: collectibleImage.height
2020-08-27 14:41:50 +00:00
clip: true
RoundedImage {
id: collectibleImage
width: collectiblesContent.imageSize
height: collectiblesContent.imageSize
border.width: 1
border.color: Style.current.border
radius: 16
source: modelData.image
fillMode: Image.PreserveAspectCrop
2020-08-27 14:41:50 +00:00
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
collectiblesModal.openModal({
name: modelData.name,
id: modelData.id,
description: modelData.description,
buttonText: collectiblesContent.buttonText,
link: collectiblesContent.getLink(modelData.id, modelData.externalUrl),
image: modelData.image
})
}
}
}
2020-08-18 20:11:36 +00:00
}
}
}
}