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

notifications: improve general layout and visual b ugs

This commit is contained in:
bbedward
2025-07-26 11:41:25 -04:00
parent 7b8efd9114
commit ec1bf7c110
2 changed files with 138 additions and 121 deletions

View File

@@ -12,6 +12,7 @@ Rectangle {
property var notificationGroup property var notificationGroup
property bool expanded: NotificationService.expandedGroups[notificationGroup?.key] || false property bool expanded: NotificationService.expandedGroups[notificationGroup?.key] || false
property bool descriptionExpanded: false property bool descriptionExpanded: false
property bool userInitiatedExpansion: false
width: parent ? parent.width : 400 width: parent ? parent.width : 400
height: { height: {
@@ -19,10 +20,8 @@ Rectangle {
return expandedContent.height + 28; return expandedContent.height + 28;
} }
const baseHeight = 116; const baseHeight = 116;
if (descriptionExpanded && descriptionText.hasMoreText) { if (descriptionExpanded) {
const twoLineHeight = descriptionText.font.pixelSize * 1.2 * 2; return baseHeight + descriptionText.contentHeight - (descriptionText.font.pixelSize * 1.2 * 2);
const extraHeight = descriptionText.contentHeight - twoLineHeight;
return baseHeight + extraHeight;
} }
return baseHeight; return baseHeight;
} }
@@ -180,7 +179,7 @@ Rectangle {
Text { Text {
id: descriptionText id: descriptionText
property string fullText: notificationGroup?.latestNotification?.body || "" property string fullText: notificationGroup?.latestNotification?.body || ""
property bool hasMoreText: false property bool hasMoreText: truncated
text: fullText text: fullText
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
@@ -192,19 +191,14 @@ Rectangle {
visible: text.length > 0 visible: text.length > 0
textFormat: Text.PlainText textFormat: Text.PlainText
onContentHeightChanged: {
const singleLineHeight = font.pixelSize * 1.2;
const twoLineHeight = singleLineHeight * 2;
hasMoreText = descriptionText.contentHeight > twoLineHeight;
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
cursorShape: parent.hasMoreText ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: (parent.hasMoreText || descriptionExpanded) ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: parent.hasMoreText enabled: parent.hasMoreText || descriptionExpanded
onClicked: { onClicked: {
descriptionExpanded = !descriptionExpanded; descriptionExpanded = !descriptionExpanded;
} }
z: 1
} }
} }
} }
@@ -246,18 +240,18 @@ Rectangle {
} }
Rectangle { Rectangle {
width: 20 width: 18
height: 20 height: 18
radius: 10 radius: 9
color: Theme.primary color: Theme.primary
visible: (notificationGroup?.count || 0) > 1 visible: (notificationGroup?.count || 0) > 1
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
text: (notificationGroup?.count || 0).toString() text: (notificationGroup?.count || 0) > 99 ? "99+" : (notificationGroup?.count || 0).toString()
color: Theme.primaryText color: Theme.primaryText
font.pixelSize: 10 font.pixelSize: 9
font.weight: Font.Bold font.weight: Font.Bold
} }
} }
@@ -294,16 +288,13 @@ Rectangle {
border.width: 1 border.width: 1
Behavior on height { Behavior on height {
NumberAnimation { enabled: false
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
} }
Item { Item {
anchors.fill: parent anchors.fill: parent
anchors.margins: 12 anchors.margins: 12
anchors.bottomMargin: 18 anchors.bottomMargin: 8
Rectangle { Rectangle {
id: messageIcon id: messageIcon
@@ -351,13 +342,20 @@ Rectangle {
} }
} }
Column { Item {
anchors.left: messageIcon.right anchors.left: messageIcon.right
anchors.leftMargin: 12 anchors.leftMargin: 12
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 12 anchors.rightMargin: 12
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: -2 anchors.bottom: parent.bottom
Column {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: buttonArea.top
anchors.bottomMargin: 4
spacing: 2 spacing: 2
Text { Text {
@@ -384,6 +382,7 @@ Rectangle {
Text { Text {
id: bodyText id: bodyText
property bool hasMoreText: truncated
text: modelData?.body || "" text: modelData?.body || ""
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
@@ -397,19 +396,28 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
cursorShape: parent.truncated ? Qt.PointingHandCursor : Qt.ArrowCursor enabled: bodyText.hasMoreText || messageExpanded
enabled: parent.truncated || messageExpanded cursorShape: bodyText.hasMoreText || messageExpanded ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: { onClicked: {
if (bodyText.hasMoreText || messageExpanded) {
NotificationService.toggleMessageExpansion(modelData?.notification?.id || ""); NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
} }
} }
} }
}
}
Item {
id: buttonArea
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 30
Row { Row {
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom
spacing: 8 spacing: 8
anchors.topMargin: 4
anchors.bottomMargin: 6
Repeater { Repeater {
model: modelData?.actions || [] model: modelData?.actions || []
@@ -480,6 +488,7 @@ Rectangle {
} }
} }
} }
}
Row { Row {
visible: !expanded visible: !expanded
@@ -563,8 +572,11 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
visible: !expanded && (notificationGroup?.count || 0) > 1 visible: !expanded && (notificationGroup?.count || 0) > 1 && !descriptionExpanded
onClicked: NotificationService.toggleGroupExpansion(notificationGroup?.key || "") onClicked: {
root.userInitiatedExpansion = true
NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
z: -1 z: -1
} }
@@ -574,33 +586,38 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: 12 anchors.topMargin: 12
anchors.rightMargin: 16 anchors.rightMargin: 16
width: 40 width: 60
height: 24 height: 28
DankActionButton { DankActionButton {
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
visible: (notificationGroup?.count || 0) > 1 visible: (notificationGroup?.count || 0) > 1
iconName: expanded ? "expand_less" : "expand_more" iconName: expanded ? "expand_less" : "expand_more"
iconSize: 14 iconSize: 18
buttonSize: 20 buttonSize: 28
onClicked: NotificationService.toggleGroupExpansion(notificationGroup?.key || "") onClicked: {
root.userInitiatedExpansion = true
NotificationService.toggleGroupExpansion(notificationGroup?.key || "")
}
} }
DankActionButton { DankActionButton {
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
iconName: "close" iconName: "close"
iconSize: 14 iconSize: 18
buttonSize: 20 buttonSize: 28
onClicked: NotificationService.dismissGroup(notificationGroup?.key || "") onClicked: NotificationService.dismissGroup(notificationGroup?.key || "")
} }
} }
Behavior on height { Behavior on height {
enabled: root.userInitiatedExpansion
NumberAnimation { NumberAnimation {
duration: Theme.mediumDuration duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing easing.type: Theme.emphasizedEasing
onFinished: root.userInitiatedExpansion = false
} }
} }
} }

View File

@@ -91,7 +91,7 @@ ListView {
} }
displaced: Transition { displaced: Transition {
enabled: !root.isUserScrolling enabled: false
NumberAnimation { NumberAnimation {
properties: "y" properties: "y"
@@ -101,11 +101,11 @@ ListView {
} }
move: Transition { move: Transition {
enabled: !root.isUserScrolling enabled: false
NumberAnimation { NumberAnimation {
properties: "y" properties: "y"
duration: (root.atYBeginning && !root.isUserScrolling) ? Theme.mediumDuration : 0 duration: 0
easing.type: Theme.emphasizedEasing easing.type: Theme.emphasizedEasing
} }