Skip to content

Commit

Permalink
Revert "[iOS] Fixed HeaderFooterGrid to pass on CV1 and CV2 (#26022)"
Browse files Browse the repository at this point in the history
This reverts commit efa6895.
  • Loading branch information
rmarinho authored Dec 13, 2024
1 parent 2e8a193 commit 683ebc3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 41 deletions.
34 changes: 1 addition & 33 deletions src/Controls/src/Core/Handlers/Items/iOS/ItemsViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public abstract class ItemsViewController<TItemsView> : UICollectionViewControll
where TItemsView : ItemsView
{
public const int EmptyTag = 333;
const int HeaderTag = 111;
const int FooterTag = 222;
readonly WeakReference<TItemsView> _itemsView;

public IItemsViewSource ItemsSource { get; protected set; }
Expand Down Expand Up @@ -279,37 +277,7 @@ void InvalidateMeasureIfContentSizeChanged()
return _emptyUIView.Frame.Size.ToSize();
}

CGSize contentSize = CollectionView.CollectionViewLayout.CollectionViewContentSize;
CGSize headerSize = GetHeaderSize();
CGSize footerSize = GetFooterSize();

nfloat totalWidth = contentSize.Width;
nfloat totalHeight = contentSize.Height;

// Ensure calculating the total width or height, consider the boundary conditions to ensure it does not exceed the boundaries of the view.
// If it exceeds, the content becomes non-scrollable and is constrained to the view's screen size.
if (IsHorizontal)
{
totalWidth += headerSize.Width + footerSize.Width;
totalWidth = (nfloat)Math.Min(totalWidth, CollectionView.Bounds.Width);
}
else
{
totalHeight += headerSize.Height + footerSize.Height;
totalHeight = (nfloat)Math.Min(totalHeight, CollectionView.Bounds.Height);
}

return new Size(totalWidth, totalHeight);
}

CGSize GetHeaderSize()
{
return CollectionView.ViewWithTag(HeaderTag)?.Frame.Size ?? CGSize.Empty;
}

CGSize GetFooterSize()
{
return CollectionView.ViewWithTag(FooterTag)?.Frame.Size ?? CGSize.Empty;
return CollectionView.CollectionViewLayout.CollectionViewContentSize.ToSize();
}

void ConstrainItemsToBounds()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
<Button Text="Toggle Header" Clicked="ToggleHeader"></Button>
<Button Text="Toggle Footer" Clicked="ToggleFooter"></Button>
</StackLayout>
<CollectionView x:Name="CollectionView" Grid.Row="1" >
<CollectionView.ItemsLayout>
<local:CollectionView2 x:Name="CollectionView" Grid.Row="1" >
<local:CollectionView2.ItemsLayout>
<GridItemsLayout Span="3" Orientation="Vertical" HorizontalItemSpacing="4" VerticalItemSpacing="2"></GridItemsLayout>
</CollectionView.ItemsLayout>
<CollectionView.Header>
</local:CollectionView2.ItemsLayout>
<local:CollectionView2.Header>
<StackLayout BackgroundColor="Transparent">
<Image Source="oasis.jpg" Aspect="AspectFill" HeightRequest="60"></Image>
<Label Text="This Is A Header" TextColor="AntiqueWhite" HorizontalTextAlignment="Center"
FontAttributes="Bold" FontSize="36" />
<Button Text="Add Content" Clicked="AddContentClicked"></Button>
</StackLayout>
</CollectionView.Header>
<CollectionView.Footer>
</local:CollectionView2.Header>
<local:CollectionView2.Footer>
<StackLayout BackgroundColor="Transparent">
<Image Source="oasis.jpg" Aspect="AspectFill" HeightRequest="80"></Image>
<Label Text="This Is A Footer" TextColor="AntiqueWhite" HorizontalTextAlignment="Center" Rotation="10"
FontAttributes="Bold" FontSize="20" />
<Button Text="Add Content" Clicked="AddContentClicked"></Button>
</StackLayout>
</CollectionView.Footer>
</CollectionView>
</local:CollectionView2.Footer>
</local:CollectionView2>
</Grid>
</ContentPage.Content>
</ContentPage>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 683ebc3

Please sign in to comment.