Skip to content
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 @@ -558,6 +558,8 @@ internal sealed class Container : ViewGroup
{
IPlatformViewHandler _child;

AView _platformView => _child?.ToPlatform() ?? _child?.PlatformView;

public Container(Context context) : base(context)
{
}
Expand All @@ -567,35 +569,35 @@ public IPlatformViewHandler Child
set
{
if (_child != null)
RemoveView(_child.PlatformView);
RemoveView(_platformView);

_child = value;

if (value != null)
AddView(value.PlatformView);
AddView(_platformView);
}
}

protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
if (_child?.PlatformView == null)
if (_platformView == null)
{
return;
}

_child.PlatformView.Layout(0, 0, r - l, b - t);
_platformView.Layout(0, 0, r - l, b - t);
}

protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
if (_child?.PlatformView == null)
if (_platformView == null)
{
SetMeasuredDimension(0, 0);
return;
}

_child.PlatformView.Measure(widthMeasureSpec, heightMeasureSpec);
SetMeasuredDimension(_child.PlatformView.MeasuredWidth, _child.PlatformView.MeasuredHeight);
_platformView.Measure(widthMeasureSpec, heightMeasureSpec);
SetMeasuredDimension(_platformView.MeasuredWidth, _platformView.MeasuredHeight);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ void UpdateFooterMeasure()

var size = _footerRenderer.VirtualView.Measure(Bounds.Width, double.PositiveInfinity);
var platformFrame = new RectangleF(0, 0, size.Width, size.Height);
_footerRenderer.PlatformView.Frame = platformFrame;
_footerRenderer.ToPlatform().Frame = platformFrame;
_footerRenderer.VirtualView.Arrange(platformFrame.ToRectangle());
Control.TableFooterView = _footerRenderer.PlatformView;
Control.TableFooterView = _footerRenderer.ToPlatform();

BeginInvokeOnMainThread(() =>
{
if (_footerRenderer != null)
Control.TableFooterView = _footerRenderer.PlatformView;
Control.TableFooterView = _footerRenderer.ToPlatform();
});
}

Expand All @@ -380,9 +380,9 @@ void UpdateHeaderMeasure()

var size = _headerRenderer.VirtualView.Measure(Bounds.Width, double.PositiveInfinity);
var platformFrame = new RectangleF(0, 0, size.Width, size.Height);
_headerRenderer.PlatformView.Frame = platformFrame;
_headerRenderer.ToPlatform().Frame = platformFrame;
_headerRenderer.VirtualView.Arrange(platformFrame.ToRectangle());
Control.TableHeaderView = _headerRenderer.PlatformView;
Control.TableHeaderView = _headerRenderer.ToPlatform();

// Time for another story with Jason. Gather round children because the following Math.Ceiling will look like it's completely useless.
// You will remove it and test and find everything is fiiiiiine, but it is not fine, no it is far from fine. See iOS, or at least iOS 8
Expand All @@ -395,7 +395,7 @@ void UpdateHeaderMeasure()
BeginInvokeOnMainThread(() =>
{
if (_headerRenderer != null)
Control.TableHeaderView = _headerRenderer.PlatformView;
Control.TableHeaderView = _headerRenderer.ToPlatform();
});
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26636.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns:controls="clr-namespace:Maui.Controls.Sample.Issues"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue26636">
<StackLayout>
<ListView
VerticalOptions="Center"
HeightRequest="300">
<ListView.Header>
<Label
FontSize="16"
AutomationId="HeaderLabel"
HorizontalTextAlignment="Center"
Text="(Header) This is a border with shadows">
<Label.Background>
<LinearGradientBrush
StartPoint="0, 0"
EndPoint="1, 1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#8A2387"
Offset="0.1"/>
<GradientStop Color="#E94057"
Offset="0.6"/>
<GradientStop Color="#F27121"
Offset="1.0"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Label.Background>
</Label>
</ListView.Header>
<ListView.Footer>
<Label
FontSize="16"
HorizontalTextAlignment="Center"
Text="(Footer) This is a label with shadows">
<Label.Shadow>
<Shadow
Brush="Green"
Radius="4"
Offset="0,4"/>
</Label.Shadow>
</Label>
</ListView.Footer>
</ListView>
</StackLayout>
</ContentPage>
12 changes: 12 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue26636.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Maui.Controls.Sample.Issues
{

[Issue(IssueTracker.Github, 26636, "Shadows & Gradients don't work with a list view's header/footer", PlatformAffected.Android | PlatformAffected.iOS)]
public partial class Issue26636 : ContentPage
{
public Issue26636()
{
InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#if ANDROID || IOS
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue26636 : _IssuesUITest
{
public Issue26636(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "Shadows & Gradients don't work with a list view's header/footer";

[Test]
[Category(UITestCategories.ListView)]
public void GradientAndShadowShouldWork()
{
App.WaitForElement("HeaderLabel");
VerifyScreenshot();
}
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.