Skip to content

Commit

Permalink
Update screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
albyrock87 committed Jan 9, 2025
1 parent 1702ea7 commit 87c5759
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 25 deletions.
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 @@ -5,7 +5,7 @@
Title="Issue24414">

<Grid RowDefinitions="Auto,*,*,*,*" ColumnDefinitions="*,*,*,*" RowSpacing="6" ColumnSpacing="6" Padding="16">
<Label x:Name="TheLabel" AutomationId="WaitForStubControl" Grid.ColumnSpan="4">
<Label x:Name="TheLabel" AutomationId="TheLabel" Grid.ColumnSpan="4">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="OnTapGestureRecognizerTapped"/>
</Label.GestureRecognizers>
Expand Down
16 changes: 8 additions & 8 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24414.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Maui.Controls.Sample.Issues;

public partial class Issue24414 : ContentPage
{
int fn = 0;
string[] labels = ["LLOHE WODRL", "OLLEH ORLWD", "LOHEL LODRW", "HELLO WORLD"];
int fn = 1;
string[] labels = ["HELLO WORLD", "LLOHE WODRL", "OLLEH ORLWD", "LOHEL LODRW"];

public Issue24414()
{
Expand All @@ -24,14 +24,14 @@ private void OnTapGestureRecognizerTapped(object sender, EventArgs e)
{
switch (fn)
{
case 0:
case 1:
border.WidthRequest += 4;
border.HeightRequest += 4;
break;
case 1:
case 2:
border.StrokeShape = new RoundRectangle { CornerRadius = border.WidthRequest };
break;
case 2:
case 3:
border.Shadow.Radius -= 8;
break;
}
Expand All @@ -51,9 +51,9 @@ void UpdateLabel()
{
TheLabel.Text = fn switch
{
0 => "Tap to resize the border",
1 => "Tap to change the border shape",
2 => "Tap to change the shadow radius",
1 => "Tap to resize the border",
2 => "Tap to change the border shape",
3 => "Tap to change the shadow radius",
_ => "Done"
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,34 @@ public Issue24414(TestDevice device)
[Category(UITestCategories.Visual)]
public void Issue24414Test()
{
App.WaitForElement("WaitForStubControl");
VerifyScreenshot();
var label = App.WaitForElement("TheLabel");
var ex = TryVerifyScreenshot();

for (int i = 1; i <= 3; i++)
{
label.Tap();
var exception = TryVerifyScreenshot("Issue24414Test_" + i);
ex ??= exception;
}

if (ex != null)
{
throw ex;
}
}

private Exception? TryVerifyScreenshot(string fileName)
{
try
{
App.Screenshot(fileName);
}
catch(Exception ex)
{
return ex;
}

return null;
}
}
}
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 @@ -182,9 +182,10 @@ protected void drawShadow(@NonNull Canvas canvas, int viewWidth, int viewHeight)
}

private void drawShadowViaPlatformShadowDrawable(@NonNull Canvas canvas, @NonNull PlatformShadowDrawable drawable, int viewWidth, int viewHeight) {
int bitmapWidth = viewWidth + (int)(radius * 2.5);
int bitmapHeight = viewHeight + (int)(radius * 2.5);

int radiusSafeSpace = getRadiusSafeSpace();
int bitmapWidth = viewWidth + radiusSafeSpace;
int bitmapHeight = viewHeight + radiusSafeSpace;

// Apply shader if needed
Shader shader = createShader(bitmapWidth, bitmapHeight);
if (shader != null) {
Expand All @@ -200,14 +201,9 @@ private void drawShadowViaPlatformShadowDrawable(@NonNull Canvas canvas, @NonNul
}

private void drawShadowViaDispatchDraw(@NonNull Canvas canvas, int viewWidth, int viewHeight) {
int radius = (int)this.radius;
// Give it a minimum additional space to draw shadow
if (radius <= 0) {
radius = 1;
}

int bitmapWidth = viewWidth + radius * 2;
int bitmapHeight = viewHeight + radius * 2;
int radiusSafeSpace = getRadiusSafeSpace();
int bitmapWidth = viewWidth + radiusSafeSpace;
int bitmapHeight = viewHeight + radiusSafeSpace;
int drawOriginX = (bitmapWidth - viewWidth) / 2;
int drawOriginY = (bitmapHeight - viewHeight) / 2;

Expand Down Expand Up @@ -235,16 +231,16 @@ private void drawShadowViaDispatchDraw(@NonNull Canvas canvas, int viewWidth, in

// Get the alpha bounds of bitmap
Bitmap extractAlpha = shadowBitmap.extractAlpha();

// Clear the shadow canvas
shadowCanvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR);

// Apply shader if needed
Shader shader = createShader(bitmapWidth, bitmapHeight);
if (shader != null) {
shadowPaint.setShader(shader);
}

shadowCanvas.drawBitmap(extractAlpha, 0, 0, shadowPaint);

extractAlpha.recycle();
Expand All @@ -254,6 +250,14 @@ private void drawShadowViaDispatchDraw(@NonNull Canvas canvas, int viewWidth, in
canvas.drawBitmap(shadowBitmap, offsetX - drawOriginX, offsetY - drawOriginY, null);
}

private int getRadiusSafeSpace() {
if (radius <= 0) {
return 4;
}

return (int)(radius * 3);
}

private Shader createShader(int bitmapWidth, int bitmapHeight) {
Shader shader = null;

Expand Down
Binary file modified src/Core/src/maui.aar
Binary file not shown.

0 comments on commit 87c5759

Please sign in to comment.