forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Navigationbar BarBackgroundColor is not updating (dotnet#23195)
- Loading branch information
Showing
7 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
31 changes: 31 additions & 0 deletions
31
src/Controls/tests/TestCases.HostApp/Issues/Issues23195.xaml
This file contains 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,31 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<NavigationPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Name="Self" | ||
BarBackgroundColor="{AppThemeBinding Light=White,Dark=Black}" | ||
BarTextColor="{AppThemeBinding Light=Black,Dark=White}" | ||
x:Class="Maui.Controls.Sample.Issues.Issue23195"> | ||
<x:Arguments> | ||
<ContentPage x:Name="contentPage" Title="Content page"> | ||
<ContentPage.ToolbarItems> | ||
<ToolbarItem> | ||
<ToolbarItem.IconImageSource> | ||
<FontImageSource Glyph="" | ||
Color="{AppThemeBinding Light=Black, Dark=White}" | ||
FontFamily="FA"/> | ||
</ToolbarItem.IconImageSource> | ||
</ToolbarItem> | ||
</ContentPage.ToolbarItems> | ||
<VerticalStackLayout> | ||
<Button Text="Chnage theme" | ||
AutomationId="button" | ||
HeightRequest="100" | ||
Clicked="Button_Clicked"/> | ||
<Label Text="Dark theme applied" | ||
IsVisible="{AppThemeBinding Default=False,Dark=True}" | ||
AutomationId="label"/> | ||
</VerticalStackLayout> | ||
</ContentPage> | ||
</x:Arguments> | ||
</NavigationPage> |
18 changes: 18 additions & 0 deletions
18
src/Controls/tests/TestCases.HostApp/Issues/Issues23195.xaml.cs
This file contains 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,18 @@ | ||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 23195, "NavigationBarColors from NavigationPage not changing on AppTheme changing", PlatformAffected.Android | PlatformAffected.iOS)] | ||
public partial class Issue23195 : NavigationPage | ||
{ | ||
public Issue23195() | ||
{ | ||
InitializeComponent(); | ||
PushAsync(contentPage); | ||
} | ||
|
||
public void Button_Clicked(object sender, EventArgs eventArgs) | ||
{ | ||
Application.Current!.UserAppTheme = AppTheme.Dark; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue23195.cs
This file contains 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,27 @@ | ||
#if IOS || ANDROID | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class Issue23195 : _IssuesUITest | ||
{ | ||
public override string Issue => "NavigationBarColors from NavigationPage not changing on AppTheme changing"; | ||
|
||
public Issue23195(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.Page)] | ||
public void Issue23195Test() | ||
{ | ||
App.WaitForElement("button"); | ||
App.Click("button"); | ||
App.WaitForElement("label"); | ||
VerifyScreenshot(); | ||
} | ||
} | ||
} | ||
#endif |
This file contains 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,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ContentPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Name="contentPage" | ||
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui23195"> | ||
<ContentPage.ToolbarItems> | ||
<ToolbarItem> | ||
<ToolbarItem.IconImageSource> | ||
<FontImageSource Glyph="" | ||
x:Name="fontImage" | ||
Color="{AppThemeBinding Light=Black, Dark=White}"/> | ||
</ToolbarItem.IconImageSource> | ||
</ToolbarItem> | ||
</ContentPage.ToolbarItems> | ||
</ContentPage> |
50 changes: 50 additions & 0 deletions
50
src/Controls/tests/Xaml.UnitTests/Issues/Maui23195.xaml.cs
This file contains 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,50 @@ | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls.Core.UnitTests; | ||
using Microsoft.Maui.Dispatching; | ||
using Microsoft.Maui.Graphics; | ||
using Microsoft.Maui.UnitTests; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.Controls.Xaml.UnitTests | ||
{ | ||
public partial class Maui23195 : ContentPage | ||
{ | ||
public Maui23195() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public Maui23195(bool useCompiledXaml) | ||
{ | ||
//this stub will be replaced at compile time | ||
} | ||
|
||
[TestFixture] | ||
class Test | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Application.SetCurrentApplication(new MockApplication()); | ||
DispatcherProvider.SetCurrent(new DispatcherProviderStub()); | ||
} | ||
|
||
|
||
[TearDown] public void TearDown() => AppInfo.SetCurrent(null); | ||
|
||
[Test] | ||
public void FontImageColorShouldChangeOnAppThemeChange([Values(false, true)] bool useCompiledXaml) | ||
{ | ||
var contentPage = new Maui23195(useCompiledXaml); | ||
Application.Current.MainPage = contentPage; | ||
Assert.True(contentPage.fontImage.Parent is not null); | ||
|
||
Application.Current.UserAppTheme = AppTheme.Light; | ||
Assert.AreEqual(contentPage.fontImage.Color, Colors.Black); | ||
|
||
Application.Current.UserAppTheme = AppTheme.Dark; | ||
Assert.AreEqual(contentPage.fontImage.Color, Colors.White); | ||
} | ||
} | ||
} | ||
} |