perf: replace notifcenter repeater with listview for virtualization
This commit is contained in:
parent
e1241b33d2
commit
c5067c4e7f
1 changed files with 272 additions and 288 deletions
|
|
@ -64,24 +64,32 @@ M.PopupPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property var _delegates: []
|
|
||||||
|
|
||||||
property var _pendingDismissIds: []
|
property var _pendingDismissIds: []
|
||||||
|
|
||||||
function _cascadeDismiss() {
|
function _cascadeDismiss() {
|
||||||
const dels = _delegates.filter(d => d && d.modelData && !d.modelData.closed);
|
const list = M.NotifService.list;
|
||||||
if (dels.length === 0)
|
if (list.length === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_pendingDismissIds = dels.map(d => d.modelData.id);
|
_pendingDismissIds = list.map(n => n.id);
|
||||||
|
|
||||||
for (let i = 0; i < dels.length; i++) {
|
const visibles = [];
|
||||||
const d = dels[i];
|
for (let i = 0; i < list.length; i++) {
|
||||||
const isLast = (i === dels.length - 1);
|
const d = notifList.itemAtIndex(i);
|
||||||
|
if (d && d.modelData?.state !== "dismissing")
|
||||||
|
visibles.push(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visibles.length === 0) {
|
||||||
|
_finishCascade();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < visibles.length; i++) {
|
||||||
_cascadeTimer.createObject(menuWindow, {
|
_cascadeTimer.createObject(menuWindow, {
|
||||||
_target: d,
|
_target: visibles[i],
|
||||||
_delay: i * 60,
|
_delay: i * 60,
|
||||||
_isLast: isLast
|
_isLast: i === visibles.length - 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -132,25 +140,12 @@ M.PopupPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notification list (scrollable)
|
// Notification list (scrollable)
|
||||||
Item {
|
ListView {
|
||||||
|
id: notifList
|
||||||
width: menuWindow.panelWidth
|
width: menuWindow.panelWidth
|
||||||
height: Math.min(notifFlick.contentHeight, _maxHeight)
|
height: Math.min(contentHeight, 60 * (M.Modules.notifications.maxVisible || 10))
|
||||||
readonly property real _itemHeight: 60
|
|
||||||
readonly property real _maxHeight: _itemHeight * (M.Modules.notifications.maxVisible || 10)
|
|
||||||
|
|
||||||
Flickable {
|
|
||||||
id: notifFlick
|
|
||||||
anchors.fill: parent
|
|
||||||
contentWidth: width
|
|
||||||
contentHeight: notifCol.implicitHeight
|
|
||||||
clip: true
|
clip: true
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
Column {
|
|
||||||
id: notifCol
|
|
||||||
width: parent.width
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
model: M.NotifService.list
|
model: M.NotifService.list
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
|
|
@ -182,15 +177,7 @@ M.PopupPanel {
|
||||||
_dismissAnim.start();
|
_dismissAnim.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: fadeIn.start()
|
||||||
menuWindow._delegates.push(notifItem);
|
|
||||||
fadeIn.start();
|
|
||||||
}
|
|
||||||
Component.onDestruction: {
|
|
||||||
const idx = menuWindow._delegates.indexOf(notifItem);
|
|
||||||
if (idx >= 0)
|
|
||||||
menuWindow._delegates.splice(idx, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
id: fadeIn
|
id: fadeIn
|
||||||
|
|
@ -419,10 +406,7 @@ M.PopupPanel {
|
||||||
onClicked: _dismissAnim.start()
|
onClicked: _dismissAnim.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // Repeater
|
}
|
||||||
} // Column
|
|
||||||
} // Flickable
|
|
||||||
} // Item
|
|
||||||
|
|
||||||
// Empty state
|
// Empty state
|
||||||
Text {
|
Text {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue