timeline fixups
This commit is contained in:
parent
c658034d3b
commit
ac31fbb74d
1 changed files with 46 additions and 7 deletions
|
|
@ -40,6 +40,16 @@ class const ChatTimeline({
|
|||
isHighlighted: scroll.highlightedEvent == eventRowId,
|
||||
);
|
||||
|
||||
/// Where the row with [key] now is in [rows], so its element moves with it
|
||||
/// when rows are added before it, rather than being rebuilt by index.
|
||||
int? indexOf(IList<int> rows, Key key) => switch (key) {
|
||||
EventRowKey(:final rowId) => switch (rows.indexOf(rowId)) {
|
||||
-1 => null,
|
||||
final index => index,
|
||||
},
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) => TweenAnimationBuilder(
|
||||
|
|
@ -66,6 +76,7 @@ class const ChatTimeline({
|
|||
|
||||
SuperSliverList.builder(
|
||||
itemCount: scroll.liveRows.length,
|
||||
findChildIndexCallback: (key) => indexOf(scroll.liveRows, key),
|
||||
itemBuilder: (_, index) => eventRow(
|
||||
scroll.liveRows[index],
|
||||
index > 0
|
||||
|
|
@ -78,6 +89,8 @@ class const ChatTimeline({
|
|||
SuperSliverList.builder(
|
||||
key: scroll.centerKey,
|
||||
itemCount: scroll.historyRows.length,
|
||||
findChildIndexCallback: (key) =>
|
||||
indexOf(scroll.historyRows, key),
|
||||
itemBuilder: (_, index) => eventRow(
|
||||
scroll.historyRows[index],
|
||||
scroll.historyRows.getOrNull(index + 1),
|
||||
|
|
|
|||
Loading…
Reference in a new issue