1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 14:05:38 -05:00

Notification updates

This commit is contained in:
purian23
2025-07-14 10:51:17 -04:00
parent cf5c26522b
commit 5c5653a41a
4 changed files with 375 additions and 116 deletions

View File

@@ -43,10 +43,114 @@ PanelWindow {
opacity: root.showNotificationPopup ? 1.0 : 0.0
// Transform for swipe animations
transform: Translate {
id: swipeTransform
x: 0
}
Behavior on opacity {
NumberAnimation { duration: 200; easing.type: Easing.OutQuad }
}
// Drag area for swipe gestures
DragHandler {
id: dragHandler
target: null // We'll handle the transform manually
acceptedDevices: PointerDevice.TouchScreen | PointerDevice.Mouse
property real startX: 0
property real currentDelta: 0
property bool isDismissing: false
onActiveChanged: {
if (active) {
startX = centroid.position.x
currentDelta = 0
isDismissing = false
} else {
// Handle end of drag
let deltaX = centroid.position.x - startX
if (Math.abs(deltaX) > 80) { // Threshold for swipe action
if (deltaX > 0) {
// Swipe right - open notification history
swipeOpenHistory()
} else {
// Swipe left - dismiss notification
swipeDismiss()
}
} else {
// Snap back to original position
snapBack()
}
}
}
onCentroidChanged: {
if (active) {
let deltaX = centroid.position.x - startX
currentDelta = deltaX
// Limit swipe distance and add resistance
let maxDistance = 120
let resistance = 0.6
if (Math.abs(deltaX) > maxDistance) {
deltaX = deltaX > 0 ? maxDistance : -maxDistance
}
swipeTransform.x = deltaX * resistance
// Visual feedback - reduce opacity when swiping left (dismiss)
if (deltaX < 0) {
popupContainer.opacity = Math.max(0.3, 1.0 - Math.abs(deltaX) / 150)
} else {
popupContainer.opacity = Math.max(0.7, 1.0 - Math.abs(deltaX) / 200)
}
}
}
function swipeOpenHistory() {
// Animate to the right and open history
swipeAnimation.to = 400
swipeAnimation.onFinished = function() {
root.notificationHistoryVisible = true
Utils.hideNotificationPopup()
snapBack()
}
swipeAnimation.start()
}
function swipeDismiss() {
// Animate to the left and dismiss
swipeAnimation.to = -400
swipeAnimation.onFinished = function() {
Utils.hideNotificationPopup()
snapBack()
}
swipeAnimation.start()
}
function snapBack() {
swipeAnimation.to = 0
swipeAnimation.onFinished = function() {
popupContainer.opacity = Qt.binding(() => root.showNotificationPopup ? 1.0 : 0.0)
}
swipeAnimation.start()
}
}
// Swipe animation
NumberAnimation {
id: swipeAnimation
target: swipeTransform
property: "x"
duration: 200
easing.type: Easing.OutCubic
}
// Tap area for notification interaction
MouseArea {
anchors.fill: parent
anchors.rightMargin: 36 // Don't overlap with close button
@@ -58,15 +162,9 @@ PanelWindow {
console.log("Popup clicked!")
if (root.activeNotification) {
root.handleNotificationClick(root.activeNotification)
// Remove notification from history entirely
for (let i = 0; i < notificationHistory.count; i++) {
if (notificationHistory.get(i).id === root.activeNotification.id) {
notificationHistory.remove(i)
break
}
}
// Don't remove from history - just hide popup
}
// Always hide popup after click
// Hide popup but keep in history
Utils.hideNotificationPopup()
mouse.accepted = true // Prevent event propagation
}
@@ -110,11 +208,77 @@ PanelWindow {
}
}
// Small dismiss button - bottom right corner
Rectangle {
width: 60
height: 18
radius: 9
color: dismissButtonArea.containsMouse ?
Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.1)
border.color: dismissButtonArea.containsMouse ?
Theme.primary :
Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.5)
border.width: 1
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 12
anchors.bottomMargin: 10
Row {
anchors.centerIn: parent
spacing: 4
Text {
text: "archive"
font.family: Theme.iconFont
font.pixelSize: 10
color: dismissButtonArea.containsMouse ? Theme.primary : Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter
}
Text {
text: "Dismiss"
font.pixelSize: 10
color: dismissButtonArea.containsMouse ? Theme.primary : Theme.surfaceText
font.weight: Font.Medium
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: dismissButtonArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
// Just hide the popup, keep in history
Utils.hideNotificationPopup()
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
Behavior on border.color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
// Content layout
Row {
anchors.fill: parent
anchors.margins: 12
anchors.rightMargin: 32
anchors.bottomMargin: 6 // Reduced bottom margin to account for dismiss button
spacing: 12
// Notification icon based on EXAMPLE NotificationAppIcon pattern