summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchungryeol lim <cdark.lim@samsung.com>2016-12-19 04:22:27 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-03-24 04:18:58 (GMT)
commitcff8c0237a263222282f7e403feb431ee874c27c (patch)
treefe0fe78698b0acdf9dceb160c6758e17c4ac3e57
parent3cf5635ef16736538b3edf06edfa1db3a8f5679d (diff)
downloadxamarin-forms-cff8c0237a263222282f7e403feb431ee874c27c.zip
xamarin-forms-cff8c0237a263222282f7e403feb431ee874c27c.tar.gz
xamarin-forms-cff8c0237a263222282f7e403feb431ee874c27c.tar.bz2
Fixed NavigationPage.BarBackgroundColor Property
- Apply whole area "BarBackgroundColor" - Property values for page push & pop Signed-off-by: chungryeol lim <cdark.lim@samsung.com> Change-Id: I8082be5d57cbea2b3a5b9a1cc533429d080b50c6
-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 e760489..c8f8606 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;
});
}