From 687f5a5fd0e93428ca05a6490fbdac9949399323 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 7 Jun 2025 00:43:04 +1000 Subject: dashboard: make own swipeview impl Fixes bad anim, buggy flicking and blur --- modules/dashboard/Content.qml | 83 ++++++++++++++++++++++++++++++++----------- modules/dashboard/Tabs.qml | 1 + 2 files changed, 64 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/dashboard/Content.qml b/modules/dashboard/Content.qml index bd613e7..a3963bb 100644 --- a/modules/dashboard/Content.qml +++ b/modules/dashboard/Content.qml @@ -43,40 +43,83 @@ 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); } - ClippingWrapperRectangle { - id: media + Row { + id: row + + ClippingWrapperRectangle { + id: dash - radius: Appearance.rounding.normal - color: "transparent" + radius: Appearance.rounding.normal + color: "transparent" - Media { - shouldUpdate: visible && media.ListView.isCurrentItem + Dash { + shouldUpdate: visible && dash === view.currentItem + } } - } - ClippingWrapperRectangle { - radius: Appearance.rounding.normal - color: "transparent" + ClippingWrapperRectangle { + id: media + + radius: Appearance.rounding.normal + color: "transparent" - Performance {} + Media { + shouldUpdate: visible && media === view.currentItem + } + } + + ClippingWrapperRectangle { + radius: Appearance.rounding.normal + color: "transparent" + + Performance {} + } + } + + Behavior on contentX { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } } } } diff --git a/modules/dashboard/Tabs.qml b/modules/dashboard/Tabs.qml index 945f71c..db7796a 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 -- cgit v1.2.3-freya