mobile/dive-list: make sure filter input area is visible

Since apparently the header property of the ListView isn't reliably
making sure that our filter input line is visible, let's move the filter
header to be it's own visual element and manually manage the
relationship between that and the ListView.

The obvious idea was to anchor the ListView to the bottom of the
filterHeader, but that didn't work in my tests. So instead we are using
the topMargin to make sure that there is space to show the header.

Because this re-indents the whole filterHeader, 'git show -w' gives a
much better idea what this commit actually changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-03-29 12:18:24 -07:00
parent d12e86cb2b
commit ccb671685d

View file

@ -353,21 +353,21 @@ Kirigami.ScrollablePage {
visible: diveListView.visible && diveListView.count === 0 visible: diveListView.visible && diveListView.count === 0
} }
Component {
id: filterHeader
Rectangle { Rectangle {
id: filterRectangle id: filterHeader
visible: filterBar.height > 0 visible: filterBar.height > 0
implicitHeight: filterBar.implicitHeight implicitHeight: filterBar.implicitHeight
implicitWidth: filterBar.implicitWidth implicitWidth: filterBar.implicitWidth
height: filterBar.height height: filterBar.height
anchors.left: parent.left anchors {
anchors.right: parent.right top: parent.top
left: parent.left
right: parent.right
}
color: subsurfaceTheme.backgroundColor color: subsurfaceTheme.backgroundColor
enabled: rootItem.filterToggle enabled: rootItem.filterToggle
RowLayout { RowLayout {
id: filterBar id: filterBar
z: 5 //make sure it sits on top
states: [ states: [
State { State {
name: "isVisible" name: "isVisible"
@ -379,7 +379,6 @@ Kirigami.ScrollablePage {
when: !rootItem.filterToggle when: !rootItem.filterToggle
PropertyChanges { target: filterBar; height: 0 } PropertyChanges { target: filterBar; height: 0 }
} }
] ]
transitions: [ transitions: [
Transition { NumberAnimation { property: "height"; duration: 400; easing.type: Easing.InOutQuad }} Transition { NumberAnimation { property: "height"; duration: 400; easing.type: Easing.InOutQuad }}
@ -389,6 +388,7 @@ Kirigami.ScrollablePage {
anchors.leftMargin: Kirigami.Units.gridUnit / 2 anchors.leftMargin: Kirigami.Units.gridUnit / 2
anchors.rightMargin: Kirigami.Units.gridUnit / 2 anchors.rightMargin: Kirigami.Units.gridUnit / 2
TemplateComboBox { TemplateComboBox {
visible: filterBar.height === sitefilter.implicitHeight
id: sitefilterMode id: sitefilterMode
editable: false editable: false
model: ListModel { model: ListModel {
@ -405,7 +405,6 @@ Kirigami.ScrollablePage {
} }
Controls.TextField { Controls.TextField {
id: sitefilter id: sitefilter
z: 10
verticalAlignment: TextInput.AlignVCenter verticalAlignment: TextInput.AlignVCenter
Layout.fillWidth: true Layout.fillWidth: true
text: "" text: ""
@ -423,22 +422,18 @@ Kirigami.ScrollablePage {
} }
Controls.Label { Controls.Label {
id: numShown id: numShown
z: 10
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: diveModel.shown text: diveModel.shown
} }
} }
} }
}
ListView { ListView {
id: diveListView id: diveListView
topMargin: filterHeader.height
anchors.fill: parent anchors.fill: parent
model: diveListModel model: diveListModel
currentIndex: -1 currentIndex: -1
delegate: diveOrTripDelegate delegate: diveOrTripDelegate
header: filterHeader
headerPositioning: ListView.OverlayHeader
boundsBehavior: Flickable.DragOverBounds boundsBehavior: Flickable.DragOverBounds
maximumFlickVelocity: parent.height * 5 maximumFlickVelocity: parent.height * 5
bottomMargin: Kirigami.Units.iconSizes.medium + Kirigami.Units.gridUnit bottomMargin: Kirigami.Units.iconSizes.medium + Kirigami.Units.gridUnit