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

Commit

Permalink
[macOS] Fix crash setting the default Label color using Span (#11300) f…
Browse files Browse the repository at this point in the history
…ixes #11272 fixes #11248

* Fixed crash converting color types in macOS

* Updated the fix
  • Loading branch information
jsuarezruiz committed Jul 3, 2020
1 parent c68071a commit 7160b30
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Xamarin.Forms.Internals;
using Xamarin.Forms.CustomAttributes;

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

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Label)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 11272,
"[Bug] Crash XF for Mac 4.7.0.1080",
PlatformAffected.macOS)]
public class Issue11272 : TestContentPage
{
public Issue11272()
{

}

protected override void Init()
{
Title = "Issue 11272";

var layout = new StackLayout();

var instructions = new Label
{
Padding = 12,
BackgroundColor = Color.Black,
TextColor = Color.White,
Text = "Without exception, this test has passed."
};

var errorLabel1 = new Label()
{
HorizontalOptions = LayoutOptions.Center,
FormattedText = new FormattedString
{
Spans =
{
new Span()
{
Text = "🔔🌀 Issue 11272",
}
}
}
};

var errorLabel2 = new Label()
{
HorizontalOptions = LayoutOptions.Center,
FormattedText = new FormattedString
{
Spans =
{
new Span()
{
TextColor = Color.Red,
Text = "🔔🌀 Issue 11272 (Using TextColor)",
}
}
}
};

layout.Children.Add(instructions);
layout.Children.Add(errorLabel1);
layout.Children.Add(errorLabel2);

Content = layout;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue11113.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue10182.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11107.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11272.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
Expand Down
2 changes: 1 addition & 1 deletion Xamarin.Forms.Platform.iOS/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ internal static UIColor LightGray
#else
internal static readonly NSColor Black = NSColor.Black;
internal static readonly NSColor SeventyPercentGrey = NSColor.FromRgba(0.7f, 0.7f, 0.7f, 1);
internal static readonly NSColor LabelColor = NSColor.Black;
internal static readonly NSColor LabelColor = NSColor.Black.UsingColorSpace("NSCalibratedRGBColorSpace");
internal static readonly NSColor AccentColor = Color.FromRgba(50, 79, 133, 255).ToNSColor();
#endif

Expand Down

0 comments on commit 7160b30

Please sign in to comment.