Skip to content
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

[Android] invalidate shadows on parent's size change #24561

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 16 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24034.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 24034, "Shadow is not updating on change of parent control", PlatformAffected.All)]
public partial class Issue24034 : ContentPage
{
public Issue24034()
{
InitializeComponent();
}

private void Button_Clicked(object sender, EventArgs e)
{
GridView.IsVisible = !GridView.IsVisible;
}
}
45 changes: 45 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24034.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue24034">
<Grid RowDefinitions="300,Auto" Margin="10" ColumnSpacing="0" Padding="5,0" ColumnDefinitions="*,*,Auto">

<Border
Grid.Column="0"
HeightRequest="150"
Grid.Row="0"
StrokeShape="RoundRectangle 16,16,16,16"
Margin="5,0">
<Border.Shadow>
<Shadow Brush="Red"
Offset="2,10"
Radius="{OnPlatform Android=9, iOS=12}"
Opacity="1" />
</Border.Shadow>
<BoxView BackgroundColor="Green"/>
</Border>

<Border
Grid.Column="1" Grid.Row="0"
HeightRequest="150"
StrokeShape="RoundRectangle 16,16,16,16"
Margin="5,0">
<Border.Shadow>
<Shadow Brush="Red"
Offset="2,10"
Radius="{OnPlatform Android=9, iOS=12}"
Opacity="1" />
</Border.Shadow>

<BoxView BackgroundColor="Green"/>
</Border>

<Grid x:Name="GridView" Margin="5,0"
Padding="0, 5, 0, 0"
Grid.Column="2">
<BoxView WidthRequest="100" Height="100"/>
</Grid>

<Button Grid.Row="1" Grid.ColumnSpan="3" AutomationId="button" Text="Click" Clicked="Button_Clicked"/>
</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue24034(TestDevice device) : _IssuesUITest(device)
{
public override string Issue => "Shadow is not updating on change of parent control";

[Test]
[Category(UITestCategories.Border)]
public void ShadowShouldUpdate()
{
App.WaitForElement("button");
App.Click("button");

VerifyScreenshot();
}
}
1 change: 1 addition & 0 deletions src/Core/src/Platform/Android/WrapperView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected override void OnLayout(bool changed, int left, int top, int right, int
var widthMeasureSpec = MeasureSpecMode.Exactly.MakeMeasureSpec(right - left);
var heightMeasureSpec = MeasureSpecMode.Exactly.MakeMeasureSpec(bottom - top);

_invalidateShadow = true;
mattleibow marked this conversation as resolved.
Show resolved Hide resolved
child.Measure(widthMeasureSpec, heightMeasureSpec);
child.Layout(0, 0, child.MeasuredWidth, child.MeasuredHeight);
_borderView?.Layout(0, 0, child.MeasuredWidth, child.MeasuredHeight);
Expand Down
Loading