Rearrange scroll bar.

Fixes #3.
This commit is contained in:
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.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.leftMargin: 16 Layout.leftMargin: 16
Layout.rightMargin: 16
displayMarginBeginning: 40
displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop
spacing: 8
boundsBehavior: Flickable.DragOverBounds z: -10
model: MessageEventModel{ spacing: 0
id: messageEventModel
room: currentRoom
}
delegate: MessageDelegate {} ListView {
id: messageListView
section.property: "section" Layout.fillWidth: true
section.criteria: ViewSection.FullString Layout.fillHeight: true
section.delegate: RowLayout { displayMarginBeginning: 40
width: parent.width * 0.6 displayMarginEnd: 40
anchors.right: parent.right verticalLayoutDirection: ListView.BottomToTop
spacing: 8
Rectangle { boundsBehavior: Flickable.DragOverBounds
Layout.fillWidth: true
height:2 model: MessageEventModel{
color: Material.accent id: messageEventModel
room: currentRoom
} }
Label { delegate: MessageDelegate {}
padding: 4
text: section section.property: "section"
color: Material.accent section.criteria: ViewSection.FullString
verticalAlignment: Text.AlignVCenter 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) : {} ScrollBar {
onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {} id: messageListViewScrollBar
ScrollBar.vertical: ScrollBar {} Layout.preferredWidth: 16
Layout.fillHeight: true
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 } }
} }
} }