From 4c892f53e842d224f55d7abbdcb3dd1520817bf4 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 10 May 2025 19:52:35 +1000 Subject: notifs: slide to remove --- modules/notifications/Notification.qml | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'modules/notifications/Notification.qml') diff --git a/modules/notifications/Notification.qml b/modules/notifications/Notification.qml index a3fa171..c8a83ea 100644 --- a/modules/notifications/Notification.qml +++ b/modules/notifications/Notification.qml @@ -20,8 +20,48 @@ StyledRect { color: Colours.palette.m3surfaceContainer radius: Appearance.rounding.normal implicitWidth: NotifsConfig.sizes.width + implicitHeight: inner.height + + MouseArea { + property int startY + + anchors.fill: parent + hoverEnabled: true + preventStealing: true + + onEntered: root.modelData.timer.stop() + onExited: root.modelData.timer.start() + + drag.target: parent + drag.axis: Drag.XAxis + + onPressed: event => startY = event.y + onReleased: event => { + if (Math.abs(root.x) < NotifsConfig.sizes.width * NotifsConfig.clearThreshold) + root.x = 0; + else + root.modelData.popup = false; + } + onPositionChanged: event => { + if (pressed) { + const diffY = event.y - startY; + if (Math.abs(diffY) > NotifsConfig.expandThreshold) + root.expanded = diffY > 0; + } + } + } + + Behavior on x { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.emphasizedDecel + } + } Item { + id: inner + anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top @@ -160,6 +200,11 @@ StyledRect { text: root.expanded ? "expand_less" : "expand_more" font.pointSize: Appearance.font.size.smaller } + + MouseArea { + anchors.fill: parent + onClicked: root.expanded = !root.expanded + } } StyledText { -- cgit v1.2.3-freya