Commit 9309c6ab authored by Martin Straka's avatar Martin Straka Committed by Karel Slaný

Added scroll idicators and refactoring message detail page

parent 8dfb7aca
......@@ -23,7 +23,8 @@
import QtGraphicalEffects 1.0
import QtQuick 2.7
import QtQuick.Layouts 1.2
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.1
import cz.nic.mobileDatovka.messages 1.0
ListView {
......@@ -168,4 +169,5 @@ ListView {
color: datovkaPalette.mid
}
}
ScrollIndicator.vertical: ScrollIndicator {}
}
......@@ -422,6 +422,7 @@ Component {
}
}
}
ScrollIndicator.vertical: ScrollIndicator {}
}
}
}
......@@ -63,28 +63,21 @@ Component {
function fillContentFromDb() {
if (!fromLocalDb && (rawZfoContent != null)) {
/* This method also sets the attachment model. */
var msgInfo = files.zfoData(attachmentModel, rawZfoContent)
zfoId = msgInfo.idStr
msgAnnotation = msgInfo.annotation
msgDescrHtml = msgInfo.descrHtml
emailBody = msgInfo.emailBody
zfoType = msgInfo.type
if (zfoType == MsgInfo.TYPE_UNKNOWN) {
errorNotification.text = qsTr("File doesn't contain a valid message nor does it contain valid delivery information or the file is corrupt.")
errorNotification.visible = true
flickable.visible = false
}
attachmentLabel.visible = zfoType == MsgInfo.TYPE_MESSAGE
attachmentArea.visible = zfoType == MsgInfo.TYPE_MESSAGE
emptyList.visible = zfoType == MsgInfo.TYPE_MESSAGE
attachmentList.visible = zfoType == MsgInfo.TYPE_MESSAGE
console.log("Loaded page content from ZFO.")
rawZfoContent = null /* There is no need to remember this. */
} else if (fromLocalDb && (userName.length != 0) && (msgId.length != 0)) {
zfoId = msgId
......@@ -92,12 +85,8 @@ Component {
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
zfoType = MsgInfo.TYPE_MESSAGE
console.log("Loaded page content from database.")
}
emptyList.visible = (attachmentList.count == 0)
setTopButtonVisibility()
}
......@@ -238,30 +227,19 @@ Component {
}
}
}
}
Rectangle {
id: messageDetail
} // PageHeader
Flickable {
id: flickable
z: 0
anchors.top: headerBar.bottom
width: parent.width
anchors.right: parent.right
anchors.left: parent.left
contentHeight: flickContent.implicitHeight
height: (zfoType == MsgInfo.TYPE_MESSAGE) ? parent.height * 0.5 : parent.height - headerHeight
color: datovkaPalette.base
ListModel {
id: messageDetailModel
ListElement {
text: ""
}
}
ListView {
id: messageDetailList
Pane {
id: flickContent
anchors.fill: parent
anchors.margins: defaultMargin
clip: true
spacing: 0
opacity: 1
visible: true
interactive: true
model: messageDetailModel
delegate: Text {
Text {
id: messageDetailText
color: datovkaPalette.text
width: parent.width
......@@ -269,170 +247,194 @@ Component {
wrapMode: Text.WordWrap
text: msgDescrHtml
}
}
Text {
id: errorNotification
visible: false
color: datovkaPalette.text
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: ""
}
}
Item {
id: attachmentLabel
anchors.top: messageDetail.bottom
width: parent.width
height: textFontSizeInPixels * 2
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
textFormat: TextEdit.RichText
text: "<h3>" + qsTr("Attachments") + "</h3>"
font.bold: true
}
Rectangle {
id: attachmentLabelLine
anchors.bottom: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.mid
}
}
ListView {
id: attachmentList
anchors.top: attachmentLabel.bottom
} // Pane
ScrollIndicator.vertical: ScrollIndicator {}
} // Flickable
Rectangle {
id: attachmentArea
anchors.top: flickable.bottom
anchors.bottom: parent.bottom
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: attachmentModel
onCountChanged: {
emptyList.visible = (attachmentList.count == 0)
setTopButtonVisibility()
}
delegate: Rectangle {
id: attachmentItem
anchors.right: parent.right
anchors.left: parent.left
color: datovkaPalette.base
Item {
id: attachmentLabel
width: parent.width
height: headerHeight
color: datovkaPalette.base
Image {
id: imageAttachment
anchors.left: parent.left
height: textFontSizeInPixels * 2
Text {
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: rFileIcon
}
Item {
anchors.left: imageAttachment.right
anchors.left: parent.left
anchors.leftMargin: defaultMargin
height: parent.height
textFormat: TextEdit.RichText
text: "<h3>" + qsTr("Attachments") + "</h3>"
font.bold: true
}
Rectangle {
id: attachmentLabelLine
anchors.bottom: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.mid
}
}
ListView {
id: attachmentList
anchors.top: attachmentLabel.bottom
anchors.bottom: parent.bottom
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: attachmentModel
onCountChanged: {
emptyList.visible = (attachmentList.count == 0)
setTopButtonVisibility()
}
delegate: Rectangle {
id: attachmentItem
width: parent.width
Column {
height: headerHeight
color: datovkaPalette.base
Image {
id: imageAttachment
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
Text {
id: filenameid
anchors.left: parent.left
text: rFileName
color: datovkaPalette.text
font.bold: true
}
Text {
id: filesizeid
anchors.left: parent.left
text: rFileSize
color: datovkaPalette.mid
font.pointSize: textFontSizeSmall
renderType: Text.NativeRendering
sourceSize.height: imgHeight
source: rFileIcon
}
Item {
anchors.left: imageAttachment.right
anchors.leftMargin: defaultMargin
height: parent.height
width: parent.width
Column {
anchors.verticalCenter: parent.verticalCenter
Text {
id: filenameid
anchors.left: parent.left
text: rFileName
color: datovkaPalette.text
font.bold: true
}
Text {
id: filesizeid
anchors.left: parent.left
text: rFileSize
color: datovkaPalette.mid
font.pointSize: textFontSizeSmall
renderType: Text.NativeRendering
}
}
}
}
Rectangle {
id: next
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
height: parent.height
width: parent.width * 0.07
color: parent.color
Image {
id: nextImage
Rectangle {
id: next
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/next.svg"
}
ColorOverlay {
anchors.fill: nextImage
source: nextImage
color: datovkaPalette.text
height: parent.height
width: parent.width * 0.07
color: parent.color
Image {
id: nextImage
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/next.svg"
}
ColorOverlay {
anchors.fill: nextImage
source: nextImage
color: datovkaPalette.text
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
locker.ignoreNextSuspension()
if (files.isZfoFile(rFileName)) {
console.log("Attachment is ZFO: " + rFileName)
var fileContent = null
if (!fromLocalDb) {
fileContent = files.base64ToRaw(rFileContent)
} else {
fileContent = files.getAttachmentDb(userName, zfoId, rFileId)
}
pageView.push(pageMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"fromLocalDb": false,
"rawZfoContent": fileContent
}, StackView.Immediate)
} else {
if (!fromLocalDb) {
files.openAttachment(rFileName, rFileContent)
MouseArea {
anchors.fill: parent
onClicked: {
locker.ignoreNextSuspension()
if (files.isZfoFile(rFileName)) {
console.log("Attachment is ZFO: " + rFileName)
var fileContent = null
if (!fromLocalDb) {
fileContent = files.base64ToRaw(rFileContent)
} else {
fileContent = files.getAttachmentDb(userName, zfoId, rFileId)
}
pageView.push(pageMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"fromLocalDb": false,
"rawZfoContent": fileContent
}, StackView.Immediate)
} else {
files.openAttachmentFromDb(userName, zfoId, rFileId)
if (!fromLocalDb) {
files.openAttachment(rFileName, rFileContent)
} else {
files.openAttachmentFromDb(userName, zfoId, rFileId)
}
}
}
}
Rectangle {
anchors.top: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.mid
}
}
Rectangle {
anchors.top: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.mid
property bool downloadStart: false
//onContentYChanged: // whenever position changes
//onVerticalVelocityChanged:
//onFlickEnded: // similar to onDragEnded but shorter distance
onMovementEnded: {
if (downloadStart) {
downloadStart = false
if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
}
}
}
}
property bool downloadStart: false
//onContentYChanged: // whenever position changes
//onVerticalVelocityChanged:
//onFlickEnded: // similar to onDragEnded but shorter distance
onMovementEnded: {
if (downloadStart) {
downloadStart = false
if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
onDragEnded: {
downloadStart = contentY < -120
}
ScrollIndicator.vertical: ScrollIndicator {}
} // Listview
Text {
id: emptyList
visible: false
color: datovkaPalette.text
anchors.centerIn: parent
width: parent.width
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
text: fromLocalDb ? qsTr("Attachments have not been downloaded yet.\nClick the icon or this text for their download.") : qsTr("No attachments present.")
MouseArea {
anchors.fill: parent
onClicked: {
if (fromLocalDb) {
isds.downloadMessage(messageModel, userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
emptyList.visible = (attachmentList.count == 0)
setTopButtonVisibility()
}
}
}
}
onDragEnded: {
downloadStart = contentY < -120
}
}
} // Text
} // Rectangle
Text {
id: emptyList
id: errorNotification
visible: false
color: datovkaPalette.text
anchors.centerIn: attachmentList
text: fromLocalDb ? qsTr("Attachments have not been downloaded yet.") : qsTr("No attachments present.")
}
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: ""
} // Text
}
}
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