Fix roomList height with sections

This commit is contained in:
miruka 2019-04-21 11:39:29 -04:00
parent 9602608b87
commit 94d6bc0e52
2 changed files with 13 additions and 4 deletions

View File

@ -3,7 +3,6 @@ import "../base" as Base
Base.HLabel { Base.HLabel {
width: roomList.width width: roomList.width
height: text.height
// topPadding is provided by the roomList spacing // topPadding is provided by the roomList spacing
bottomPadding: roomList.spacing bottomPadding: roomList.spacing

View File

@ -7,11 +7,21 @@ ListView {
property var forUserId: null property var forUserId: null
property int childrenHeight: 36 property int childrenHeight: 36
property int sectionHeight: 16 + spacing
property int contentHeight: 0 property int contentHeight: 0
onCountChanged: { onCountChanged: {
contentHeight = childrenHeight * model.count + var sections = []
spacing * (model.count - 1)
for (var i = 0; i < model.count; i++) {
var categ = model.get(i).category
if (sections.indexOf(categ) == -1) { sections.push(categ) }
}
contentHeight =
childrenHeight * model.count +
spacing * Math.max(0, (model.count - 1)) +
sectionHeight * sections.length
} }
id: roomList id: roomList
@ -20,5 +30,5 @@ ListView {
delegate: RoomDelegate {} delegate: RoomDelegate {}
section.property: "category" section.property: "category"
section.delegate: RoomCategoryDelegate {} section.delegate: RoomCategoryDelegate { height: sectionHeight }
} }