Skip to content

Commit 2345869

Browse files
kaustuvpokharelgabriel-bolbotina
authored andcommitted
scroll bar to all list WIP
1 parent 9bb46cf commit 2345869

4 files changed

Lines changed: 26 additions & 18 deletions

File tree

app/qml/components/MMListDelegate.qml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Item {
2424
property string text
2525
property string secondaryText
2626

27+
readonly property int scrollSpace: (ListView.view && ListView.view.scrollSpace) ? ListView.view.scrollSpace : 0
2728
property alias leftContent: leftContentGroup.children
2829
property alias rightContent: rightContentGroup.children
2930

@@ -40,9 +41,10 @@ Item {
4041

4142
property real verticalSpacing: root.secondaryText ? __style.margin8 : __style.margin20
4243

43-
implicitWidth: ListView?.view?.width ?? 0 // in case ListView is injected as attached property (usually it is)
44+
implicitWidth: ListView?.view?.width ?? 0 // in case ListView is injected as attached property (usually it is)
4445
implicitHeight: contentLayout.implicitHeight
4546
height: visible ? implicitHeight : 0.1 // hide invisible items, for some reason setting 0 does not work ¯\_(ツ)_/¯
47+
width: implicitWidth - root.scrollSpace
4648

4749
MouseArea {
4850
anchors.fill: contentLayout

app/qml/components/MMListView.qml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,35 @@
88
***************************************************************************/
99

1010
import QtQuick
11+
import QtQuick.Controls
1112

1213
//
1314
// Hot-fix for hotfix https://github.com/MerginMaps/mobile/issues/3417
1415
// Seems like there is some issue with cache in ListView
1516
//
1617

1718
ListView {
19+
id: root
1820

1921
cacheBuffer: 0
22+
readonly property bool isMobile: (Qt.platform.os === "android" || Qt.platform.os === "ios")
23+
property int scrollSpace: !isMobile ? 10 : 0
24+
25+
ScrollBar.vertical: ScrollBar {
26+
id: verticalScrollBar
27+
28+
policy: ScrollBar.AlwaysOn
29+
visible: !isMobile && (root.contentHeight > root.height)
30+
opacity: (pressed || root.moving) ? 0.7 : 0.4
31+
32+
anchors.right: root.right
33+
34+
implicitHeight: root.height
35+
36+
contentItem: Rectangle {
37+
implicitWidth: 5
38+
radius: width / 2
39+
color: __style.darkGreenColor
40+
}
41+
}
2042
}

app/qml/components/MMScrollView.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ ScrollView {
2020

2121
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
2222
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
23+
2324
}

app/qml/layers/MMFeaturesListPage.qml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ MMComponents.MMPage {
7373
onClicked: root.featureClicked( model.FeaturePair )
7474
}
7575

76-
ScrollBar.vertical: ScrollBar {
77-
id: verticalScrollBar
78-
79-
readonly property bool isMobile: (Qt.platform.os === "android" || Qt.platform.os === "ios")
80-
policy: ScrollBar.AlwaysOn
81-
visible: !isMobile
82-
opacity: (pressed || listView.moving) ? 0.7 : 0.4
83-
84-
implicitHeight: listView.height
85-
86-
contentItem: Rectangle {
87-
implicitWidth: 5
88-
radius: width / 2
89-
color: __style.darkGreenColor
90-
}
91-
}
92-
9376
footer: MMComponents.MMListSpacer {
9477
height: __style.margin20 + ( root.hasToolbar ? 0 : __style.safeAreaBottom ) + ( addButton.visible ? addButton.height : 0 )
9578
}

0 commit comments

Comments
 (0)