Skip to content

Commit 229434a

Browse files
committed
sticky_header [nfc]: Expand on the header-overflows-sliver case
This case has several bugs in it. Not coincidentally, it's tricky to think through: there are several sub-cases and variables involved (the growth direction, vs. the header-placement direction, vs. the coordinate direction, ...). And in fact my original PR revision which fixed the cases that would affect the Zulip message list was still conceptually confused, as evidenced by the fact that it turned out to break other cases: #1316 (comment) One step in sorting that out was the preceding commit which split this overflows-sliver case from the alternative. As a next step, let's expand on the reasoning here a bit, with named variables and comments. In doing so, it becomes more apparent that several points in this calculation are wrong; for this NFC commit, mark those with TODO-comments. We'll fix them shortly.
1 parent 0ad4b07 commit 229434a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

lib/widgets/sticky_header.dart

+19-8
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,28 @@ class _RenderSliverStickyHeaderList extends RenderSliver with RenderSliverHelper
628628
// The header will overflow the child sliver.
629629
// That makes this sliver's geometry a bit more complicated.
630630

631+
// This sliver's paint region consists entirely of the header.
632+
final paintExtent = headerExtent;
633+
headerOffset = _headerAtCoordinateEnd()
634+
? childExtent - headerExtent // TODO buggy, should be zero
635+
: 0.0;
636+
637+
// Its layout region (affecting where the next sliver begins layout)
638+
// is that given by the child sliver.
639+
final layoutExtent = childExtent;
640+
641+
// The paint origin places this sliver's paint region relative to its
642+
// layout region.
643+
final paintOrigin = 0.0; // TODO buggy
644+
631645
geometry = SliverGeometry( // TODO review interaction with other slivers
632646
scrollExtent: geometry.scrollExtent,
633-
layoutExtent: childExtent,
634-
paintExtent: childExtent,
635-
maxPaintExtent: math.max(geometry.maxPaintExtent, headerExtent),
647+
layoutExtent: layoutExtent,
648+
paintExtent: childExtent, // TODO buggy
649+
paintOrigin: paintOrigin,
650+
maxPaintExtent: math.max(geometry.maxPaintExtent, paintExtent),
636651
hasVisualOverflow: geometry.hasVisualOverflow
637-
|| headerExtent > constraints.remainingPaintExtent,
652+
|| paintExtent > constraints.remainingPaintExtent,
638653

639654
// The cache extent is an extension of layout, not paint; it controls
640655
// where the next sliver should start laying out content. (See
@@ -643,10 +658,6 @@ class _RenderSliverStickyHeaderList extends RenderSliver with RenderSliverHelper
643658
// affect the cache extent.
644659
cacheExtent: geometry.cacheExtent,
645660
);
646-
647-
headerOffset = _headerAtCoordinateEnd()
648-
? childExtent - headerExtent
649-
: 0.0;
650661
}
651662
} else {
652663
// The header's item has [StickyHeaderItem.allowOverflow] false.

0 commit comments

Comments
 (0)