mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 21:45:38 -05:00
notifications: improve general layout and visual b ugs
This commit is contained in:
@@ -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,85 +342,134 @@ 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
|
||||||
spacing: 2
|
|
||||||
|
|
||||||
Text {
|
Column {
|
||||||
width: parent.width
|
anchors.left: parent.left
|
||||||
text: modelData?.timeStr || ""
|
anchors.right: parent.right
|
||||||
color: Theme.surfaceVariantText
|
anchors.top: parent.top
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
anchors.bottom: buttonArea.top
|
||||||
font.weight: Font.Medium
|
anchors.bottomMargin: 4
|
||||||
elide: Text.ElideRight
|
spacing: 2
|
||||||
maximumLineCount: 1
|
|
||||||
visible: text.length > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: modelData?.summary || ""
|
text: modelData?.timeStr || ""
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceVariantText
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: bodyText
|
width: parent.width
|
||||||
|
text: modelData?.summary || ""
|
||||||
text: modelData?.body || ""
|
color: Theme.surfaceText
|
||||||
color: Theme.surfaceVariantText
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.weight: Font.Medium
|
||||||
width: parent.width
|
elide: Text.ElideRight
|
||||||
elide: messageExpanded ? Text.ElideNone : Text.ElideRight
|
maximumLineCount: 1
|
||||||
maximumLineCount: messageExpanded ? -1 : 2
|
visible: text.length > 0
|
||||||
wrapMode: Text.WordWrap
|
}
|
||||||
visible: text.length > 0
|
|
||||||
textFormat: Text.PlainText
|
Text {
|
||||||
|
id: bodyText
|
||||||
MouseArea {
|
property bool hasMoreText: truncated
|
||||||
anchors.fill: parent
|
|
||||||
cursorShape: parent.truncated ? Qt.PointingHandCursor : Qt.ArrowCursor
|
text: modelData?.body || ""
|
||||||
enabled: parent.truncated || messageExpanded
|
color: Theme.surfaceVariantText
|
||||||
onClicked: {
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
|
width: parent.width
|
||||||
|
elide: messageExpanded ? Text.ElideNone : Text.ElideRight
|
||||||
|
maximumLineCount: messageExpanded ? -1 : 2
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
visible: text.length > 0
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: bodyText.hasMoreText || messageExpanded
|
||||||
|
cursorShape: bodyText.hasMoreText || messageExpanded ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
onClicked: {
|
||||||
|
if (bodyText.hasMoreText || messageExpanded) {
|
||||||
|
NotificationService.toggleMessageExpansion(modelData?.notification?.id || "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Item {
|
||||||
|
id: buttonArea
|
||||||
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
spacing: 8
|
anchors.bottom: parent.bottom
|
||||||
anchors.topMargin: 4
|
height: 30
|
||||||
anchors.bottomMargin: 6
|
|
||||||
|
Row {
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: modelData?.actions || []
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
property bool isHovered: false
|
||||||
|
|
||||||
|
width: Math.max(actionText.implicitWidth + 12, 50)
|
||||||
|
height: 24
|
||||||
|
radius: 4
|
||||||
|
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: actionText
|
||||||
|
text: modelData.text || ""
|
||||||
|
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
font.weight: Font.Medium
|
||||||
|
anchors.centerIn: parent
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onEntered: parent.isHovered = true
|
||||||
|
onExited: parent.isHovered = false
|
||||||
|
onClicked: {
|
||||||
|
if (modelData && modelData.invoke) {
|
||||||
|
modelData.invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: modelData?.actions || []
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
property bool isHovered: false
|
property bool isHovered: false
|
||||||
|
|
||||||
width: Math.max(actionText.implicitWidth + 12, 50)
|
width: Math.max(dismissText.implicitWidth + 12, 50)
|
||||||
height: 24
|
height: 24
|
||||||
radius: 4
|
radius: 4
|
||||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: actionText
|
id: dismissText
|
||||||
text: modelData.text || ""
|
text: "Dismiss"
|
||||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -438,41 +478,10 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onEntered: parent.isHovered = true
|
onEntered: parent.isHovered = true
|
||||||
onExited: parent.isHovered = false
|
onExited: parent.isHovered = false
|
||||||
onClicked: {
|
onClicked: NotificationService.dismissNotification(modelData)
|
||||||
if (modelData && modelData.invoke) {
|
|
||||||
modelData.invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
property bool isHovered: false
|
|
||||||
|
|
||||||
width: Math.max(dismissText.implicitWidth + 12, 50)
|
|
||||||
height: 24
|
|
||||||
radius: 4
|
|
||||||
color: isHovered ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1) : "transparent"
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: dismissText
|
|
||||||
text: "Dismiss"
|
|
||||||
color: parent.isHovered ? Theme.primary : Theme.surfaceVariantText
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
font.weight: Font.Medium
|
|
||||||
anchors.centerIn: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onEntered: parent.isHovered = true
|
|
||||||
onExited: parent.isHovered = false
|
|
||||||
onClicked: NotificationService.dismissNotification(modelData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user