From ea2b5e6ac893fb3d5440a534eda7807e1ab4005d Mon Sep 17 00:00:00 2001 From: NanthiniMahalingam <105482474+NanthiniMahalingam@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:14:25 +0530 Subject: [PATCH 1/8] Fixed the header view cropping issue when resizing the mac windows --- .../StructuredItemsViewController.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs index c0362cb6e46d..81bd6ab3bfe8 100644 --- a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs +++ b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs @@ -79,6 +79,23 @@ public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); + if (_headerUIView is not null) + { + var emptyView = CollectionView.ViewWithTag(EmptyTag); + if (IsHorizontal) + { + if (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || + _headerUIView.Frame.X < emptyView?.Frame.X) + UpdateHeaderFooterPosition(); + } + else + { + if (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || + _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)) + UpdateHeaderFooterPosition(); + } + } + // This update is only relevant if you have a footer view because it's used to place the footer view // based on the ContentSize so we just update the positions if the ContentSize has changed if (_footerUIView != null) From 1dbc2b403d6039ff5e1d9837f3a52039acf43afc Mon Sep 17 00:00:00 2001 From: NanthiniMahalingam <105482474+NanthiniMahalingam@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:26:38 +0530 Subject: [PATCH 2/8] Updated the header fix and added fix for footer issue --- .../StructuredItemsViewController.cs | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs index 81bd6ab3bfe8..83f473e73d6e 100644 --- a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs +++ b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs @@ -78,41 +78,24 @@ protected override CGRect DetermineEmptyViewFrame() public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); - - if (_headerUIView is not null) - { - var emptyView = CollectionView.ViewWithTag(EmptyTag); - if (IsHorizontal) - { - if (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || - _headerUIView.Frame.X < emptyView?.Frame.X) - UpdateHeaderFooterPosition(); - } - else - { - if (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || - _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)) - UpdateHeaderFooterPosition(); - } - } - - // This update is only relevant if you have a footer view because it's used to place the footer view - // based on the ContentSize so we just update the positions if the ContentSize has changed - if (_footerUIView != null) + // This updates the positions of the header view and footer view as their sizes change dynamically + if (_headerUIView is not null || _footerUIView is not null) { var emptyView = CollectionView.ViewWithTag(EmptyTag); if (IsHorizontal) { - if (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || - _footerUIView.Frame.X < emptyView?.Frame.X) + if ((_headerUIView is not null && (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _headerUIView.Frame.X < emptyView?.Frame.X)) || (_footerUIView is not null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || _footerUIView.Frame.X < emptyView?.Frame.X))) + { UpdateHeaderFooterPosition(); + } } else { - if (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || - _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)) + if ((_headerUIView is not null && (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height))) || (_footerUIView is not null && (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _footerUIView.Frame.Y != _footerUIView.Frame.Height || _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)))) + { UpdateHeaderFooterPosition(); + } } } } @@ -178,7 +161,7 @@ void UpdateHeaderFooterPosition() if (_headerUIView != null && _headerUIView.Frame.X != headerWidth) _headerUIView.Frame = new CoreGraphics.CGRect(-headerWidth, 0, headerWidth, CollectionView.Frame.Height); - if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || emptyWidth > 0)) + if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || emptyWidth > 0)) _footerUIView.Frame = new CoreGraphics.CGRect(ItemsViewLayout.CollectionViewContentSize.Width + emptyWidth, 0, footerWidth, CollectionView.Frame.Height); if (CollectionView.ContentInset.Left != headerWidth || CollectionView.ContentInset.Right != footerWidth) @@ -231,7 +214,7 @@ void UpdateHeaderFooterPosition() height = ItemsViewLayout.CollectionViewContentSize.Height; } - if (_footerUIView != null && (_footerUIView.Frame.Y != height || emptyHeight > 0)) + if (_footerUIView != null && (_footerUIView.Frame.Y != height || _footerUIView.Frame.Y != _footerUIView.Frame.Heigh || emptyHeight > 0)) { _footerUIView.Frame = new CoreGraphics.CGRect(0, height + emptyHeight, CollectionView.Frame.Width, footerHeight); } From 25df5993f10d03c32da47bb7067145334928b4ff Mon Sep 17 00:00:00 2001 From: NanthiniMahalingam <105482474+NanthiniMahalingam@users.noreply.github.com> Date: Fri, 3 Jan 2025 16:44:26 +0530 Subject: [PATCH 3/8] Optimized the fix code section --- .../StructuredItemsViewController.cs | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs index 83f473e73d6e..7716cd179980 100644 --- a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs +++ b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs @@ -79,23 +79,20 @@ public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); // This updates the positions of the header view and footer view as their sizes change dynamically - if (_headerUIView is not null || _footerUIView is not null) - { - var emptyView = CollectionView.ViewWithTag(EmptyTag); + var emptyView = CollectionView.ViewWithTag(EmptyTag); - if (IsHorizontal) + if (IsHorizontal) + { + if ((_headerUIView is not null && (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _headerUIView.Frame.X < emptyView?.Frame.X)) || (_footerUIView is not null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || _footerUIView.Frame.X < emptyView?.Frame.X))) { - if ((_headerUIView is not null && (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _headerUIView.Frame.X < emptyView?.Frame.X)) || (_footerUIView is not null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || _footerUIView.Frame.X < emptyView?.Frame.X))) - { - UpdateHeaderFooterPosition(); - } + UpdateHeaderFooterPosition(); } - else + } + else + { + if ((_headerUIView is not null && (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height))) || (_footerUIView is not null && (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _footerUIView.Frame.Y != _footerUIView.Frame.Height || _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)))) { - if ((_headerUIView is not null && (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height))) || (_footerUIView is not null && (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _footerUIView.Frame.Y != _footerUIView.Frame.Height || _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)))) - { - UpdateHeaderFooterPosition(); - } + UpdateHeaderFooterPosition(); } } } @@ -161,7 +158,7 @@ void UpdateHeaderFooterPosition() if (_headerUIView != null && _headerUIView.Frame.X != headerWidth) _headerUIView.Frame = new CoreGraphics.CGRect(-headerWidth, 0, headerWidth, CollectionView.Frame.Height); - if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || emptyWidth > 0)) + if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != footerWidth || emptyWidth > 0)) _footerUIView.Frame = new CoreGraphics.CGRect(ItemsViewLayout.CollectionViewContentSize.Width + emptyWidth, 0, footerWidth, CollectionView.Frame.Height); if (CollectionView.ContentInset.Left != headerWidth || CollectionView.ContentInset.Right != footerWidth) @@ -214,7 +211,7 @@ void UpdateHeaderFooterPosition() height = ItemsViewLayout.CollectionViewContentSize.Height; } - if (_footerUIView != null && (_footerUIView.Frame.Y != height || _footerUIView.Frame.Y != _footerUIView.Frame.Heigh || emptyHeight > 0)) + if (_footerUIView != null && (_footerUIView.Frame.Y != height || _footerUIView.Frame.Y != footerHeight || emptyHeight > 0)) { _footerUIView.Frame = new CoreGraphics.CGRect(0, height + emptyHeight, CollectionView.Frame.Width, footerHeight); } From 6369698aab07ef7fca5a3dba959ab2b88a8db691 Mon Sep 17 00:00:00 2001 From: NanthiniMahalingam <105482474+NanthiniMahalingam@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:34:09 +0530 Subject: [PATCH 4/8] Removed unwanted code section --- .../StructuredItemsViewController.cs | 27 ++++++++++--------- .../iOS/StructuredItemsViewController.cs | 27 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs index 7716cd179980..c0362cb6e46d 100644 --- a/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs +++ b/src/Compatibility/Core/src/iOS/CollectionView/StructuredItemsViewController.cs @@ -78,21 +78,24 @@ protected override CGRect DetermineEmptyViewFrame() public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); - // This updates the positions of the header view and footer view as their sizes change dynamically - var emptyView = CollectionView.ViewWithTag(EmptyTag); - if (IsHorizontal) + // This update is only relevant if you have a footer view because it's used to place the footer view + // based on the ContentSize so we just update the positions if the ContentSize has changed + if (_footerUIView != null) { - if ((_headerUIView is not null && (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _headerUIView.Frame.X < emptyView?.Frame.X)) || (_footerUIView is not null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || _footerUIView.Frame.X < emptyView?.Frame.X))) + var emptyView = CollectionView.ViewWithTag(EmptyTag); + + if (IsHorizontal) { - UpdateHeaderFooterPosition(); + if (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || + _footerUIView.Frame.X < emptyView?.Frame.X) + UpdateHeaderFooterPosition(); } - } - else - { - if ((_headerUIView is not null && (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height))) || (_footerUIView is not null && (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _footerUIView.Frame.Y != _footerUIView.Frame.Height || _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)))) + else { - UpdateHeaderFooterPosition(); + if (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || + _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)) + UpdateHeaderFooterPosition(); } } } @@ -158,7 +161,7 @@ void UpdateHeaderFooterPosition() if (_headerUIView != null && _headerUIView.Frame.X != headerWidth) _headerUIView.Frame = new CoreGraphics.CGRect(-headerWidth, 0, headerWidth, CollectionView.Frame.Height); - if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != footerWidth || emptyWidth > 0)) + if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || emptyWidth > 0)) _footerUIView.Frame = new CoreGraphics.CGRect(ItemsViewLayout.CollectionViewContentSize.Width + emptyWidth, 0, footerWidth, CollectionView.Frame.Height); if (CollectionView.ContentInset.Left != headerWidth || CollectionView.ContentInset.Right != footerWidth) @@ -211,7 +214,7 @@ void UpdateHeaderFooterPosition() height = ItemsViewLayout.CollectionViewContentSize.Height; } - if (_footerUIView != null && (_footerUIView.Frame.Y != height || _footerUIView.Frame.Y != footerHeight || emptyHeight > 0)) + if (_footerUIView != null && (_footerUIView.Frame.Y != height || emptyHeight > 0)) { _footerUIView.Frame = new CoreGraphics.CGRect(0, height + emptyHeight, CollectionView.Frame.Width, footerHeight); } diff --git a/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs index 3d9ef7689442..b8965b8094ea 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/StructuredItemsViewController.cs @@ -101,24 +101,21 @@ protected override CGRect DetermineEmptyViewFrame() public override void ViewWillLayoutSubviews() { base.ViewWillLayoutSubviews(); + // This updates the positions of the header view and footer view as their sizes change dynamically + var emptyView = CollectionView.ViewWithTag(EmptyTag); - // This update is only relevant if you have a footer view because it's used to place the footer view - // based on the ContentSize so we just update the positions if the ContentSize has changed - if (_footerUIView != null) + if (IsHorizontal) { - var emptyView = CollectionView.ViewWithTag(EmptyTag); - - if (IsHorizontal) + if ((_headerUIView is not null && (_headerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _headerUIView.Frame.X < emptyView?.Frame.X)) || (_footerUIView is not null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != _footerUIView.Frame.Width || _footerUIView.Frame.X < emptyView?.Frame.X))) { - if (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || - _footerUIView.Frame.X < emptyView?.Frame.X) - UpdateHeaderFooterPosition(); + UpdateHeaderFooterPosition(); } - else + } + else + { + if ((_headerUIView is not null && (_headerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _headerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height))) || (_footerUIView is not null && (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || _footerUIView.Frame.Y != _footerUIView.Frame.Height || _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)))) { - if (_footerUIView.Frame.Y != ItemsViewLayout.CollectionViewContentSize.Height || - _footerUIView.Frame.Y < (emptyView?.Frame.Y + emptyView?.Frame.Height)) - UpdateHeaderFooterPosition(); + UpdateHeaderFooterPosition(); } } } @@ -209,7 +206,7 @@ void UpdateHeaderFooterPosition() _headerUIView.Frame = new CoreGraphics.CGRect(-headerWidth, 0, headerWidth, CollectionView.Frame.Height); } - if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || emptyWidth > 0)) + if (_footerUIView != null && (_footerUIView.Frame.X != ItemsViewLayout.CollectionViewContentSize.Width || _footerUIView.Frame.X != footerWidth || emptyWidth > 0)) _footerUIView.Frame = new CoreGraphics.CGRect(ItemsViewLayout.CollectionViewContentSize.Width + emptyWidth, 0, footerWidth, CollectionView.Frame.Height); if (CollectionView.ContentInset.Left != headerWidth || CollectionView.ContentInset.Right != footerWidth) @@ -262,7 +259,7 @@ void UpdateHeaderFooterPosition() height = ItemsViewLayout.CollectionViewContentSize.Height; } - if (_footerUIView != null && (_footerUIView.Frame.Y != height || emptyHeight > 0)) + if (_footerUIView != null && (_footerUIView.Frame.Y != height || _footerUIView.Frame.Y != footerHeight || emptyHeight > 0)) { _footerUIView.Frame = new CoreGraphics.CGRect(0, height + emptyHeight, CollectionView.Frame.Width, footerHeight); } From 482bb96baf2ff1ef6c6e5ba9c444f71749dde4bb Mon Sep 17 00:00:00 2001 From: NanthiniMahalingam <105482474+NanthiniMahalingam@users.noreply.github.com> Date: Fri, 3 Jan 2025 19:18:16 +0530 Subject: [PATCH 5/8] Added the test cases --- .../TestCases.HostApp/Issues/Issue26186.xaml | 92 +++++++++++++++++++ .../Issues/Issue26186.xaml.cs | 15 +++ .../Tests/Issues/Issue26186.cs | 19 ++++ 3 files changed, 126 insertions(+) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue26186.xaml create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue26186.xaml.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26186.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue26186.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue26186.xaml new file mode 100644 index 000000000000..93d00483212a --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue26186.xaml @@ -0,0 +1,92 @@ + + + +