Merge branch '4.2.0' into 4.3.0

This commit is contained in:
Stephane Delcroix 2019-10-07 11:54:46 +02:00
Родитель 32cb21ae0d 7e136aef4a
Коммит 5d1ef547f0
5 изменённых файлов: 152 добавлений и 6 удалений

Просмотреть файл

@ -0,0 +1,59 @@
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 5395, "[macOs] Image Rotation issue", PlatformAffected.macOS)]
public class Issue5395 : ContentPage
{
public Issue5395()
{
var sl = new StackLayout() { Orientation = StackOrientation.Vertical };
sl.Children.Add(new Label() { Text = "Image should rotate clockwise around its center" });
sl.Children.Add(new TestImage(0.5, 0.5, true, false));
sl.Children.Add(new Label() { Text = "Image should rotate clockwise around its top left corner" });
sl.Children.Add(new TestImage(0, 0, true, false));
sl.Children.Add(new Label() { Text = "Image should rotate clockwise around its top right corner" });
sl.Children.Add(new TestImage(1, 0, true, false));
sl.Children.Add(new Label() { Text = "Image should rotate clockwise around its bottom right corner" });
sl.Children.Add(new TestImage(1, 1, true, false));
sl.Children.Add(new Label() { Text = "Image should scale on its center" });
sl.Children.Add(new TestImage(0.5, 0.5, false, true));
Content = sl;
}
class TestImage : Image
{
public TestImage(double anchorx, double anchory, bool rotate, bool scale)
{
VerticalOptions = HorizontalOptions = LayoutOptions.Center;
Aspect = Aspect.AspectFit;
Source = "bank.png";
WidthRequest = 30;
HeightRequest = 30;
BackgroundColor = Color.Red;
AnchorX = anchorx;
AnchorY = anchory;
//TranslationX = -50;
//TranslationY = 25;
if (rotate)
{
this.RotateTo(3600, 10000);
}
if (scale)
{
this.ScaleTo(2, 4000);
}
Margin = 30;
}
}
}
}

Просмотреть файл

@ -0,0 +1,59 @@
using System.Threading.Tasks;
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, 7283, "[Android] Crash changing the Application MainPage",
PlatformAffected.Android)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.ManualReview)]
#endif
public class Issue7283 : TestContentPage
{
public Issue7283()
{
Title = "Issue 7283";
}
protected override void Init()
{
var layout = new StackLayout
{
Padding = new Thickness(12)
};
var instructions = new Label
{
Text = "Press the Button below. If navigate without any errors, the test has passed."
};
var navigateButton = new Button
{
Text = "Navigate"
};
navigateButton.Clicked += async (sender, e) =>
{
navigateButton.IsEnabled = false;
await Task.Delay(2000);
var navigation = new NavigationPage();
Application.Current.MainPage = navigation;
await Application.Current.MainPage.Navigation.PushAsync(new ContentPage { Title = "Did I crash?" });
};
layout.Children.Add(instructions);
layout.Children.Add(navigateButton);
Content = layout;
}
}
}

Просмотреть файл

@ -1084,6 +1084,8 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue7678.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue7678.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6491.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue6491.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6127.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Issue6127.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue7283.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue5395.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml"> <EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">

Просмотреть файл

@ -643,7 +643,9 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (_masterDetailPage == null) if (_masterDetailPage == null)
{ {
_masterDetailPage = PageController.InternalChildren[0] as MasterDetailPage; if (PageController.InternalChildren.Count > 0)
_masterDetailPage = PageController.InternalChildren[0] as MasterDetailPage;
if (_masterDetailPage == null) if (_masterDetailPage == null)
return; return;
} }
@ -1025,7 +1027,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (!textColor.IsDefault) if (!textColor.IsDefault)
bar.SetTitleTextColor(textColor.ToAndroid().ToArgb()); bar.SetTitleTextColor(textColor.ToAndroid().ToArgb());
bar.Title = currentPage.Title ?? ""; bar.Title = currentPage?.Title ?? string.Empty;
UpdateTitleIcon(); UpdateTitleIcon();
@ -1035,6 +1037,10 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
void UpdateTitleIcon() void UpdateTitleIcon()
{ {
Page currentPage = Element.CurrentPage; Page currentPage = Element.CurrentPage;
if (currentPage == null)
return;
ImageSource source = NavigationPage.GetTitleIconImageSource(currentPage); ImageSource source = NavigationPage.GetTitleIconImageSource(currentPage);
if (source == null || source.IsEmpty) if (source == null || source.IsEmpty)
@ -1072,6 +1078,10 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
return; return;
Page currentPage = Element.CurrentPage; Page currentPage = Element.CurrentPage;
if (currentPage == null)
return;
VisualElement titleView = NavigationPage.GetTitleView(currentPage); VisualElement titleView = NavigationPage.GetTitleView(currentPage);
if (_titleViewRenderer != null) if (_titleViewRenderer != null)
{ {

Просмотреть файл

@ -259,19 +259,35 @@ namespace Xamarin.Forms.Platform.MacOS
#endif #endif
return; return;
} }
#if __MOBILE__ #if !__MOBILE__
caLayer.AnchorPoint = new PointF(anchorX, anchorY); // Y-axe on macos is inverted
#else translationY = -translationY;
caLayer.AnchorPoint = new PointF(anchorX - 0.5f, anchorY - 0.5f); anchorY = 1 - anchorY;
// rotation direction on macos also inverted
rotationX = -rotationX;
rotationY = -rotationY;
rotation = -rotation;
//otherwise scaled/rotated image clipped by parent bounds
caLayer.MasksToBounds = false;
#endif #endif
caLayer.AnchorPoint = new PointF(anchorX, anchorY);
caLayer.Opacity = opacity; caLayer.Opacity = opacity;
const double epsilon = 0.001; const double epsilon = 0.001;
#if !__MOBILE__
// fix position, position in macos is aslo relative to anchor point
// but it's (0,0) by default, so we don't need to substract 0.5
transform = transform.Translate(anchorX * width, 0, 0);
transform = transform.Translate(0, anchorY * height, 0);
#else
// position is relative to anchor point // position is relative to anchor point
if (Math.Abs(anchorX - .5) > epsilon) if (Math.Abs(anchorX - .5) > epsilon)
transform = transform.Translate((anchorX - .5f) * width, 0, 0); transform = transform.Translate((anchorX - .5f) * width, 0, 0);
if (Math.Abs(anchorY - .5) > epsilon) if (Math.Abs(anchorY - .5) > epsilon)
transform = transform.Translate(0, (anchorY - .5f) * height, 0); transform = transform.Translate(0, (anchorY - .5f) * height, 0);
#endif
if (Math.Abs(translationX) > epsilon || Math.Abs(translationY) > epsilon) if (Math.Abs(translationX) > epsilon || Math.Abs(translationY) > epsilon)
transform = transform.Translate(translationX, translationY, 0); transform = transform.Translate(translationX, translationY, 0);