-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix Switch ThumbColor reset on iOS 26+ theme changes. #33953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shalini-Ashokan
wants to merge
10
commits into
dotnet:main
Choose a base branch
from
Shalini-Ashokan:fix-33783
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3d5bef2
Fixed the switch thumb color is wrong when theme changes
Shalini-Ashokan 29063bd
Simplified the fix
Shalini-Ashokan a66b6b0
modified the fix
Shalini-Ashokan f4e8c56
Added test cases
Shalini-Ashokan bb6b7e9
Added snapshots
Shalini-Ashokan af5a556
Fixed the switch thumb color is wrong when theme changes
Shalini-Ashokan 877a3e2
Simplified the fix
Shalini-Ashokan 7750db7
Resolved the compilation issue
Shalini-Ashokan 0807361
committed the windows snapshot
Shalini-Ashokan 39a41f2
Resolved the gate failures
Shalini-Ashokan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+20.7 KB
...Cases.Android.Tests/snapshots/android/Issue33783_SwitchThumbColor_DarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.5 KB
...ases.Android.Tests/snapshots/android/Issue33783_SwitchThumbColor_LightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 33783, "Switch ThumbColor not applied correctly when theme changes on iOS", PlatformAffected.iOS | PlatformAffected.macOS)] | ||
| public class Issue33783 : ContentPage | ||
| { | ||
| public Issue33783() | ||
| { | ||
| var testSwitch = new Switch | ||
| { | ||
| AutomationId = "TestSwitch", | ||
| OnColor = Colors.Green, | ||
| ThumbColor = Colors.Red, | ||
| IsToggled = true, | ||
| HorizontalOptions = LayoutOptions.Center | ||
| }; | ||
|
|
||
| var lightThemeButton = new Button | ||
| { | ||
| AutomationId = "LightThemeButton", | ||
| Text = "Light Theme" | ||
| }; | ||
|
|
||
| lightThemeButton.Clicked += (s, e) => | ||
| { | ||
| if (Application.Current != null) | ||
| { | ||
| Application.Current.UserAppTheme = AppTheme.Light; | ||
| } | ||
| }; | ||
|
|
||
| var darkThemeButton = new Button | ||
| { | ||
| AutomationId = "DarkThemeButton", | ||
| Text = "Dark Theme" | ||
| }; | ||
|
|
||
| darkThemeButton.Clicked += (s, e) => | ||
| { | ||
| if (Application.Current != null) | ||
| { | ||
| Application.Current.UserAppTheme = AppTheme.Dark; | ||
| } | ||
| }; | ||
|
|
||
| var themeButtonsLayout = new HorizontalStackLayout | ||
| { | ||
| Spacing = 10, | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| Children = { lightThemeButton, darkThemeButton } | ||
| }; | ||
|
|
||
| var contentLayout = new VerticalStackLayout | ||
| { | ||
| Spacing = 20, | ||
| Padding = new Thickness(30), | ||
| Children = { testSwitch, themeButtonsLayout } | ||
| }; | ||
| contentLayout.SetAppThemeColor(BackgroundColorProperty, Colors.White, Colors.Black); | ||
| Content = contentLayout; | ||
| } | ||
| } |
Binary file added
BIN
+7.93 KB
...sts/TestCases.Mac.Tests/snapshots/mac/Issue33783_SwitchThumbColor_DarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.6 KB
...ts/TestCases.Mac.Tests/snapshots/mac/Issue33783_SwitchThumbColor_LightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue33783.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue33783 : _IssuesUITest | ||
| { | ||
| public Issue33783(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Switch ThumbColor not applied correctly when theme changes on iOS"; | ||
|
|
||
| [Test, Order(0)] | ||
| [Category(UITestCategories.Switch)] | ||
| public async Task VerifySwitchThumbColorOnDarkThemeChange() | ||
| { | ||
| App.WaitForElement("DarkThemeButton"); | ||
| App.Tap("DarkThemeButton"); | ||
| await Task.Delay(500); | ||
| VerifyScreenshot("Issue33783_SwitchThumbColor_DarkTheme"); | ||
| } | ||
|
|
||
| [Test, Order(1)] | ||
| [Category(UITestCategories.Switch)] | ||
| public async Task VerifySwitchThumbColorOnLightThemeChange() | ||
| { | ||
| App.WaitForElement("LightThemeButton"); | ||
| App.Tap("LightThemeButton"); | ||
| await Task.Delay(500); | ||
| VerifyScreenshot("Issue33783_SwitchThumbColor_LightTheme"); | ||
Shalini-Ashokan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Binary file added
BIN
+8 KB
...stCases.WinUI.Tests/snapshots/windows/Issue33783_SwitchThumbColor_DarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.12 KB
...tCases.WinUI.Tests/snapshots/windows/Issue33783_SwitchThumbColor_LightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.1 KB
.../TestCases.iOS.Tests/snapshots/ios-26/Issue33783_SwitchThumbColor_DarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.8 KB
...TestCases.iOS.Tests/snapshots/ios-26/Issue33783_SwitchThumbColor_LightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.4 KB
...sts/TestCases.iOS.Tests/snapshots/ios/Issue33783_SwitchThumbColor_DarkTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23 KB
...ts/TestCases.iOS.Tests/snapshots/ios/Issue33783_SwitchThumbColor_LightTheme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.