Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Set StatusBar color and StatusBarStyle for iOS Android and UWP from Page #8298

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
224beb0
StatusBar Background color
KSemenenko Oct 21, 2019
50244fc
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Oct 23, 2019
81797cf
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Oct 30, 2019
76a4b0b
gallery
KSemenenko Oct 30, 2019
6ba0c66
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Oct 30, 2019
5410f90
revert changes
KSemenenko Oct 30, 2019
52ff6b7
wip
KSemenenko Oct 30, 2019
1cbef02
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Nov 6, 2019
1c244ef
changes from review + UWP
KSemenenko Nov 6, 2019
9ecde1b
StatusBarStyle
KSemenenko Nov 8, 2019
5a782da
uwp
KSemenenko Nov 9, 2019
b8b1563
refactoring
KSemenenko Nov 9, 2019
36df8d5
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Nov 9, 2019
437fb62
Merge branch 'master' into issue-7314-status-bar-color
KSemenenko Nov 15, 2019
2d0ef89
refactoring
KSemenenko Nov 20, 2019
97e9039
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Nov 20, 2019
3535061
Shell and Pages
KSemenenko Nov 21, 2019
9276d35
swhitch page
KSemenenko Nov 21, 2019
e217084
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Nov 27, 2019
654881d
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Dec 9, 2019
aabc274
appeared
KSemenenko Dec 9, 2019
47a4d42
refactoring
KSemenenko Dec 9, 2019
cd8b4b8
SendAppearing
KSemenenko Dec 13, 2019
59fdde4
IsOnScreen
KSemenenko Dec 13, 2019
19b86de
refactoring and more samples
KSemenenko Dec 13, 2019
0f8ce38
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Dec 13, 2019
74faacc
IsOnScreenProperty
KSemenenko Dec 13, 2019
606b8dc
Tests
KSemenenko Dec 13, 2019
2e88988
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Dec 13, 2019
225e237
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Dec 18, 2019
674b55b
IsLoaded
KSemenenko Dec 18, 2019
6fda594
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Dec 18, 2019
13093db
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Jan 2, 2020
3cbdac3
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Jan 3, 2020
64ca279
IsPresented
KSemenenko Jan 3, 2020
e575bd9
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Jan 31, 2020
c5d2c2f
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Feb 6, 2020
0b26303
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Feb 10, 2020
aa6d1c5
IsAppeared
KSemenenko Feb 10, 2020
4f345fe
IsAppeared
KSemenenko Feb 10, 2020
f620add
IsAppearedProperty
KSemenenko Feb 10, 2020
713b988
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Feb 13, 2020
2c5de8b
Merge branch 'master' into issue-7314-status-bar-color
KSemenenko Feb 14, 2020
3ba5c26
Commands
KSemenenko Feb 14, 2020
57180a6
remove extra propeties
KSemenenko Feb 26, 2020
ec10e8d
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Feb 26, 2020
01470c3
tests
KSemenenko Feb 26, 2020
10beb52
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Apr 16, 2020
0ea8872
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko May 22, 2020
54ef8d8
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Jun 1, 2020
d019c04
tabs
KSemenenko Jun 1, 2020
659cc11
refactoring
KSemenenko Jun 1, 2020
aba19bf
tabbedpage fix
KSemenenko Jun 1, 2020
c764ecf
GetEffectiveBindableValue
KSemenenko Jun 1, 2020
0857aea
Merge remote-tracking branch 'upstream/master' into issue-7314-status…
KSemenenko Jun 11, 2020
de427f1
Merge branch 'main' into issue-7314-status-bar-color
KSemenenko Jul 15, 2020
564279d
Merge branch 'main' into issue-7314-status-bar-color
KSemenenko Aug 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Xamarin.Forms.ControlGallery.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<string>[email protected]</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We are using your location</string>
<key>NSLocationAlwaysUsageDescription</key>
Expand Down
3 changes: 2 additions & 1 deletion Xamarin.Forms.Controls/CoreGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public override string ToString()
new GalleryPageFactory(() => new SwitchCoreGalleryPage(), "Switch Gallery"),
new GalleryPageFactory(() => new SwipeViewCoreGalleryPage(), "SwipeView Core Gallery"),
new GalleryPageFactory(() => new SwipeViewGallery(), "SwipeView Gallery"),
new GalleryPageFactory(() => new StatusBarGallery(), "Page StatusBar Gallery"),
new GalleryPageFactory(() => new TableViewCoreGalleryPage(), "TableView Gallery"),
new GalleryPageFactory(() => new TimePickerCoreGalleryPage(), "TimePicker Gallery"),
new GalleryPageFactory(() => new VisualGallery(), "Visual Gallery"),
Expand All @@ -379,7 +380,7 @@ public override string ToString()
new GalleryPageFactory(() => new DynamicViewGallery(), "Dynamic ViewGallery"),
new GalleryPageFactory(() => new AppThemeGallery(), "AppTheme Gallery"),
//pages
new GalleryPageFactory(() => new RootContentPage ("Content"), "RootPages Gallery"),
new GalleryPageFactory(() => new RootContentPage ("Content"), "RootPages Gallery"),
new GalleryPageFactory(() => new MasterDetailPageTabletPage(), "MasterDetailPage Tablet Page"),
// legacy galleries
new GalleryPageFactory(() => new AbsoluteLayoutGallery(), "AbsoluteLayout Gallery - Legacy"),
Expand Down
36 changes: 36 additions & 0 deletions Xamarin.Forms.Controls/GalleryPages/StatusBarGallery.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Xamarin.Forms.Controls.GalleryPages.StatusBarGallery">
<StackLayout>
<Label Text="Slide to change StatusBarColor color"/>

<Slider Minimum="0" Maximum="255" Value="0" ValueChanged="Slider_OnValueChanged" MaximumTrackColor="Red" ThumbColor="Red"
MinimumTrackColor="Red" Margin="20,10" x:Name="RedSlider"/>

<Slider Minimum="0" Maximum="255" Value="0" ValueChanged="Slider_OnValueChanged" MaximumTrackColor="Green" ThumbColor="Green"
MinimumTrackColor="Green" Margin="20,10" x:Name="GreenSlider"/>

<Slider Minimum="0" Maximum="255" Value="0" ValueChanged="Slider_OnValueChanged" MaximumTrackColor="Blue" ThumbColor="Blue"
MinimumTrackColor="Blue" Margin="20,10" x:Name="BlueSlider"/>

<Label Text="Swith to change StatusBarStyle"/>

<Switch Toggled="Switch_OnToggled" HorizontalOptions="Start"/>
<ScrollView>
<StackLayout>
<Button Text="NavigationPage" Clicked="NavigationPage_Navigate"/>
<Button Text="NavigationPage Pages" Clicked="NavigationPage_Pages_Navigate"/>
<Button Text="TabbedPage" Clicked="TabbedPage_Navigate"/>
<Button Text="TabbedPage Pages" Clicked="TabbedPage_Pages_Navigate"/>
<Button Text="CarouselPage" Clicked="CarouselPage_Navigate"/>
<Button Text="CarouselPage Pages" Clicked="CarouselPage_Pages_Navigate"/>
<Button Text="ContentPage" Clicked="ContentPage_Navigate"/>
<Button Text="Shell" Clicked="Shell_Navigate"/>
</StackLayout>
</ScrollView>
</StackLayout>
</ContentPage>
133 changes: 133 additions & 0 deletions Xamarin.Forms.Controls/GalleryPages/StatusBarGallery.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms.Xaml;

namespace Xamarin.Forms.Controls.GalleryPages
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class StatusBarGallery : ContentPage
{
public StatusBarGallery()
{
InitializeComponent();
}

void Slider_OnValueChanged(object sender, ValueChangedEventArgs e)
{
StatusBarColor = Color.FromRgb(Convert.ToInt32(RedSlider.Value), Convert.ToInt32(GreenSlider.Value), Convert.ToInt32(BlueSlider.Value));
}

void Switch_OnToggled(object sender, ToggledEventArgs e)
{
StatusBarStyle = e.Value ? StatusBarStyle.DarkContent : StatusBarStyle.LightContent;
}

void NavigationPage_Navigate(object sender, EventArgs e)
{
var page = new NavigationPage(new StatusBarGallery());
page.StatusBarColor = Color.DarkBlue;
page.StatusBarStyle = StatusBarStyle.DarkContent;
Application.Current.MainPage = page;
}

void NavigationPage_Pages_Navigate(object sender, EventArgs e)
{
var page = new NavigationPage(new StatusBarGallery()
{
StatusBarColor = Color.Red,
StatusBarStyle = StatusBarStyle.LightContent
});
Application.Current.MainPage = page;
page.PushAsync(new StatusBarGallery()
{
StatusBarColor = Color.Cyan,
StatusBarStyle = StatusBarStyle.DarkContent
});
}

void ContentPage_Navigate(object sender, EventArgs e)
{
var page = new StatusBarGallery()
{
StatusBarColor = Color.DarkTurquoise,
StatusBarStyle = StatusBarStyle.DarkContent
};
Application.Current.MainPage = page;
}

void TabbedPage_Navigate(object sender, EventArgs e)
{
var page = new TabbedPage();
page.Children.Add(new StatusBarGallery { Title = "Page1" });
page.Children.Add(new StatusBarGallery { Title = "Page2" });
page.StatusBarColor = Color.DarkCyan;
page.StatusBarStyle = StatusBarStyle.DarkContent;
Application.Current.MainPage = page;
}

void TabbedPage_Pages_Navigate(object sender, EventArgs e)
{
var page = new TabbedPage();
page.Children.Add(new StatusBarGallery()
{
StatusBarColor = Color.Red,
StatusBarStyle = StatusBarStyle.LightContent,
Title = "Page1"
});
page.Children.Add(new StatusBarGallery()
{
StatusBarColor = Color.Cyan,
StatusBarStyle = StatusBarStyle.DarkContent,
Title = "Page1"
});
Application.Current.MainPage = page;
}

void CarouselPage_Navigate(object sender, EventArgs e)
{
var page = new CarouselPage();
page.Children.Add(new StatusBarGallery());
page.Children.Add(new StatusBarGallery());
page.StatusBarColor = Color.DarkMagenta;
page.StatusBarStyle = StatusBarStyle.DarkContent;
Application.Current.MainPage = page;
}

void CarouselPage_Pages_Navigate(object sender, EventArgs e)
{
var page = new CarouselPage();
page.Children.Add(new StatusBarGallery()
{
StatusBarColor = Color.Red,
StatusBarStyle = StatusBarStyle.LightContent
});
page.Children.Add(new StatusBarGallery()
{
StatusBarColor = Color.Cyan,
StatusBarStyle = StatusBarStyle.DarkContent
});
Application.Current.MainPage = page;
}

void Shell_Navigate(object sender, EventArgs e)
{
var shell = new Shell();
shell.Items.Add(new TabBar()
{
Items = { new Tab
{
Items = { new ShellContent()
{
Content = new StatusBarGallery()
}}
}}
});
shell.StatusBarColor = Color.DarkGoldenrod;
shell.StatusBarStyle = StatusBarStyle.DarkContent;

Application.Current.MainPage = shell;
}


}
}
3 changes: 3 additions & 0 deletions Xamarin.Forms.Core.UnitTests/PageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ public void SendAppearing ()
((IPageController)page).SendAppearing ();

Assert.True (sent);
Assert.True(page.HasAppeared);
}

[Test]
Expand All @@ -445,12 +446,14 @@ public void SendDisappearing ()

((IPageController)page).SendAppearing ();

Assert.True(page.HasAppeared);
bool sent = false;
page.Disappearing += (sender, args) => sent = true;

((IPageController)page).SendDisappearing ();

Assert.True (sent);
Assert.False(page.HasAppeared);
}

[Test]
Expand Down
1 change: 1 addition & 0 deletions Xamarin.Forms.Core/MultiPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,6 @@ void UpdateCurrentPage()
else if (SelectedItem is T)
CurrentPage = (T)SelectedItem;
}

}
}
2 changes: 2 additions & 0 deletions Xamarin.Forms.Core/NavigationPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class NavigationPage : Page, IPageContainer<Page>, IBarElement, INavigati
public static readonly BindableProperty TitleViewProperty = BindableProperty.CreateAttached("TitleView", typeof(View), typeof(NavigationPage), null, propertyChanging: TitleViewPropertyChanging);

static readonly BindablePropertyKey CurrentPagePropertyKey = BindableProperty.CreateReadOnly("CurrentPage", typeof(Page), typeof(NavigationPage), null);

public static readonly BindableProperty CurrentPageProperty = CurrentPagePropertyKey.BindableProperty;

static readonly BindablePropertyKey RootPagePropertyKey = BindableProperty.CreateReadOnly(nameof(RootPage), typeof(Page), typeof(NavigationPage), null);
Expand Down Expand Up @@ -545,5 +546,6 @@ protected override void OnRemovePage(Page page)
{
return _platformConfigurationRegistry.Value.On<T>();
}

}
}
Loading