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

Commit 41fa4e4

Browse files
committed
Address fast label renderer, changes in BoxView, and a bug in Android fast button
1 parent 5576568 commit 41fa4e4

File tree

4 files changed

+51
-11
lines changed

4 files changed

+51
-11
lines changed

Xamarin.Forms.ControlGallery.Android/Tests/PlatformTestFixture.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,15 @@ protected TextView GetNativeControl(Label label)
209209
{
210210
var renderer = GetRenderer(label);
211211
var viewRenderer = renderer.View as LabelRenderer;
212-
return viewRenderer.Control;
212+
213+
if (viewRenderer != null)
214+
{
215+
return viewRenderer.Control;
216+
}
217+
218+
var fastRenderer = renderer.View as Platform.Android.FastRenderers.LabelRenderer;
219+
220+
return fastRenderer;
213221
}
214222

215223
protected EditText GetNativeControl(Picker picker)

Xamarin.Forms.ControlGallery.WindowsUniversal/Tests/BackgroundColorTests.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using NUnit.Framework;
44
using Windows.UI.Xaml.Controls;
55
using Windows.UI.Xaml.Media;
6+
using Windows.UI.Xaml.Shapes;
67
using Xamarin.Forms.Platform.UWP;
78
using WColor = Windows.UI.Color;
89

@@ -26,7 +27,7 @@ static IEnumerable TestCases
2627
}
2728
}
2829

29-
WColor GetBackgroundColor(Control control)
30+
WColor GetBackgroundColor(Control control)
3031
{
3132
if (control is FormsButton button)
3233
{
@@ -41,21 +42,41 @@ WColor GetBackgroundColor(Control control)
4142
return (control.Background as SolidColorBrush).Color;
4243
}
4344

44-
WColor GetBackgroundColor(Panel panel)
45+
WColor GetBackgroundColor(Panel panel)
4546
{
4647
return (panel.Background as SolidColorBrush).Color;
4748
}
4849

49-
[Test, TestCaseSource(nameof(TestCases))]
50-
[Description("View background color should match renderer background color")]
51-
public void BackgroundColorConsistent(View view)
50+
WColor GetBackgroundColor(Border border)
51+
{
52+
return (border.Background as SolidColorBrush).Color;
53+
}
54+
55+
WColor GetNativeColor(View view)
5256
{
5357
var control = GetNativeControl(view);
5458

55-
var nativeColor = control != null
56-
? GetBackgroundColor(control)
57-
: GetBackgroundColor(GetContainer(view));
59+
if (control != null)
60+
{
61+
return GetBackgroundColor(control);
62+
}
63+
64+
var border = GetBorder(view);
5865

66+
if (border != null)
67+
{
68+
return GetBackgroundColor(border);
69+
}
70+
71+
var panel = GetPanel(view);
72+
return GetBackgroundColor(panel);
73+
}
74+
75+
[Test, TestCaseSource(nameof(TestCases))]
76+
[Description("View background color should match renderer background color")]
77+
public void BackgroundColorConsistent(View view)
78+
{
79+
var nativeColor = GetNativeColor(view);
5980
var formsColor = view.BackgroundColor.ToUwpColor();
6081
Assert.That(nativeColor, Is.EqualTo(formsColor));
6182
}

Xamarin.Forms.ControlGallery.WindowsUniversal/Tests/PlatformTestFixture.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using NUnit.Framework;
33
using Windows.UI.Xaml.Controls;
4+
using Windows.UI.Xaml.Shapes;
45
using Xamarin.Forms.Platform.UWP;
56

67
namespace Xamarin.Forms.ControlGallery.WindowsUniversal.Tests
@@ -51,10 +52,17 @@ protected Control GetNativeControl(VisualElement element)
5152
return GetRenderer(element).GetNativeElement() as Control;
5253
}
5354

54-
protected Panel GetContainer(VisualElement element)
55+
protected Panel GetPanel(VisualElement element)
5556
{
5657
return GetRenderer(element).ContainerElement as Panel;
5758
}
59+
60+
protected Border GetBorder(VisualElement element)
61+
{
62+
var renderer = GetRenderer(element);
63+
var nativeElement = renderer.GetNativeElement();
64+
return nativeElement as Border;
65+
}
5866

5967
protected TextBlock GetNativeControl(Label label)
6068
{

Xamarin.Forms.Platform.Android/FastRenderers/ButtonRenderer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ SizeRequest IVisualElementRenderer.GetDesiredSize(int widthConstraint, int heigh
104104

105105
var result = _buttonLayoutManager.GetDesiredSize(widthConstraint, heightConstraint);
106106

107-
Control.Hint = hint;
107+
if (Control.Hint != hint)
108+
{
109+
Control.Hint = hint;
110+
}
108111

109112
return result;
110113
}

0 commit comments

Comments
 (0)