Skip to content

Commit

Permalink
chore: Try to fix flipview....
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Oct 12, 2024
1 parent 4263d3f commit 2ae5528
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/FlipView/PagedCollectionView.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ public override void SetNeedsLayout()
Superview?.SetNeedsLayout();
}

public override CGSize SizeThatFits(CGSize size)
{
var desiredSize = base.SizeThatFits(size);
foreach (var cell in VisibleCells)
{
_ = cell.SizeThatFits(desiredSize);
}

return desiredSize;
}

public UICollectionViewScrollDirection Orientation
{
get { return _layout.ScrollDirection; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ internal class InternalContainer : UICollectionViewCell
/// </remarks>
public InternalContainer(NativeHandle handle) : base(handle) { }

private CGSize _lastUsedSize;
//private CGSize _lastUsedSize;

Check warning on line 613 in src/Uno.UI/UI/Xaml/Controls/ListViewBase/Legacy/ListViewBaseSource.Legacy.iOS.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/UI/Xaml/Controls/ListViewBase/Legacy/ListViewBaseSource.Legacy.iOS.cs#L613

Remove this commented out code.

protected override void Dispose(bool disposing)
{
Expand All @@ -635,6 +635,34 @@ protected override void Dispose(bool disposing)
}
}

public override void SetNeedsLayout()
{
base.SetNeedsLayout();
Superview?.SetNeedsLayout();
}

public override CGSize SizeThatFits(CGSize size)
{
var content = Content;
if (content is null)
{
return base.SizeThatFits(size);
}

content.Measure(size);
return content.DesiredSize;
}

public override CGRect Frame
{
get => base.Frame;
set
{
base.Frame = value;
Content?.Arrange(value);
}
}

public ContentControl Content
{
get
Expand All @@ -648,27 +676,28 @@ public ContentControl Content
ContentView.Subviews[0].RemoveFromSuperview();
}

value.Frame = ContentView.Bounds;
value.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
//value.Frame = ContentView.Bounds;

Check warning on line 679 in src/Uno.UI/UI/Xaml/Controls/ListViewBase/Legacy/ListViewBaseSource.Legacy.iOS.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/UI/Xaml/Controls/ListViewBase/Legacy/ListViewBaseSource.Legacy.iOS.cs#L679

Remove this commented out code.
//value.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

ContentView.AddSubview(value);
value.InvalidateMeasure();
}
}

public override void ApplyLayoutAttributes(UICollectionViewLayoutAttributes layoutAttributes)
{
// We don't call base because it adds unnecessary interop. From the doc: "The default implementation of this method does nothing." https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionReusableView_class/#//apple_ref/occ/instm/UICollectionReusableView/applyLayoutAttributes:
//base.ApplyLayoutAttributes(layoutAttributes);

var size = layoutAttributes.Frame.Size;
// If frame size has changed, call SizeThatFits on item content. This allows views that expect a measure prior to an arrange (eg StackPanel, StarStackPanel)
// to be laid out correctly.
if (size != _lastUsedSize)
{
Content?.SizeThatFits(size);
_lastUsedSize = size;
}
}
//public override void ApplyLayoutAttributes(UICollectionViewLayoutAttributes layoutAttributes)
//{

Check warning on line 688 in src/Uno.UI/UI/Xaml/Controls/ListViewBase/Legacy/ListViewBaseSource.Legacy.iOS.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/UI/Xaml/Controls/ListViewBase/Legacy/ListViewBaseSource.Legacy.iOS.cs#L688

Remove this commented out code.
// // We don't call base because it adds unnecessary interop. From the doc: "The default implementation of this method does nothing." https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionReusableView_class/#//apple_ref/occ/instm/UICollectionReusableView/applyLayoutAttributes:
// //base.ApplyLayoutAttributes(layoutAttributes);

// var size = layoutAttributes.Frame.Size;
// // If frame size has changed, call SizeThatFits on item content. This allows views that expect a measure prior to an arrange (eg StackPanel, StarStackPanel)
// // to be laid out correctly.
// if (size != _lastUsedSize)
// {
// Content?.SizeThatFits(size);
// _lastUsedSize = size;
// }
//}
}
}
}
Expand Down

0 comments on commit 2ae5528

Please sign in to comment.