2016-03-22 23:02:25 +03:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Xamarin.Forms.CustomAttributes;
|
2016-04-26 18:20:55 +03:00
|
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
2016-11-15 22:39:23 +03:00
|
|
|
|
#if UITEST
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Xamarin.Forms.Core.UITests;
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-11-07 01:00:08 +03:00
|
|
|
|
namespace Xamarin.Forms.Controls.Issues
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
2016-11-15 22:39:23 +03:00
|
|
|
|
#if UITEST
|
|
|
|
|
[Category(UITestCategories.BoxView)]
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
[Preserve (AllMembers=true)]
|
|
|
|
|
[Issue (IssueTracker.Github, 1075, "Does not update Color", PlatformAffected.Android | PlatformAffected.WinPhone)]
|
|
|
|
|
public class Issue1075 : ContentPage
|
|
|
|
|
{
|
|
|
|
|
// Issue1075
|
|
|
|
|
// BoxView doesn't update color
|
|
|
|
|
public Issue1075 ()
|
|
|
|
|
{
|
2019-01-04 22:34:15 +03:00
|
|
|
|
var instructions = new Label { Text = "Tap the 'Change to blue' button below. If the BoxView does not " +
|
|
|
|
|
"turn blue, this test has failed." };
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
Label header = new Label
|
|
|
|
|
{
|
|
|
|
|
Text = "Picker",
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning disable 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
Font = Font.BoldSystemFontOfSize(50),
|
2016-04-11 19:50:28 +03:00
|
|
|
|
#pragma warning restore 618
|
2016-03-22 23:02:25 +03:00
|
|
|
|
HorizontalOptions = LayoutOptions.Center
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Picker picker = new Picker
|
|
|
|
|
{
|
|
|
|
|
Title = "Color",
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (string color in new string[]
|
|
|
|
|
{
|
|
|
|
|
"Aqua", "Black", "Blue", "Fuschia",
|
|
|
|
|
"Gray", "Green", "Lime", "Maroon",
|
|
|
|
|
"Navy", "Olive", "Purple", "Red",
|
|
|
|
|
"Silver", "Teal", "White", "Yellow"
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
picker.Items.Add(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create BoxView for displaying pickedColor
|
|
|
|
|
BoxView boxView = new BoxView
|
|
|
|
|
{
|
2019-01-04 22:34:15 +03:00
|
|
|
|
BackgroundColor = Color.Gray,
|
2016-03-22 23:02:25 +03:00
|
|
|
|
WidthRequest = 150,
|
|
|
|
|
HeightRequest = 150,
|
|
|
|
|
HorizontalOptions = LayoutOptions.Center,
|
|
|
|
|
VerticalOptions = LayoutOptions.CenterAndExpand
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var button = new Button {
|
|
|
|
|
Text = "Change to blue",
|
2019-01-04 22:34:15 +03:00
|
|
|
|
Command = new Command (() => boxView.BackgroundColor = Color.Blue)
|
2016-03-22 23:02:25 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
picker.SelectedIndexChanged += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
if (picker.SelectedIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
boxView.Color = Color.Default;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string selectedItem = picker.Items[picker.SelectedIndex];
|
|
|
|
|
FieldInfo colorField = typeof(Color).GetTypeInfo().GetDeclaredField(selectedItem);
|
|
|
|
|
boxView.Color = (Color)colorField.GetValue(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Accomodate iPhone status bar.
|
2017-01-12 23:05:41 +03:00
|
|
|
|
Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 0) : new Thickness(10, 0);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
// Build the page.
|
|
|
|
|
Content = new StackLayout
|
|
|
|
|
{
|
|
|
|
|
Children =
|
|
|
|
|
{
|
2019-01-04 22:34:15 +03:00
|
|
|
|
instructions,
|
2016-03-22 23:02:25 +03:00
|
|
|
|
header,
|
|
|
|
|
picker,
|
|
|
|
|
boxView,
|
|
|
|
|
button
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|