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: []
|
||||
|
||||
function _cascadeDismiss() {
|
||||
const dels = _delegates.filter(d => d && d.modelData && !d.modelData.closed);
|
||||
if (dels.length === 0)
|
||||
const list = M.NotifService.list;
|
||||
if (list.length === 0)
|
||||
return;
|
||||
|
||||
_pendingDismissIds = dels.map(d => d.modelData.id);
|
||||
_pendingDismissIds = list.map(n => n.id);
|
||||
|
||||
for (let i = 0; i < dels.length; i++) {
|
||||
const d = dels[i];
|
||||
const isLast = (i === dels.length - 1);
|
||||
const visibles = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
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, {
|
||||
_target: d,
|
||||
_target: visibles[i],
|
||||
_delay: i * 60,
|
||||
_isLast: isLast
|
||||
_isLast: i === visibles.length - 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -132,25 +140,12 @@ M.PopupPanel {
|
|||
}
|
||||
|
||||
// Notification list (scrollable)
|
||||
Item {
|
||||
ListView {
|
||||
id: notifList
|
||||
width: menuWindow.panelWidth
|
||||
height: Math.min(notifFlick.contentHeight, _maxHeight)
|
||||
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
|
||||
height: Math.min(contentHeight, 60 * (M.Modules.notifications.maxVisible || 10))
|
||||
clip: true
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
Column {
|
||||
id: notifCol
|
||||
width: parent.width
|
||||
|
||||
Repeater {
|
||||
model: M.NotifService.list
|
||||
|
||||
delegate: Item {
|
||||
|
|
@ -182,15 +177,7 @@ M.PopupPanel {
|
|||
_dismissAnim.start();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
menuWindow._delegates.push(notifItem);
|
||||
fadeIn.start();
|
||||
}
|
||||
Component.onDestruction: {
|
||||
const idx = menuWindow._delegates.indexOf(notifItem);
|
||||
if (idx >= 0)
|
||||
menuWindow._delegates.splice(idx, 1);
|
||||
}
|
||||
Component.onCompleted: fadeIn.start()
|
||||
|
||||
NumberAnimation {
|
||||
id: fadeIn
|
||||
|
|
@ -419,10 +406,7 @@ M.PopupPanel {
|
|||
onClicked: _dismissAnim.start()
|
||||
}
|
||||
}
|
||||
} // Repeater
|
||||
} // Column
|
||||
} // Flickable
|
||||
} // Item
|
||||
}
|
||||
|
||||
// Empty state
|
||||
Text {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue