Squaby Demo
import QtQuick 2.0
import Felgo 4.0
Flickable {
id: levelList
contentWidth: grid.width
contentHeight: grid.height+offset.height
flickableDirection: Flickable.HorizontalFlick
interactive: grid.width > width
boundsBehavior: Flickable.StopAtBounds
property alias grid: grid
property variant levelMetaDataArray: levelScene.levelArrayFromState()
property alias levelColumn: grid
property Component levelItemDelegate: LevelItem {}
signal nextPageClicked
signal prevPageClicked
onLevelMetaDataArrayChanged: {
updateList()
}
function updateList() {
isLoading = true
displayLoadingDelay.start()
}
property bool isLoading: false
Timer {
id: displayLoadingDelay
interval: 50
onTriggered: {
levelListRepeater.model = null
if(levelMetaDataArray) {
isLoading = true
displayLoadingDelayReloading.start()
} else {
offIntervall.start()
}
}
}
Timer {
id: displayLoadingDelayReloading
interval: 50
onTriggered: {
levelListRepeater.model = levelMetaDataArray
}
}
function nextPage() {
if(page>=pageCount) return;
page++
nextPageClicked()
}
function prevPage() {
if(page<=1) return;
page--
prevPageClicked()
}
property int pageSize: -1
property int page: 1
property int pageCount: 1
Grid {
id: grid
rows: 2
spacing: 6
Repeater {
id: levelListRepeater
delegate: levelItemDelegate
onModelChanged: {
console.debug("LevelList: listModel changed to", model, ", stringified:", JSON.stringify(model))
offIntervall.start()
}
}
}
Timer {
id: offIntervall
interval: 1000
onTriggered: {
isLoading = false
}
}
Item {
id: offset
width: parent.width