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,41 +43,84 @@ Item {
|
||||||
radius: Appearance.rounding.normal
|
radius: Appearance.rounding.normal
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
SwipeView {
|
Flickable {
|
||||||
id: view
|
id: view
|
||||||
|
|
||||||
|
readonly property int currentIndex: tabs.currentIndex
|
||||||
|
readonly property Item currentItem: row.children[currentIndex]
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
currentIndex: tabs.currentIndex
|
flickableDirection: Flickable.HorizontalFlick
|
||||||
|
|
||||||
ClippingWrapperRectangle {
|
implicitWidth: currentItem.implicitWidth
|
||||||
id: dash
|
implicitHeight: currentItem.implicitHeight
|
||||||
|
|
||||||
radius: Appearance.rounding.normal
|
contentX: currentItem.x
|
||||||
color: "transparent"
|
contentWidth: row.implicitWidth
|
||||||
|
contentHeight: row.implicitHeight
|
||||||
|
|
||||||
Dash {
|
onContentXChanged: {
|
||||||
shouldUpdate: visible && dash.ListView.isCurrentItem
|
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 {
|
Behavior on contentX {
|
||||||
id: media
|
NumberAnimation {
|
||||||
|
duration: Appearance.anim.durations.normal
|
||||||
radius: Appearance.rounding.normal
|
easing.type: Easing.BezierSpline
|
||||||
color: "transparent"
|
easing.bezierCurve: Appearance.anim.curves.standard
|
||||||
|
|
||||||
Media {
|
|
||||||
shouldUpdate: visible && media.ListView.isCurrentItem
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClippingWrapperRectangle {
|
|
||||||
radius: Appearance.rounding.normal
|
|
||||||
color: "transparent"
|
|
||||||
|
|
||||||
Performance {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ Item {
|
||||||
|
|
||||||
required property real nonAnimWidth
|
required property real nonAnimWidth
|
||||||
property alias currentIndex: bar.currentIndex
|
property alias currentIndex: bar.currentIndex
|
||||||
|
readonly property TabBar bar: bar
|
||||||
|
|
||||||
implicitHeight: bar.implicitHeight + indicator.implicitHeight + indicator.anchors.topMargin + separator.implicitHeight
|
implicitHeight: bar.implicitHeight + indicator.implicitHeight + indicator.anchors.topMargin + separator.implicitHeight
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue