diff --git a/modules/dashboard/Content.qml b/modules/dashboard/Content.qml index bd613e74..a3963bb6 100644 --- a/modules/dashboard/Content.qml +++ b/modules/dashboard/Content.qml @@ -43,41 +43,84 @@ Item { radius: Appearance.rounding.normal color: "transparent" - SwipeView { + Flickable { id: view + readonly property int currentIndex: tabs.currentIndex + readonly property Item currentItem: row.children[currentIndex] + anchors.fill: parent - currentIndex: tabs.currentIndex + flickableDirection: Flickable.HorizontalFlick - ClippingWrapperRectangle { - id: dash + implicitWidth: currentItem.implicitWidth + implicitHeight: currentItem.implicitHeight - radius: Appearance.rounding.normal - color: "transparent" + contentX: currentItem.x + contentWidth: row.implicitWidth + contentHeight: row.implicitHeight - Dash { - shouldUpdate: visible && dash.ListView.isCurrentItem + onContentXChanged: { + if (!moving) + return; + + const x = contentX - currentItem.x; + if (x > currentItem.implicitWidth / 2) + tabs.bar.incrementCurrentIndex(); + else if (x < -currentItem.implicitWidth / 2) + tabs.bar.decrementCurrentIndex(); + } + + onDragEnded: { + const x = contentX - currentItem.x; + if (x > currentItem.implicitWidth / 10) + tabs.bar.incrementCurrentIndex(); + else if (x < -currentItem.implicitWidth / 10) + tabs.bar.decrementCurrentIndex(); + else + contentX = Qt.binding(() => currentItem.x); + } + + Row { + id: row + + ClippingWrapperRectangle { + id: dash + + radius: Appearance.rounding.normal + color: "transparent" + + Dash { + shouldUpdate: visible && dash === view.currentItem + } + } + + ClippingWrapperRectangle { + id: media + + radius: Appearance.rounding.normal + color: "transparent" + + Media { + shouldUpdate: visible && media === view.currentItem + } + } + + ClippingWrapperRectangle { + radius: Appearance.rounding.normal + color: "transparent" + + Performance {} } } - ClippingWrapperRectangle { - id: media - - radius: Appearance.rounding.normal - color: "transparent" - - Media { - shouldUpdate: visible && media.ListView.isCurrentItem + Behavior on contentX { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard } } - - ClippingWrapperRectangle { - radius: Appearance.rounding.normal - color: "transparent" - - Performance {} - } } } diff --git a/modules/dashboard/Tabs.qml b/modules/dashboard/Tabs.qml index 945f71cb..db7796ac 100644 --- a/modules/dashboard/Tabs.qml +++ b/modules/dashboard/Tabs.qml @@ -10,6 +10,7 @@ Item { required property real nonAnimWidth property alias currentIndex: bar.currentIndex + readonly property TabBar bar: bar implicitHeight: bar.implicitHeight + indicator.implicitHeight + indicator.anchors.topMargin + separator.implicitHeight