Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Fix crash animation two times the Frame scale (#14606)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezruiz committed Nov 16, 2021
1 parent cc1d057 commit 2bdf498
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<local:TestContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Test 13236" xmlns:local="using:Xamarin.Forms.Controls"
x:Class="Xamarin.Forms.Controls.Issues.Issue13236">
<StackLayout>
<Label
Padding="12"
BackgroundColor="Black"
TextColor="White"
Text="Tap the button. Without exceptions, the test has passed."/>
<Frame
x:Name="TheFrame" BackgroundColor="#2196F3"
Padding="24" CornerRadius="0">
<Label
Text="Issue 13236" HorizontalTextAlignment="Center"
TextColor="White" FontSize="36"/>
</Frame>
<Button
Text="Animate"
Clicked="OnButtonClicked"/>
</StackLayout>
</local:TestContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 13236,
"[Bug] ScaleTo IllegalArgumentException (Android only)",
PlatformAffected.Android)]
public partial class Issue13236 : TestContentPage
{
public Issue13236()
{
#if APP
InitializeComponent();
#endif
}

protected override void Init()
{
}

#if APP
async void OnButtonClicked(System.Object sender, System.EventArgs e)
{
await TheFrame.ScaleTo(0.2, 0);
await TheFrame.ScaleTo(0.2, 0);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue11795.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14528.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14286.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13236.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue14613.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13930.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11211.xaml.cs" />
Expand Down Expand Up @@ -2284,6 +2285,9 @@
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue14286.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue13236.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue14613.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Expand Down
9 changes: 7 additions & 2 deletions Xamarin.Forms.Platform.Android/VisualElementTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,13 @@ void UpdateScale()
VisualElement view = _renderer.Element;
AView aview = _renderer.View;

aview.ScaleX = (float)view.Scale * (float)view.ScaleX;
aview.ScaleY = (float)view.Scale * (float)view.ScaleY;
var scale = view.Scale;

if (double.IsNaN(scale))
return;

aview.ScaleX = (float)scale * (float)view.ScaleX;
aview.ScaleY = (float)scale * (float)view.ScaleY;
}

void UpdateTranslationX()
Expand Down

0 comments on commit 2bdf498

Please sign in to comment.