Skip to content
Snippets Groups Projects
Verified Commit 868342ff authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Allow swiping between views in single page mode

Allows access to spaces on mobile for example
parent b2b9cccb
No related branches found
No related tags found
No related merge requests found
Pipeline #2235 passed
......@@ -21,7 +21,39 @@ Rectangle {
anchors.fill: parent
singlePageMode: communityListC.preferredWidth + roomListC.preferredWidth + timlineViewC.minimumWidth > width
pageIndex: (Rooms.currentRoom || Rooms.currentRoomPreview.roomid) ? 2 : 1
pageIndex: 1
Component.onCompleted: initializePageIndex()
onSinglePageModeChanged: initializePageIndex()
function initializePageIndex() {
if (!singlePageMode)
adaptiveView.pageIndex = 0;
else if (Rooms.currentRoom || Rooms.currentRoomPreview.roomid)
adaptiveView.pageIndex = 2;
else
adaptiveView.pageIndex = 1;
}
Connections {
target: Rooms
function onCurrentRoomChanged() {
adaptiveView.initializePageIndex();
}
}
Connections {
target: Communities
function onCurrentTagIdChanged() {
adaptiveView.initializePageIndex();
}
}
onPageIndexChanged: {
if (adaptiveView.pageIndex == 1 && (Rooms.currentRoom || Rooms.currentRoomPreview.roomid)) {
Rooms.resetCurrentRoom();
}
}
AdaptiveLayoutElement {
id: communityListC
......
......@@ -16,10 +16,12 @@ Container {
property bool singlePageMode: width < 800
property int splitterGrabMargin: Nheko.paddingSmall
property int pageIndex: 0
property alias pageIndex: view.currentIndex
property Component handle
property Component handleToucharea
onSinglePageModeChanged: if (!singlePageMode) pageIndex = 0
anchors.fill: parent
Component.onCompleted: {
for (var i = 0; i < count - 1; i++) {
......@@ -103,9 +105,7 @@ Container {
xAxis.minimum: splitter.minimumWidth - 1
xAxis.maximum: splitter.maximumWidth
margin: container.splitterGrabMargin
//dragThreshold: 0
grabPermissions: PointerHandler.CanTakeOverFromAnything | PointerHandler.ApprovesTakeOverByHandlersOfSameType
//cursorShape: Qt.SizeHorCursor
onActiveChanged: {
if (!active)
splitter.parent.preferredWidth = splitter.x;
......@@ -114,8 +114,6 @@ Container {
}
HoverHandler {
//cursorShape: Qt.SizeHorCursor
enabled: !container.singlePageMode
margin: container.splitterGrabMargin
}
......@@ -129,7 +127,7 @@ Container {
snapMode: ListView.SnapOneItem
orientation: ListView.Horizontal
highlightRangeMode: ListView.StrictlyEnforceRange
interactive: false
interactive: singlePageMode
highlightMoveDuration: container.singlePageMode ? 200 : 0
currentIndex: container.singlePageMode ? container.pageIndex : 0
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment