lockscreen: Fix clock getting animated right after load

Restores a fix for https://invent.kde.org/plasma/plasma-mobile/-/issues/381

The pw notifications model right at load appears to say there are notifications at load, but then fixes itself once the component finishes loading.
This commit is contained in:
Devin Lin 2024-06-28 23:25:50 -04:00
parent 6b41f0c354
commit 403b11c2d7

View file

@ -29,13 +29,16 @@ Item {
visible: root.isVertical
spacing: 0
// center clock when no notifications are shown, otherwise move the clock upward
anchors.topMargin: !root.notificationsShown ? Math.round(root.fullHeight / 2 - (verticalLayout.implicitHeight / 2)) : Kirigami.Units.gridUnit * 5
// Center clock when no notifications are shown, otherwise move the clock upward
anchors.topMargin: root.notificationsShown ? Kirigami.Units.gridUnit * 5 : Math.round(root.fullHeight / 2 - (verticalLayout.implicitHeight / 2))
anchors.bottomMargin: Kirigami.Units.gridUnit
anchors.fill: parent
// animate
// Animate clock centering change when notifications come in
Behavior on anchors.topMargin {
id: topMarginAnim
enabled: false
NumberAnimation {
duration: Kirigami.Units.veryLongDuration
easing.type: Easing.InOutExpo
@ -46,6 +49,13 @@ Item {
LayoutItemProxy { target: notificationComponent }
}
// HACK: don't animate top margin at beginning, while notification model figures itself out
Timer {
running: true
repeat: false
onTriggered: topMarginAnim.enabled = true
}
// Horizontal layout (landscape on smaller devices)
Item {
id: horizontalLayout