summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-01-04 01:06:05 -0800
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2017-01-04 01:06:05 -0800
commitae0ccf26f110bb10df5bb6d1b32bb51452c7b528 (patch)
treedf03ada89fd1c8ec1f765c83a56f23d624b1a67f
parent3e252c25c283b154ca5f383051aeaec07a456ad8 (diff)
parent437bc4c434e27359c5e67df238823eefcd9f6eda (diff)
downloadxamarin-forms-ae0ccf26f110bb10df5bb6d1b32bb51452c7b528.tar.gz
xamarin-forms-ae0ccf26f110bb10df5bb6d1b32bb51452c7b528.tar.bz2
xamarin-forms-ae0ccf26f110bb10df5bb6d1b32bb51452c7b528.zip
Merge "Fixed NavigationPage.BarBackgroundColor Property" into tizen
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs54
1 files changed, 34 insertions, 20 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
index e760489d..c8f8606a 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/NavigationPageRenderer.cs
@@ -22,6 +22,11 @@ namespace Xamarin.Forms.Platform.Tizen
readonly List<Widget> _naviItemContentPartList = new List<Widget>();
ToolbarTracker _toolbarTracker = null;
+ Page CurrentPage => Element.CurrentPage;
+ Page PreviousPage => Element.Navigation.NavigationStack.Count > 1 ? Element.Navigation.NavigationStack[Element.Navigation.NavigationStack.Count - 2] : null;
+ NaviItem CurrentNaviItem => _naviFrame.NavigationStack.Count > 0 ? _naviFrame.NavigationStack.Last() : null;
+ NaviItem PreviousNaviItem => _naviFrame.NavigationStack.Count > 1 ? _naviFrame.NavigationStack[_naviFrame.NavigationStack.Count - 2] : null;
+
public NavigationPageRenderer()
{
}
@@ -99,6 +104,11 @@ namespace Xamarin.Forms.Platform.Tizen
_previousPage = Element.CurrentPage;
(_previousPage as IPageController)?.SendAppearing();
}
+ else if (e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName)
+ UpdateTitle(CurrentPage);
+ // Tizen does not support 'Tint', but only 'BarBackgroundColor'
+ else if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName)
+ UpdateBarBackgroundColor(CurrentNaviItem);
}
void PageCollectionChangedHandler(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
@@ -124,10 +134,7 @@ namespace Xamarin.Forms.Platform.Tizen
else if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName ||
e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
UpdateHasBackButton(sender as Page);
- else if (e.PropertyName == Page.TitleProperty.PropertyName ||
- e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName ||
- e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName ||
- e.PropertyName == NavigationPage.TintProperty.PropertyName)
+ else if (e.PropertyName == Page.TitleProperty.PropertyName)
UpdateTitle(sender as Page);
}
@@ -136,6 +143,7 @@ namespace Xamarin.Forms.Platform.Tizen
NaviItem item = GetNaviItemForPage(page);
item.TitleBarVisible = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
UpdateToolbarItem(page, item);
+ UpdateBarBackgroundColor(item);
}
void UpdateToolbarItem(Page page, NaviItem item = null)
@@ -171,9 +179,11 @@ namespace Xamarin.Forms.Platform.Tizen
item.SetPartContent(_partBackButton, button);
}
- void UpdateTitle(Page page)
+ void UpdateTitle(Page page, NaviItem item = null)
{
- NaviItem item = GetNaviItemForPage(page);
+ if (item == null)
+ item = GetNaviItemForPage(page);
+
item.SetPartText(_partTitle, SpanTitle(page.Title));
}
@@ -185,21 +195,23 @@ namespace Xamarin.Forms.Platform.Tizen
HorizontalTextAlignment = Native.TextAlignment.Center,
ForegroundColor = Element.BarTextColor.ToNative()
};
-
- //TODO: changes only background of title not all bar
- if (Element.BarBackgroundColor != Color.Default)
- {
- span.BackgroundColor = Element.BarBackgroundColor.ToNative();
- }
- else if (Element.Tint != Color.Default)
- {
- //TODO: This is only for backward compatibility
- //- remove when Tint is no longer in Xamarin API
- span.BackgroundColor = Element.Tint.ToNative();
- }
return span.GetMarkupText();
}
+ void UpdateBarBackgroundColor(NaviItem item)
+ {
+ item.TitleBarBackgroundColor = Element.BarBackgroundColor.ToNative();
+ }
+
+ void UpdateNavigationBar(Page page, NaviItem item = null)
+ {
+ if (item == null)
+ item = GetNaviItemForPage(page);
+
+ UpdateTitle(page, item);
+ UpdateBarBackgroundColor(item);
+ }
+
EButton CreateNavigationButton(string text)
{
EButton button = new EButton(Forms.Context.MainWindow);
@@ -289,6 +301,8 @@ namespace Xamarin.Forms.Platform.Tizen
{
if ((Element as IPageController).InternalChildren.Count == _naviFrame.NavigationStack.Count)
{
+ UpdateNavigationBar(PreviousPage, PreviousNaviItem);
+
if (nre.Animated)
{
_naviFrame.Pop();
@@ -301,7 +315,7 @@ namespace Xamarin.Forms.Platform.Tizen
CompleteCurrentNavigationTask();
}
else
- _naviFrame.NavigationStack.Last().Delete();
+ CurrentNaviItem?.Delete();
}
}
@@ -318,6 +332,7 @@ namespace Xamarin.Forms.Platform.Tizen
if (topItem != rootItem)
{
+ UpdateNavigationBar(Element.Navigation.NavigationStack.Last(), rootItem);
if (nre.Animated)
{
_naviFrame.Pop();
@@ -369,7 +384,6 @@ namespace Xamarin.Forms.Platform.Tizen
tcs.SetResult(true);
UpdateHasNavigationBar(nre.Page);
-
return false;
});
}