mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
lockscreen: Port from Flickable to SwipeArea
This commit is contained in:
parent
911d41e5ce
commit
f949ea7fdf
2 changed files with 107 additions and 143 deletions
|
|
@ -5,8 +5,9 @@ import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import org.kde.kirigami 2.20 as Kirigami
|
import org.kde.kirigami 2.20 as Kirigami
|
||||||
|
import org.kde.plasma.private.mobileshell as MobileShell
|
||||||
|
|
||||||
Flickable {
|
MobileShell.SwipeArea {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property int position: 0
|
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 int oldPosition: position
|
||||||
property bool movingUp: false
|
property bool movingUp: false
|
||||||
|
|
||||||
|
|
@ -68,38 +61,15 @@ Flickable {
|
||||||
oldPosition = position;
|
oldPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update position from flickable movement
|
onSwipeStarted: cancelAnimations();
|
||||||
property real oldContentY
|
onSwipeEnded: {
|
||||||
onContentYChanged: {
|
|
||||||
position = Math.max(0, Math.min(keypadHeight, position + (contentY - oldContentY)));
|
|
||||||
oldContentY = contentY;
|
|
||||||
}
|
|
||||||
|
|
||||||
onMovementStarted: cancelAnimations();
|
|
||||||
onMovementEnded: {
|
|
||||||
if (!positionAnim.running) {
|
if (!positionAnim.running) {
|
||||||
updateState();
|
updateState();
|
||||||
}
|
}
|
||||||
resetPosition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFlickStarted: root.cancelFlick()
|
onSwipeMove: (totalDeltaX, totalDeltaY, deltaX, deltaY) => {
|
||||||
onFlickEnded: resetPosition();
|
position = Math.max(0, Math.min(keypadHeight, position + deltaY));
|
||||||
|
|
||||||
onDraggingChanged: {
|
|
||||||
if (!dragging) {
|
|
||||||
resetPosition();
|
|
||||||
if (!positionAnim.running) {
|
|
||||||
root.updateState();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cancelAnimations();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetPosition() {
|
|
||||||
oldContentY = startContentY;
|
|
||||||
contentY = startContentY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,11 +108,6 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
|
||||||
width: flickable.width
|
|
||||||
height: flickable.height
|
|
||||||
y: flickable.contentY // effectively anchored to the screen
|
|
||||||
|
|
||||||
LockScreenNarrowContent {
|
LockScreenNarrowContent {
|
||||||
id: phoneComponent
|
id: phoneComponent
|
||||||
|
|
||||||
|
|
@ -238,4 +233,3 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue