Change `SectionsContainer` to use flowing children for section update logic

This commit is contained in:
Dean Herbert 2022-12-07 16:30:15 +09:00
parent d8d25c704f
commit 0497e433b1
1 changed files with 4 additions and 2 deletions

View File

@ -240,7 +240,9 @@ protected override void UpdateAfterChildren()
headerBackgroundContainer.Height = expandableHeaderSize + fixedHeaderSize; headerBackgroundContainer.Height = expandableHeaderSize + fixedHeaderSize;
headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0; headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0;
float smallestSectionHeight = Children.Count > 0 ? Children.Min(d => d.Height) : 0; var flowChildren = scrollContentContainer.FlowingChildren.OfType<T>();
float smallestSectionHeight = flowChildren.Any() ? flowChildren.Min(d => d.Height) : 0;
// scroll offset is our fixed header height if we have it plus 10% of content height // scroll offset is our fixed header height if we have it plus 10% of content height
// plus 5% to fix floating point errors and to not have a section instantly unselect when scrolling upwards // plus 5% to fix floating point errors and to not have a section instantly unselect when scrolling upwards
@ -249,7 +251,7 @@ protected override void UpdateAfterChildren()
float scrollCentre = fixedHeaderSize + scrollContainer.DisplayableContent * scroll_y_centre + selectionLenienceAboveSection; float scrollCentre = fixedHeaderSize + scrollContainer.DisplayableContent * scroll_y_centre + selectionLenienceAboveSection;
var presentChildren = Children.Where(c => c.IsPresent); var presentChildren = flowChildren.Where(c => c.IsPresent);
if (lastClickedSection != null) if (lastClickedSection != null)
SelectedSection.Value = lastClickedSection; SelectedSection.Value = lastClickedSection;