diff options
author | Samantha Houts <samantha@teamredwall.com> | 2016-11-15 11:43:34 -0800 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-11-15 11:43:34 -0800 |
commit | 0cc2fd2b6742a29fedc03de942801cc14ff6b499 (patch) | |
tree | 2ce0f4adc438bd611931f6b8693a4b24482da9f8 /Xamarin.Forms.Platform.WinRT/Platform.cs | |
parent | 6bc6ee5c712b2d29402e895993e38b4666acc3f9 (diff) | |
download | xamarin-forms-0cc2fd2b6742a29fedc03de942801cc14ff6b499.tar.gz xamarin-forms-0cc2fd2b6742a29fedc03de942801cc14ff6b499.tar.bz2 xamarin-forms-0cc2fd2b6742a29fedc03de942801cc14ff6b499.zip |
[UWP] Explicitly set mobile StatusBar colors to white Background/black Foreground on Light theme (#491)
* [UWP] Encapsulate MobileStatusBar
* [UWP] Set StatusBar colors on Light theme
* Add test code to override status bar color
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT/Platform.cs')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT/Platform.cs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Xamarin.Forms.Platform.WinRT/Platform.cs b/Xamarin.Forms.Platform.WinRT/Platform.cs index e5a989c0..d6a68fed 100644 --- a/Xamarin.Forms.Platform.WinRT/Platform.cs +++ b/Xamarin.Forms.Platform.WinRT/Platform.cs @@ -32,6 +32,10 @@ namespace Xamarin.Forms.Platform.WinRT { internal static readonly BindableProperty RendererProperty = BindableProperty.CreateAttached("Renderer", typeof(IVisualElementRenderer), typeof(Platform), default(IVisualElementRenderer)); +#if WINDOWS_UWP + internal static StatusBar MobileStatusBar => ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") ? StatusBar.GetForCurrentView() : null; +#endif + public static IVisualElementRenderer GetRenderer(VisualElement element) { return (IVisualElementRenderer)element.GetValue(RendererProperty); @@ -79,13 +83,26 @@ namespace Xamarin.Forms.Platform.WinRT UpdateBounds(); - #if WINDOWS_UWP - if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) + StatusBar statusBar = MobileStatusBar; + if (statusBar != null) { - StatusBar statusBar = StatusBar.GetForCurrentView(); statusBar.Showing += (sender, args) => UpdateBounds(); statusBar.Hiding += (sender, args) => UpdateBounds(); + + // UWP 14393 Bug: If RequestedTheme is Light (which it is by default), then the + // status bar uses White Foreground with White Background. + // UWP 10586 Bug: If RequestedTheme is Light (which it is by default), then the + // status bar uses Black Foreground with Black Background. + // Since the Light theme should have a Black on White status bar, we will set it explicitly. + // This can be overriden by setting the status bar colors in App.xaml.cs OnLaunched. + + if (statusBar.BackgroundColor == null && statusBar.ForegroundColor == null && Windows.UI.Xaml.Application.Current.RequestedTheme == ApplicationTheme.Light) + { + statusBar.BackgroundColor = Colors.White; + statusBar.ForegroundColor = Colors.Black; + statusBar.BackgroundOpacity = 1; + } } #endif } @@ -420,10 +437,9 @@ namespace Xamarin.Forms.Platform.WinRT { _bounds = new Rectangle(0, 0, _page.ActualWidth, _page.ActualHeight); #if WINDOWS_UWP - if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) + StatusBar statusBar = MobileStatusBar; + if (statusBar != null) { - StatusBar statusBar = StatusBar.GetForCurrentView(); - bool landscape = Device.Info.CurrentOrientation.IsLandscape(); bool titleBar = CoreApplication.GetCurrentView().TitleBar.IsVisible; double offset = landscape ? statusBar.OccludedRect.Width : statusBar.OccludedRect.Height; |