dashboard: make own swipeview impl
Fixes bad anim, buggy flicking and blur
This commit is contained in:
parent
aa04827576
commit
687f5a5fd0
2 changed files with 67 additions and 23 deletions
|
|
@ -43,12 +43,46 @@ 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
|
||||
|
||||
implicitWidth: currentItem.implicitWidth
|
||||
implicitHeight: currentItem.implicitHeight
|
||||
|
||||
contentX: currentItem.x
|
||||
contentWidth: row.implicitWidth
|
||||
contentHeight: row.implicitHeight
|
||||
|
||||
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
|
||||
|
|
@ -57,7 +91,7 @@ Item {
|
|||
color: "transparent"
|
||||
|
||||
Dash {
|
||||
shouldUpdate: visible && dash.ListView.isCurrentItem
|
||||
shouldUpdate: visible && dash === view.currentItem
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +102,7 @@ Item {
|
|||
color: "transparent"
|
||||
|
||||
Media {
|
||||
shouldUpdate: visible && media.ListView.isCurrentItem
|
||||
shouldUpdate: visible && media === view.currentItem
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,6 +113,15 @@ Item {
|
|||
Performance {}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on contentX {
|
||||
NumberAnimation {
|
||||
duration: Appearance.anim.durations.normal
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: Appearance.anim.curves.standard
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on implicitWidth {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue