Allow swiping between views in single page mode

Allows access to spaces on mobile for example
This commit is contained in:
Nicolas Werner 2021-12-06 23:38:39 +01:00
parent b2b9cccb5e
commit 868342ffc9
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
2 changed files with 37 additions and 7 deletions

View file

@ -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

View file

@ -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
}