Skip to content

[2025/05/12] Candidate - In Flight Branch #29335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@
</Setter>
</Style>

<Style TargetType="Frame">
<Setter Property="HasShadow" Value="False" />
<Setter Property="BorderColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
<Setter Property="CornerRadius" Value="8" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
</Style>

<Style TargetType="ImageButton">
<Setter Property="Opacity" Value="1" />
<Setter Property="BorderColor" Value="Transparent"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PhoneFlyoutPageRenderer : UIViewController, IPlatformViewHandler
{
UIView _clickOffView;
UIViewController _detailController;
VisualElement _element;
WeakReference<VisualElement> _element;
bool _disposed;

UIViewController _flyoutController;
Expand Down Expand Up @@ -75,7 +75,7 @@ bool Presented
get { return _presented; }
}

public VisualElement Element => _viewHandlerWrapper.Element ?? _element;
public VisualElement Element => _viewHandlerWrapper.Element ?? _element?.GetTargetOrDefault();

public event EventHandler<VisualElementChangedEventArgs> ElementChanged;

Expand All @@ -100,7 +100,7 @@ public void SetElement(VisualElement element)
_clickOffView = new UIView();
_clickOffView.BackgroundColor = new Color(0, 0, 0, 0).ToPlatform();
_viewHandlerWrapper.SetVirtualView(element, OnElementChanged, false);
_element = element;
_element = new(element);

if (_intialLayoutFinished)
{
Expand Down Expand Up @@ -269,9 +269,7 @@ protected override void Dispose(bool disposing)
}

EmptyContainers();

Page.SendDisappearing();

_element = null;
_disposed = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ internal void UpdateEmptyViewVisibility()
SwapAdapter(_emptyViewAdapter, true);

// TODO hartez 2018/10/24 17:34:36 If this works, cache this layout manager as _emptyLayoutManager
SetLayoutManager(new LinearLayoutManager(Context));
SetLayoutManager(SelectLayoutManager(ItemsLayout));
UpdateEmptyView();
}
else if (!showEmptyView && currentAdapter != ItemsViewAdapter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ void UpdateIsSwipeEnabled()
{
case ItemsLayoutOrientation.Horizontal:
ScrollViewer.SetHorizontalScrollMode(ListViewBase, ItemsView.IsSwipeEnabled ? WScrollMode.Auto : WScrollMode.Disabled);
ScrollViewer.SetHorizontalScrollBarVisibility(ListViewBase, ItemsView.IsSwipeEnabled ? WScrollBarVisibility.Auto : WScrollBarVisibility.Disabled);
ScrollViewer.SetHorizontalScrollBarVisibility(ListViewBase, ItemsView.IsSwipeEnabled ? WScrollBarVisibility.Auto : WScrollBarVisibility.Hidden);
break;
case ItemsLayoutOrientation.Vertical:
ScrollViewer.SetVerticalScrollMode(ListViewBase, ItemsView.IsSwipeEnabled ? WScrollMode.Auto : WScrollMode.Disabled);
ScrollViewer.SetVerticalScrollBarVisibility(ListViewBase, ItemsView.IsSwipeEnabled ? WScrollBarVisibility.Auto : WScrollBarVisibility.Disabled);
ScrollViewer.SetVerticalScrollBarVisibility(ListViewBase, ItemsView.IsSwipeEnabled ? WScrollBarVisibility.Auto : WScrollBarVisibility.Hidden);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,11 @@ void TearDownEmptyView()
_emptyViewFormsElement = null;
}

void LayoutEmptyView()
virtual internal CGRect LayoutEmptyView()
{
if (!_initialized || _emptyUIView == null || _emptyUIView.Superview == null)
{
return;
return CGRect.Empty;
}

var frame = DetermineEmptyViewFrame();
Expand All @@ -577,6 +577,8 @@ void LayoutEmptyView()

if (_emptyViewFormsElement != null && ((IElementController)ItemsView).LogicalChildren.IndexOf(_emptyViewFormsElement) != -1)
_emptyViewFormsElement.Layout(frame.ToRectangle());

return frame;
}

internal protected virtual void UpdateVisibility()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ void UpdateDefaultSupplementaryView(DefaultCell2 cell, NSString elementKind)
: ItemsView.Footer;

cell.Label.Text = obj?.ToString();
cell.Tag = elementKind == UICollectionElementKindSectionKey.Header
? HeaderTag
: FooterTag;
}

void UpdateTemplatedSupplementaryView(TemplatedCell2 cell, NSString elementKind)
Expand Down Expand Up @@ -157,6 +160,21 @@ string DetermineViewReuseId(DataTemplate template, object item)
? HorizontalSupplementaryView2.ReuseId
: VerticalSupplementaryView2.ReuseId;
}
internal override CGRect LayoutEmptyView()
{
var emptyViewFrame = base.LayoutEmptyView();
var footerView = CollectionView.ViewWithTag(FooterTag);

if (footerView is not null)
{
if (emptyViewFrame.Height > 0)
footerView.Frame = new CGRect(footerView.Frame.X, emptyViewFrame.Bottom, footerView.Frame.Width, footerView.Frame.Height);
else
footerView.Frame = new CGRect(footerView.Frame.X, CollectionView.ContentSize.Height - footerView.Frame.Height, footerView.Frame.Width, footerView.Frame.Height);
}

return emptyViewFrame;
}

protected override CGRect DetermineEmptyViewFrame()
{
Expand All @@ -172,8 +190,8 @@ protected override CGRect DetermineEmptyViewFrame()
if (footerView != null)
footerHeight = footerView.Frame.Height;

return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y, CollectionView.Frame.Width,
Math.Abs(CollectionView.Frame.Height - (headerHeight + footerHeight)));
return new CGRect(CollectionView.Frame.X, CollectionView.Frame.Y + headerHeight, CollectionView.Frame.Width,
Math.Abs(CollectionView.Frame.Height - (headerHeight + footerHeight)));
}

public override void ViewWillLayoutSubviews()
Expand Down
6 changes: 3 additions & 3 deletions src/Controls/src/Core/Label/Label.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected override Size ArrangeOverride(Rect bounds)
{
var size = base.ArrangeOverride(bounds);

RecalculateSpanPositions();
RecalculateSpanPositions(size);

return size;
}
Expand Down Expand Up @@ -51,14 +51,14 @@ static void MapFormatting(ILabelHandler handler, Label label)
LabelHandler.MapFormatting(handler, label);
}

void RecalculateSpanPositions()
void RecalculateSpanPositions(Size size)
{
if (Handler is LabelHandler labelHandler)
{
if (labelHandler.PlatformView is not UILabel platformView || labelHandler.VirtualView is not Label virtualView)
return;

platformView.RecalculateSpanPositions(virtualView);
platformView.RecalculateSpanPositions(virtualView, size);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public static NSAttributedString ToNSAttributedString(
return attrString;
}

internal static void RecalculateSpanPositions(this UILabel control, Label element)
internal static void RecalculateSpanPositions(this UILabel control, Label element, Size size)
{
if (element is null)
{
Expand All @@ -149,7 +149,7 @@ internal static void RecalculateSpanPositions(this UILabel control, Label elemen
return;
}

var finalSize = control.Bounds;
var finalSize = size;

if (finalSize.Width <= 0 || finalSize.Height <= 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,39 @@ await CreateHandlerAndAddToWindow<FlyoutViewHandler>(flyoutPage, async (handler)
});
}

[Fact(DisplayName = "FlyoutPage as Modal Does Not Leak")]
public async Task DoesNotLeakAsModal()
{
SetupBuilder();

var references = new List<WeakReference>();
var launcherPage = new ContentPage();
var window = new Window(launcherPage);

await CreateHandlerAndAddToWindow<WindowHandlerStub>(window, async handler =>
{
var flyoutPage = new FlyoutPage
{
Flyout = new ContentPage
{
Title = "Flyout",
IconImageSource = "icon.png"
},
Detail = new ContentPage { Title = "Detail" }
};

await launcherPage.Navigation.PushModalAsync(flyoutPage, true);

references.Add(new WeakReference(flyoutPage));
references.Add(new WeakReference(flyoutPage.Flyout));
references.Add(new WeakReference(flyoutPage.Detail));

await launcherPage.Navigation.PopModalAsync();
});

await AssertionExtensions.WaitForGC(references.ToArray());
}

bool CanDeviceDoSplitMode(FlyoutPage page)
{
return ((IFlyoutPageController)page).ShouldShowSplitMode;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@
HorizontalOptions="Center"
AutomationId="ScrollingButton"
WidthRequest="400"/>
<Button Text="Selection FeaturePage"
Clicked="OnSelectionButtonClicked"
HorizontalOptions="Center"
AutomationId="SelectionPageButton"
WidthRequest="400"/>
</VerticalStackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ private async void OnScrollingButtonClicked(object sender, EventArgs e)
await Navigation.PushAsync(new CollectionViewScrollPage());
}

private async void OnSelectionButtonClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new CollectionViewSelectionPage());
}

}
Loading
Loading