Skip to content

Commit c92932f

Browse files
[net10.0] [iOS, Windows] Fix: Switch does not use the native default on color when OnColor is unset (#29694)
* Fixed Switch default color issue on iOS * Fixed Switch default color issue on Windows * UISwitch ff color changes * Reverted off-color changes * Added test sample * Test sample changes * Added snapshots
1 parent 5f1e464 commit c92932f

File tree

18 files changed

+180
-26
lines changed

18 files changed

+180
-26
lines changed
Loading
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 29693, "The default native on color is not displayed when the Switch on color is not explicitly set", PlatformAffected.UWP)]
4+
public class Issue29693 : ContentPage
5+
{
6+
public Issue29693()
7+
{
8+
var defaultOnSwitch = new Switch
9+
{
10+
IsToggled = true,
11+
VerticalOptions = LayoutOptions.Center,
12+
HorizontalOptions = LayoutOptions.Center,
13+
};
14+
15+
var defaultOffSwitch = new Switch
16+
{
17+
VerticalOptions = LayoutOptions.Center,
18+
HorizontalOptions = LayoutOptions.Center
19+
};
20+
21+
var switchControl1 = new Switch
22+
{
23+
IsToggled = true,
24+
VerticalOptions = LayoutOptions.Center,
25+
HorizontalOptions = LayoutOptions.Center
26+
};
27+
28+
var switchControl2 = new Switch
29+
{
30+
VerticalOptions = LayoutOptions.Center,
31+
HorizontalOptions = LayoutOptions.Center
32+
};
33+
34+
var button1 = new Button
35+
{
36+
Text = "Toggle Switch 3",
37+
AutomationId = "button1",
38+
VerticalOptions = LayoutOptions.Center,
39+
HorizontalOptions = LayoutOptions.Center
40+
};
41+
42+
var button2 = new Button
43+
{
44+
Text = "Toggle Switch 4",
45+
AutomationId = "button2",
46+
VerticalOptions = LayoutOptions.Center,
47+
HorizontalOptions = LayoutOptions.Center,
48+
};
49+
50+
button1.Clicked += (sender, e) =>
51+
{
52+
switchControl1.IsToggled = !switchControl1.IsToggled;
53+
};
54+
55+
button2.Clicked += (sender, e) =>
56+
{
57+
switchControl2.IsToggled = !switchControl2.IsToggled;
58+
};
59+
60+
var verticalStackLayout = new VerticalStackLayout()
61+
{
62+
Spacing = 20,
63+
Padding = new Thickness(20),
64+
};
65+
verticalStackLayout.Add(defaultOnSwitch);
66+
verticalStackLayout.Add(defaultOffSwitch);
67+
verticalStackLayout.Add(switchControl1);
68+
verticalStackLayout.Add(switchControl2);
69+
verticalStackLayout.Add(button1);
70+
verticalStackLayout.Add(button2);
71+
72+
Content = verticalStackLayout;
73+
}
74+
}
Loading
Loading
Loading
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
7+
public class Issue29693 : _IssuesUITest
8+
{
9+
public override string Issue => "The default native on color is not displayed when the Switch on color is not explicitly set";
10+
11+
public Issue29693(TestDevice device)
12+
: base(device)
13+
{ }
14+
15+
[Test]
16+
[Category(UITestCategories.Switch)]
17+
public void VerifySwitchDefaultColors()
18+
{
19+
App.WaitForElement("button1");
20+
App.Tap("button1");
21+
App.Tap("button2");
22+
VerifyScreenshot();
23+
}
24+
}
Loading
Loading

0 commit comments

Comments
 (0)