Commit 43a855cb authored by Karel Slaný's avatar Karel Slaný

Experimenting with scrolling on message list.

parent 0eda1e5a
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1 import QtQuick.Controls 2.2
import cz.nic.mobileDatovka.messages 1.0 import cz.nic.mobileDatovka.messages 1.0
ListView { ListView {
...@@ -152,6 +152,12 @@ ListView { ...@@ -152,6 +152,12 @@ ListView {
Accessible.role: Accessible.Button Accessible.role: Accessible.Button
Accessible.name: accessibleText() Accessible.name: accessibleText()
Accessible.onScrollDownAction: {
root.scrollDown()
}
Accessible.onScrollUpAction: {
root.scrollUp()
}
Accessible.onPressAction: { Accessible.onPressAction: {
handleClick() handleClick()
} }
...@@ -170,5 +176,34 @@ ListView { ...@@ -170,5 +176,34 @@ ListView {
color: datovkaPalette.dark color: datovkaPalette.dark
} }
} // Rectangle } // Rectangle
/*
* Scroll list down.
*/
function scrollDown() {
var numViewed = Math.ceil(root.height / (2 * listItemHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtTop = root.indexAt(1, 1 + root.contentY)
indexAtTop = (indexAtTop >= 0) ? (indexAtTop + numViewed) : 0
root.positionViewAtIndex(indexAtTop, ListView.Beginning)
root.returnToBounds()
}
/*
* Scroll list up.
*/
function scrollUp() {
var numViewed = Math.ceil(root.height / (2 * listItemHeight))
if (numViewed < 1) {
numViewed = 1
}
var indexAtBottom = root.indexAt(1, root.height - 2 + root.contentY)
indexAtBottom = (indexAtBottom >= 0) ? (indexAtBottom - numViewed) : 0
root.positionViewAtIndex(indexAtBottom, ListView.End)
root.returnToBounds()
}
ScrollIndicator.vertical: ScrollIndicator {} ScrollIndicator.vertical: ScrollIndicator {}
} // ListView } // ListView
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment