lockscreen: Port from Flickable to SwipeArea

This commit is contained in:
Devin Lin 2023-09-29 22:57:58 -07:00
parent 911d41e5ce
commit f949ea7fdf
2 changed files with 107 additions and 143 deletions

View file

@ -5,8 +5,9 @@ import QtQuick 2.15
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.private.mobileshell as MobileShell
Flickable {
MobileShell.SwipeArea {
id: root
property int position: 0
@ -52,14 +53,6 @@ Flickable {
}
}
// we use flickable solely for capturing flicks, not positioning elements
contentWidth: width
contentHeight: height * 2
contentX: 0
contentY: startContentY
readonly property real startContentY: contentHeight / 2
property int oldPosition: position
property bool movingUp: false
@ -68,38 +61,15 @@ Flickable {
oldPosition = position;
}
// update position from flickable movement
property real oldContentY
onContentYChanged: {
position = Math.max(0, Math.min(keypadHeight, position + (contentY - oldContentY)));
oldContentY = contentY;
}
onMovementStarted: cancelAnimations();
onMovementEnded: {
onSwipeStarted: cancelAnimations();
onSwipeEnded: {
if (!positionAnim.running) {
updateState();
}
resetPosition();
}
onFlickStarted: root.cancelFlick()
onFlickEnded: resetPosition();
onDraggingChanged: {
if (!dragging) {
resetPosition();
if (!positionAnim.running) {
root.updateState();
}
} else {
cancelAnimations();
}
}
function resetPosition() {
oldContentY = startContentY;
contentY = startContentY;
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => {
position = Math.max(0, Math.min(keypadHeight, position + deltaY));
}
}

View file

@ -108,11 +108,6 @@ Item {
}
}
Item {
width: flickable.width
height: flickable.height
y: flickable.contentY // effectively anchored to the screen
LockScreenNarrowContent {
id: phoneComponent
@ -237,5 +232,4 @@ Item {
}
}
}
}
}