Skip to content

Commit

Permalink
[Windows] Ensure consistent background colors for UI test cases (#21022)
Browse files Browse the repository at this point in the history
* Ensure consistant background colors for UI test cases

* Switch to navigation page background

* Cleanup

* Update src/Controls/samples/Controls.Sample.UITests/CoreViews/CoreNavigationPage.cs

Spelling fix

Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>

---------

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 7, 2024
1 parent 51cabfd commit 4bf640d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
using Microsoft.Maui.Graphics;
using Application = Microsoft.Maui.Controls.Application;

namespace Maui.Controls.Sample
{
Expand All @@ -17,12 +19,23 @@ public CoreNavigationPage()
On<iOS>().SetPrefersLargeTitles(true);

Navigation.PushAsync(new CoreRootPage(this));

Application.Current.RequestedThemeChanged += UpdateThemeColor;
}

private void UpdateThemeColor(object _, AppThemeChangedEventArgs args)
{
// Make sure background color is consistent so that the Mica material doesn't cause issues on Windows
BackgroundColor =
Application.Current.RequestedTheme == Microsoft.Maui.ApplicationModel.AppTheme.Dark ? Colors.Black : Colors.White;
}

public static void InitNavigationPageStyling(Microsoft.Maui.Controls.NavigationPage navigationPage)
{
navigationPage.BarBackgroundColor = Colors.Maroon;
navigationPage.BarTextColor = Colors.Yellow;
navigationPage.BackgroundColor =
Application.Current.RequestedTheme == Microsoft.Maui.ApplicationModel.AppTheme.Dark ? Colors.Black : Colors.White;
}
}
}
2 changes: 0 additions & 2 deletions src/Controls/samples/Controls.Sample.UITests/TestCases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type)
TrackOnInsights(page);
if (page is ContentPage /*|| page is CarouselPage*/)
{

await Navigation.PushAsync(page);

}
else if (page is Shell)
{
Expand Down

0 comments on commit 4bf640d

Please sign in to comment.