summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorJimmy Garrido <jimmygarrido@outlook.com>2017-04-11 02:48:41 -0700
committerRui Marinho <me@ruimarinho.net>2017-04-11 10:48:41 +0100
commit7458ca37330f424bf7fb1447580b0fa9c34c6db4 (patch)
treec87833b48d7840e673a8606951543b367d6fae17 /Xamarin.Forms.Platform.Android
parent0e73a2d16c82d6d9913b9f32cc7705268162a2c3 (diff)
downloadxamarin-forms-7458ca37330f424bf7fb1447580b0fa9c34c6db4.tar.gz
xamarin-forms-7458ca37330f424bf7fb1447580b0fa9c34c6db4.tar.bz2
xamarin-forms-7458ca37330f424bf7fb1447580b0fa9c34c6db4.zip
Clean up NavigationBar code in Platform (#753)
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/Platform.cs37
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs4
2 files changed, 13 insertions, 28 deletions
diff --git a/Xamarin.Forms.Platform.Android/Platform.cs b/Xamarin.Forms.Platform.Android/Platform.cs
index 3f969091..72a6d0c9 100644
--- a/Xamarin.Forms.Platform.Android/Platform.cs
+++ b/Xamarin.Forms.Platform.Android/Platform.cs
@@ -109,11 +109,6 @@ namespace Xamarin.Forms.Platform.Android
_currentNavigationPage.PropertyChanged += CurrentNavigationPageOnPropertyChanged;
RegisterNavPageCurrent(_currentNavigationPage.CurrentPage);
}
-
- UpdateActionBarBackgroundColor();
- UpdateActionBarTextColor();
- UpdateActionBarUpImageColor();
- UpdateActionBarTitle();
}
}
@@ -304,6 +299,7 @@ namespace Xamarin.Forms.Platform.Android
public void UpdateActionBarTextColor()
{
SetActionBarTextColor();
+ UpdateActionBarUpImageColor();
}
protected override void OnBindingContextChanged()
@@ -429,9 +425,8 @@ namespace Xamarin.Forms.Platform.Android
internal void UpdateActionBar()
{
if (ActionBar == null) //Fullscreen theme doesn't have action bar
- {
return;
- }
+
List<Page> relevantAncestors = AncestorPagesOfPage(_navModel.CurrentPage);
IEnumerable<NavigationPage> navPages = relevantAncestors.OfType<NavigationPage>();
@@ -453,19 +448,19 @@ namespace Xamarin.Forms.Platform.Android
throw new InvalidOperationException("NavigationPage must have a root Page before being used. Either call PushAsync with a valid Page, or pass a Page to the constructor before usage.");
}
- UpdateActionBarTitle();
-
- if (ShouldShowActionBarTitleArea() || tabbedPage != null)
+ if (ShouldShowActionBarTitleArea() || CurrentTabbedPage != null)
ShowActionBar();
else
HideActionBar();
+
UpdateMasterDetailToggle();
}
internal void UpdateActionBarBackgroundColor()
{
- if (!((Activity)_context).ActionBar.IsShowing)
+ if (!ShouldShowActionBarTitleArea())
return;
+
Color colorToUse = Color.Default;
if (CurrentNavigationPage != null)
{
@@ -515,13 +510,6 @@ namespace Xamarin.Forms.Platform.Android
MasterDetailPageToggle.SyncState();
}
- internal void UpdateNavigationTitleBar()
- {
- UpdateActionBarTitle();
- UpdateActionBar();
- UpdateActionBarUpImageColor();
- }
-
void AddChild(VisualElement view, bool layout = false)
{
if (GetRenderer(view) != null)
@@ -593,12 +581,12 @@ namespace Xamarin.Forms.Platform.Android
void CurrentNavigationPageOnPopped(object sender, NavigationEventArgs eventArg)
{
- UpdateNavigationTitleBar();
+ UpdateActionBar();
}
void CurrentNavigationPageOnPoppedToRoot(object sender, EventArgs eventArgs)
{
- UpdateNavigationTitleBar();
+ UpdateActionBar();
}
void CurrentNavigationPageOnPropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -610,17 +598,14 @@ namespace Xamarin.Forms.Platform.Android
else if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName)
UpdateActionBarBackgroundColor();
else if (e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName)
- {
UpdateActionBarTextColor();
- UpdateActionBarUpImageColor();
- }
else if (e.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
RegisterNavPageCurrent(CurrentNavigationPage.CurrentPage);
}
void CurrentNavigationPageOnPushed(object sender, NavigationEventArgs eventArg)
{
- UpdateNavigationTitleBar();
+ UpdateActionBar();
}
void CurrentTabbedPageChildrenChanged(object sender, NotifyCollectionChangedEventArgs e)
@@ -918,10 +903,10 @@ namespace Xamarin.Forms.Platform.Android
void ShowActionBar()
{
ReloadToolbarItems();
- UpdateActionBarHomeAsUp(ActionBar);
- ActionBar.Show();
+ UpdateActionBarTitle();
UpdateActionBarBackgroundColor();
UpdateActionBarTextColor();
+ ActionBar.Show();
}
void ToolbarTrackerOnCollectionChanged(object sender, EventArgs eventArgs)
diff --git a/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
index 5d678287..bcacee6b 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/NavigationRenderer.cs
@@ -150,7 +150,7 @@ namespace Xamarin.Forms.Platform.Android
throw new InvalidOperationException("This should never happen, please file a bug");
Device.StartTimer(TimeSpan.FromMilliseconds(0), () => {
- ((Platform)Element.Platform).UpdateNavigationTitleBar();
+ ((Platform)Element.Platform).UpdateActionBar();
return false;
});
}
@@ -197,7 +197,7 @@ namespace Xamarin.Forms.Platform.Android
Device.StartTimer(TimeSpan.FromMilliseconds(0), () =>
{
- ((Platform)Element.Platform).UpdateNavigationTitleBar();
+ ((Platform)Element.Platform).UpdateActionBar();
return false;
});
}