Rearrange scroll bar.

Fixes #3.
square-messages
Black Hat 2018-08-05 00:15:58 +08:00
parent d1d7139f4b
commit 0e34fce4a2
1 changed files with 68 additions and 54 deletions

View File

@ -74,75 +74,89 @@ Item {
}
}
ListView {
id: messageListView
z: -10
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: 16
Layout.rightMargin: 16
displayMarginBeginning: 40
displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop
spacing: 8
boundsBehavior: Flickable.DragOverBounds
z: -10
model: MessageEventModel{
id: messageEventModel
room: currentRoom
}
spacing: 0
delegate: MessageDelegate {}
ListView {
id: messageListView
section.property: "section"
section.criteria: ViewSection.FullString
section.delegate: RowLayout {
width: parent.width * 0.6
anchors.right: parent.right
Layout.fillWidth: true
Layout.fillHeight: true
displayMarginBeginning: 40
displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop
spacing: 8
Rectangle {
Layout.fillWidth: true
height:2
color: Material.accent
boundsBehavior: Flickable.DragOverBounds
model: MessageEventModel{
id: messageEventModel
room: currentRoom
}
Label {
padding: 4
text: section
color: Material.accent
verticalAlignment: Text.AlignVCenter
delegate: MessageDelegate {}
section.property: "section"
section.criteria: ViewSection.FullString
section.delegate: RowLayout {
width: parent.width * 0.6
anchors.right: parent.right
Rectangle {
Layout.fillWidth: true
height:2
color: Material.accent
}
Label {
padding: 4
text: section
color: Material.accent
verticalAlignment: Text.AlignVCenter
}
}
ScrollBar.vertical: messageListViewScrollBar
onAtYBeginningChanged: atYBeginning && currentRoom ? currentRoom.getPreviousContent(50) : {}
onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {}
RoundButton {
id: goTopFab
width: height
height: 64
visible: !parent.atYEnd
anchors.right: parent.right
anchors.bottom: parent.bottom
contentItem: MaterialIcon {
anchors.fill: parent
icon: "\ue313"
color: "white"
}
opacity: pressed ? 1 : hovered ? 0.7 : 0.4
Material.background: Qt.lighter(Material.accent)
onClicked: parent.positionViewAtBeginning()
Behavior on opacity { NumberAnimation { duration: 200 } }
}
}
onAtYBeginningChanged: atYBeginning && currentRoom ? currentRoom.getPreviousContent(50) : {}
onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {}
ScrollBar {
id: messageListViewScrollBar
ScrollBar.vertical: ScrollBar {}
RoundButton {
id: goTopFab
width: height
height: 64
visible: !parent.atYEnd
anchors.right: parent.right
anchors.bottom: parent.bottom
contentItem: MaterialIcon {
anchors.fill: parent
icon: "\ue313"
color: "white"
}
opacity: pressed ? 1 : hovered ? 0.7 : 0.4
Material.background: Qt.lighter(Material.accent)
onClicked: parent.positionViewAtBeginning()
Behavior on opacity { NumberAnimation { duration: 200 } }
Layout.preferredWidth: 16
Layout.fillHeight: true
}
}