Родитель
6943f73e91
Коммит
0d6559c31d
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using ElmSharp;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Tizen.Native
|
||||
{
|
||||
public class TitleViewPage : Native.Box
|
||||
{
|
||||
Native.Page _page = null;
|
||||
View _titleView = null;
|
||||
bool _hasNavigationBar = true;
|
||||
|
||||
public TitleViewPage(EvasObject parent, Xamarin.Forms.Page page, View titleView) : base(parent)
|
||||
{
|
||||
_page = Platform.GetOrCreateRenderer(page).NativeView as Native.Page;
|
||||
_titleView = titleView;
|
||||
if (_titleView != null)
|
||||
{
|
||||
var renderer = Platform.GetOrCreateRenderer(_titleView);
|
||||
(renderer as LayoutRenderer)?.RegisterOnLayoutUpdated();
|
||||
|
||||
this.PackEnd(renderer.NativeView);
|
||||
}
|
||||
this.PackEnd(_page);
|
||||
this.LayoutUpdated += OnLayoutUpdated;
|
||||
}
|
||||
|
||||
public bool HasNavigationBar
|
||||
{
|
||||
get
|
||||
{
|
||||
return _hasNavigationBar;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_hasNavigationBar != value)
|
||||
{
|
||||
_hasNavigationBar = value;
|
||||
UpdatPageLayout(this, new LayoutEventArgs() { Geometry = this.Geometry });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OnLayoutUpdated(object sender, LayoutEventArgs e)
|
||||
{
|
||||
UpdatPageLayout(sender, e);
|
||||
}
|
||||
|
||||
void UpdatPageLayout(object sender, LayoutEventArgs e)
|
||||
{
|
||||
double dHeight = _titleView.Measure(Forms.ConvertToScaledDP(e.Geometry.Width), Forms.ConvertToScaledDP(e.Geometry.Height)).Request.Height;
|
||||
int height = 0;
|
||||
if (_hasNavigationBar)
|
||||
{
|
||||
height = Forms.ConvertToScaledPixel(dHeight);
|
||||
}
|
||||
|
||||
var renderer = Platform.GetOrCreateRenderer(_titleView);
|
||||
renderer.NativeView.Move(e.Geometry.X, e.Geometry.Y);
|
||||
renderer.NativeView.Resize(e.Geometry.Width, height);
|
||||
|
||||
_page.Move(e.Geometry.X, e.Geometry.Y + height);
|
||||
_page.Resize(e.Geometry.Width, e.Geometry.Height - height);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -115,7 +115,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
|
||||
foreach (Page page in pageController.InternalChildren)
|
||||
{
|
||||
_naviItemMap[page] = _naviFrame.Push(Platform.GetRenderer(page).NativeView, SpanTitle(page.Title));
|
||||
_naviItemMap[page] = _naviFrame.Push(CreateNavItem(page), SpanTitle(page.Title));
|
||||
page.PropertyChanged += NavigationBarPropertyChangedHandler;
|
||||
|
||||
UpdateHasNavigationBar(page);
|
||||
|
@ -177,6 +177,16 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
void UpdateHasNavigationBar(Page page)
|
||||
{
|
||||
NaviItem item = GetNaviItemForPage(page);
|
||||
if (NavigationPage.GetTitleView(page) != null)
|
||||
{
|
||||
item.TitleBarVisible = false;
|
||||
Native.TitleViewPage tvPage = item.Content as Native.TitleViewPage;
|
||||
if (tvPage != null)
|
||||
{
|
||||
tvPage.HasNavigationBar = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//According to TV UX Guideline, item style should be set to "tabbar" in case of TabbedPage only for TV profile.
|
||||
if (Device.Idiom == TargetIdiom.TV)
|
||||
{
|
||||
|
@ -434,7 +444,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
{
|
||||
if (nre.Animated || _naviFrame.NavigationStack.Count == 0)
|
||||
{
|
||||
_naviItemMap[nre.Page] = _naviFrame.Push(Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title));
|
||||
_naviItemMap[nre.Page] = _naviFrame.Push(CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
|
||||
_currentTaskSource = new TaskCompletionSource<bool>();
|
||||
nre.Task = _currentTaskSource.Task;
|
||||
|
||||
|
@ -444,7 +454,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
}
|
||||
else
|
||||
{
|
||||
_naviItemMap[nre.Page] = _naviFrame.InsertAfter(_naviFrame.NavigationStack.Last(), Platform.GetOrCreateRenderer(nre.Page).NativeView, SpanTitle(nre.Page.Title));
|
||||
_naviItemMap[nre.Page] = _naviFrame.InsertAfter(_naviFrame.NavigationStack.Last(), CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
|
||||
}
|
||||
UpdateHasNavigationBar(nre.Page);
|
||||
}
|
||||
|
@ -463,8 +473,7 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
if (nre.Page == null)
|
||||
throw new ArgumentNullException("page");
|
||||
|
||||
EvasObject page = Platform.GetOrCreateRenderer(nre.Page).NativeView;
|
||||
_naviItemMap[nre.Page] = _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), page, SpanTitle(nre.Page.Title));
|
||||
_naviItemMap[nre.Page] = _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
|
||||
UpdateHasNavigationBar(nre.Page);
|
||||
}
|
||||
|
||||
|
@ -482,5 +491,23 @@ namespace Xamarin.Forms.Platform.Tizen
|
|||
tmp.SetResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
EvasObject CreateNavItem(Page page)
|
||||
{
|
||||
View titleView = NavigationPage.GetTitleView(page) as View;
|
||||
EvasObject nativeView = null;
|
||||
if (titleView != null)
|
||||
{
|
||||
titleView.Parent = this.Element;
|
||||
nativeView = new Native.TitleViewPage(Forms.NativeParent, page, titleView);
|
||||
nativeView.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
nativeView = Platform.GetOrCreateRenderer(page).NativeView;
|
||||
|
||||
}
|
||||
return nativeView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче