## Summary: Add a spinning loading indicator while waiting to get messages from the phone
## Test Plan - Open SMS conversation - See nice spinner
This commit is contained in:
parent
c17972881b
commit
8d939e130f
1 changed files with 30 additions and 15 deletions
|
@ -82,6 +82,33 @@ Kirigami.ScrollablePage
|
||||||
spacing: Kirigami.Units.largeSpacing
|
spacing: Kirigami.Units.largeSpacing
|
||||||
highlightMoveDuration: 0
|
highlightMoveDuration: 0
|
||||||
|
|
||||||
|
BusyIndicator {
|
||||||
|
running: !isInitalized
|
||||||
|
}
|
||||||
|
|
||||||
|
onContentHeightChanged: {
|
||||||
|
if (viewport.contentHeight <= 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isInitalized) {
|
||||||
|
// If we aren't initalized, we need to request enough messages to fill the view
|
||||||
|
// In order to do that, request one more message until we have enough
|
||||||
|
if (viewport.contentHeight < viewport.height) {
|
||||||
|
console.debug("Requesting another message to fill the screen")
|
||||||
|
conversationModel.requestMoreMessages(1)
|
||||||
|
} else {
|
||||||
|
// Finish intializing: Scroll to the bottom of the view
|
||||||
|
|
||||||
|
// View the most-recent message
|
||||||
|
viewport.forceLayout()
|
||||||
|
Qt.callLater(viewport.positionViewAtEnd)
|
||||||
|
isInitalized = true
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delegate: ChatMessage {
|
delegate: ChatMessage {
|
||||||
senderName: model.sender
|
senderName: model.sender
|
||||||
messageBody: model.display
|
messageBody: model.display
|
||||||
|
@ -90,22 +117,10 @@ Kirigami.ScrollablePage
|
||||||
|
|
||||||
ListView.onAdd: {
|
ListView.onAdd: {
|
||||||
if (!isInitalized) {
|
if (!isInitalized) {
|
||||||
// If we aren't initalized, we need to request enough messages to fill the view
|
|
||||||
// In order to do that, request one more message until we have enough
|
|
||||||
viewport.forceLayout()
|
|
||||||
|
|
||||||
if (viewport.contentHeight < viewport.height) {
|
|
||||||
console.debug("Requesting another message to fill the screen")
|
|
||||||
conversationModel.requestMoreMessages(1)
|
|
||||||
} else {
|
|
||||||
// Finish intializing: Scroll to the bottom of the view
|
|
||||||
viewport.currentIndex = 0
|
|
||||||
isInitalized = true
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == viewport.count - 1)
|
if (index == viewport.count - 1) {
|
||||||
// This message is being inserted at the newest position
|
// This message is being inserted at the newest position
|
||||||
// We want to scroll to show it if the user is "almost" looking at it
|
// We want to scroll to show it if the user is "almost" looking at it
|
||||||
|
|
||||||
|
@ -124,6 +139,7 @@ Kirigami.ScrollablePage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMovementEnded: {
|
onMovementEnded: {
|
||||||
if (!isInitalized) {
|
if (!isInitalized) {
|
||||||
|
@ -131,7 +147,6 @@ Kirigami.ScrollablePage
|
||||||
}
|
}
|
||||||
// Unset the highlightRangeMode if it was set previously
|
// Unset the highlightRangeMode if it was set previously
|
||||||
highlightRangeMode = ListView.ApplyRange
|
highlightRangeMode = ListView.ApplyRange
|
||||||
highlightMoveDuration: -1 // "Re-enable" the highlight animation
|
|
||||||
|
|
||||||
// If we have scrolled to the last message currently in the view, request some more
|
// If we have scrolled to the last message currently in the view, request some more
|
||||||
if (atYBeginning) {
|
if (atYBeginning) {
|
||||||
|
@ -142,7 +157,7 @@ Kirigami.ScrollablePage
|
||||||
preferredHighlightEnd = preferredHighlightBegin + currentItem.height
|
preferredHighlightEnd = preferredHighlightBegin + currentItem.height
|
||||||
highlightRangeMode = ListView.StrictlyEnforceRange
|
highlightRangeMode = ListView.StrictlyEnforceRange
|
||||||
|
|
||||||
highlightMoveDuration = 1 // This is not ideal: I would like to disable the highlight animation altogether
|
highlightMoveDuration = 0
|
||||||
|
|
||||||
// Get more messages
|
// Get more messages
|
||||||
conversationModel.requestMoreMessages()
|
conversationModel.requestMoreMessages()
|
||||||
|
|
Loading…
Reference in a new issue