2016-03-22 23:02:25 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Windows.Devices.Input;
|
|
|
|
|
using Windows.UI.Input;
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Automation;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
using Windows.UI.Xaml.Input;
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
using Windows.UI.Xaml.Media.Animation;
|
2016-05-04 15:18:40 +03:00
|
|
|
|
using Xamarin.Forms.Internals;
|
2016-08-30 20:46:14 +03:00
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
using Windows.UI.Core;
|
|
|
|
|
namespace Xamarin.Forms.Platform.UWP
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
namespace Xamarin.Forms.Platform.WinRT
|
|
|
|
|
#endif
|
|
|
|
|
{
|
2017-01-28 03:14:21 +03:00
|
|
|
|
public partial class NavigationPageRenderer : IVisualElementRenderer, ITitleProvider, IToolbarProvider
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
|
|
|
|
PageControl _container;
|
|
|
|
|
Page _currentPage;
|
|
|
|
|
Page _previousPage;
|
|
|
|
|
|
|
|
|
|
bool _disposed;
|
2017-01-28 03:14:21 +03:00
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
MasterDetailPage _parentMasterDetailPage;
|
|
|
|
|
TabbedPage _parentTabbedPage;
|
|
|
|
|
bool _showTitle = true;
|
|
|
|
|
VisualElementTracker<Page, PageControl> _tracker;
|
|
|
|
|
ContentThemeTransition _transition;
|
|
|
|
|
|
|
|
|
|
public NavigationPage Element { get; private set; }
|
|
|
|
|
|
|
|
|
|
protected VisualElementTracker<Page, PageControl> Tracker
|
|
|
|
|
{
|
|
|
|
|
get { return _tracker; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_tracker == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_tracker != null)
|
|
|
|
|
_tracker.Dispose();
|
|
|
|
|
|
|
|
|
|
_tracker = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Dispose(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Brush ITitleProvider.BarBackgroundBrush
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
2016-08-30 20:46:14 +03:00
|
|
|
|
_container.ToolbarBackground = value;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Brush ITitleProvider.BarForegroundBrush
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_container.TitleBrush = value;
|
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-16 18:45:09 +03:00
|
|
|
|
IPageController PageController => Element as IPageController;
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
bool ITitleProvider.ShowTitle
|
|
|
|
|
{
|
|
|
|
|
get { return _showTitle; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_showTitle == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_showTitle = value;
|
2016-08-30 20:46:14 +03:00
|
|
|
|
UpdateTitleVisible();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Title
|
|
|
|
|
{
|
|
|
|
|
get { return _currentPage?.Title; }
|
|
|
|
|
|
|
|
|
|
set { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task<CommandBar> IToolbarProvider.GetCommandBarAsync()
|
|
|
|
|
{
|
|
|
|
|
return ((IToolbarProvider)_container)?.GetCommandBarAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FrameworkElement ContainerElement
|
|
|
|
|
{
|
|
|
|
|
get { return _container; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VisualElement IVisualElementRenderer.Element
|
|
|
|
|
{
|
|
|
|
|
get { return Element; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
|
|
|
|
|
|
|
|
|
|
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
|
|
|
|
|
{
|
|
|
|
|
var constraint = new Windows.Foundation.Size(widthConstraint, heightConstraint);
|
|
|
|
|
IVisualElementRenderer childRenderer = Platform.GetRenderer(Element.CurrentPage);
|
|
|
|
|
FrameworkElement child = childRenderer.ContainerElement;
|
|
|
|
|
|
|
|
|
|
double oldWidth = child.Width;
|
|
|
|
|
double oldHeight = child.Height;
|
|
|
|
|
|
|
|
|
|
child.Height = double.NaN;
|
|
|
|
|
child.Width = double.NaN;
|
|
|
|
|
|
|
|
|
|
child.Measure(constraint);
|
|
|
|
|
var result = new Size(Math.Ceiling(child.DesiredSize.Width), Math.Ceiling(child.DesiredSize.Height));
|
|
|
|
|
|
|
|
|
|
child.Width = oldWidth;
|
|
|
|
|
child.Height = oldHeight;
|
|
|
|
|
|
|
|
|
|
return new SizeRequest(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetElement(VisualElement element)
|
|
|
|
|
{
|
|
|
|
|
if (element != null && !(element is NavigationPage))
|
2017-01-28 03:14:21 +03:00
|
|
|
|
throw new ArgumentException("Element must be a Page", nameof(element));
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
NavigationPage oldElement = Element;
|
|
|
|
|
Element = (NavigationPage)element;
|
|
|
|
|
|
|
|
|
|
if (oldElement != null)
|
|
|
|
|
{
|
2016-05-04 15:18:40 +03:00
|
|
|
|
((INavigationPageController)oldElement).PushRequested -= OnPushRequested;
|
|
|
|
|
((INavigationPageController)oldElement).PopRequested -= OnPopRequested;
|
2016-05-26 22:14:56 +03:00
|
|
|
|
((INavigationPageController)oldElement).PopToRootRequested -= OnPopToRootRequested;
|
2016-06-16 18:45:09 +03:00
|
|
|
|
((IPageController)oldElement).InternalChildren.CollectionChanged -= OnChildrenChanged;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
oldElement.PropertyChanged -= OnElementPropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (element != null)
|
|
|
|
|
{
|
|
|
|
|
if (_container == null)
|
|
|
|
|
{
|
|
|
|
|
_container = new PageControl();
|
|
|
|
|
_container.PointerPressed += OnPointerPressed;
|
|
|
|
|
_container.SizeChanged += OnNativeSizeChanged;
|
|
|
|
|
_container.BackClicked += OnBackClicked;
|
|
|
|
|
|
|
|
|
|
Tracker = new BackgroundTracker<PageControl>(Control.BackgroundProperty) { Element = (Page)element, Container = _container };
|
|
|
|
|
|
2017-01-03 14:25:24 +03:00
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
// Enforce consistency rules on toolbar (show toolbar if top-level page is Navigation Page)
|
|
|
|
|
_container.ShouldShowToolbar = _parentMasterDetailPage == null && _parentMasterDetailPage == null;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
SetPage(Element.CurrentPage, false, false);
|
|
|
|
|
|
|
|
|
|
_container.Loaded += OnLoaded;
|
|
|
|
|
_container.Unloaded += OnUnloaded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_container.DataContext = Element.CurrentPage;
|
|
|
|
|
|
|
|
|
|
UpdatePadding();
|
|
|
|
|
LookupRelevantParents();
|
|
|
|
|
UpdateTitleColor();
|
|
|
|
|
UpdateNavigationBarBackground();
|
2017-01-28 03:14:21 +03:00
|
|
|
|
UpdateToolbarPlacement();
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
Element.PropertyChanged += OnElementPropertyChanged;
|
2016-05-04 15:18:40 +03:00
|
|
|
|
((INavigationPageController)Element).PushRequested += OnPushRequested;
|
|
|
|
|
((INavigationPageController)Element).PopRequested += OnPopRequested;
|
2016-05-26 22:14:56 +03:00
|
|
|
|
((INavigationPageController)Element).PopToRootRequested += OnPopToRootRequested;
|
2016-06-16 18:45:09 +03:00
|
|
|
|
PageController.InternalChildren.CollectionChanged += OnChildrenChanged;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Element.AutomationId))
|
|
|
|
|
_container.SetValue(AutomationProperties.AutomationIdProperty, Element.AutomationId);
|
|
|
|
|
|
|
|
|
|
PushExistingNavigationStack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Dispose(bool disposing)
|
|
|
|
|
{
|
2017-01-28 03:14:21 +03:00
|
|
|
|
if (_disposed || !disposing)
|
|
|
|
|
{
|
2016-03-22 23:02:25 +03:00
|
|
|
|
return;
|
2017-01-28 03:14:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-16 18:45:09 +03:00
|
|
|
|
PageController?.SendDisappearing();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
_disposed = true;
|
|
|
|
|
|
|
|
|
|
_container.PointerPressed -= OnPointerPressed;
|
|
|
|
|
_container.SizeChanged -= OnNativeSizeChanged;
|
|
|
|
|
_container.BackClicked -= OnBackClicked;
|
|
|
|
|
|
|
|
|
|
SetElement(null);
|
|
|
|
|
SetPage(null, false, true);
|
|
|
|
|
_previousPage = null;
|
|
|
|
|
|
|
|
|
|
if (_parentTabbedPage != null)
|
|
|
|
|
_parentTabbedPage.PropertyChanged -= MultiPagePropertyChanged;
|
|
|
|
|
|
|
|
|
|
if (_parentMasterDetailPage != null)
|
|
|
|
|
_parentMasterDetailPage.PropertyChanged -= MultiPagePropertyChanged;
|
2016-06-16 19:31:50 +03:00
|
|
|
|
|
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
if (_navManager != null)
|
|
|
|
|
{
|
|
|
|
|
_navManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void OnElementChanged(VisualElementChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EventHandler<VisualElementChangedEventArgs> changed = ElementChanged;
|
|
|
|
|
if (changed != null)
|
|
|
|
|
changed(this, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Brush GetBarBackgroundBrush()
|
|
|
|
|
{
|
2017-01-28 03:14:21 +03:00
|
|
|
|
object defaultColor = GetDefaultColor();
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
if (Element.BarBackgroundColor.IsDefault && defaultColor != null)
|
|
|
|
|
return (Brush)defaultColor;
|
|
|
|
|
return Element.BarBackgroundColor.ToBrush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Brush GetBarForegroundBrush()
|
|
|
|
|
{
|
|
|
|
|
object defaultColor = Windows.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"];
|
|
|
|
|
if (Element.BarTextColor.IsDefault)
|
|
|
|
|
return (Brush)defaultColor;
|
|
|
|
|
return Element.BarTextColor.ToBrush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool GetIsNavBarPossible()
|
|
|
|
|
{
|
|
|
|
|
return _showTitle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LookupRelevantParents()
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<Page> parentPages = Element.GetParentPages();
|
|
|
|
|
|
|
|
|
|
if (_parentTabbedPage != null)
|
|
|
|
|
_parentTabbedPage.PropertyChanged -= MultiPagePropertyChanged;
|
|
|
|
|
if (_parentMasterDetailPage != null)
|
|
|
|
|
_parentMasterDetailPage.PropertyChanged -= MultiPagePropertyChanged;
|
|
|
|
|
|
|
|
|
|
foreach (Page parentPage in parentPages)
|
|
|
|
|
{
|
|
|
|
|
_parentTabbedPage = parentPage as TabbedPage;
|
|
|
|
|
_parentMasterDetailPage = parentPage as MasterDetailPage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_parentTabbedPage != null)
|
|
|
|
|
_parentTabbedPage.PropertyChanged += MultiPagePropertyChanged;
|
|
|
|
|
if (_parentMasterDetailPage != null)
|
|
|
|
|
_parentMasterDetailPage.PropertyChanged += MultiPagePropertyChanged;
|
2017-01-03 14:25:24 +03:00
|
|
|
|
|
2017-01-28 03:14:21 +03:00
|
|
|
|
UpdateShowTitle();
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MultiPagePropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.PropertyName == "CurrentPage" || e.PropertyName == "Detail")
|
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async void OnBackClicked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
await Element.PopAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnChildrenChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateBackButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnCurrentPagePropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName)
|
|
|
|
|
UpdateBackButton();
|
|
|
|
|
else if (e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
|
|
|
|
|
UpdateBackButtonTitle();
|
|
|
|
|
else if (e.PropertyName == NavigationPage.HasNavigationBarProperty.PropertyName)
|
2016-08-30 20:46:14 +03:00
|
|
|
|
UpdateTitleVisible();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName)
|
|
|
|
|
UpdateTitleColor();
|
|
|
|
|
else if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName)
|
|
|
|
|
UpdateNavigationBarBackground();
|
|
|
|
|
else if (e.PropertyName == Page.PaddingProperty.PropertyName)
|
|
|
|
|
UpdatePadding();
|
2017-01-28 03:14:21 +03:00
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
else if (e.PropertyName == PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty.PropertyName)
|
2016-08-30 20:46:14 +03:00
|
|
|
|
UpdateToolbarPlacement();
|
2017-01-28 03:14:21 +03:00
|
|
|
|
#endif
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnLoaded(object sender, RoutedEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
if (Element == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
_navManager = SystemNavigationManager.GetForCurrentView();
|
|
|
|
|
#endif
|
2016-06-16 18:45:09 +03:00
|
|
|
|
PageController.SendAppearing();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
UpdateBackButton();
|
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnNativeSizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateContainerArea();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnPointerPressed(object sender, PointerRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Handled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PointerPoint point = e.GetCurrentPoint(_container);
|
|
|
|
|
if (point == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (point.PointerDevice.PointerDeviceType != PointerDeviceType.Mouse)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (point.Properties.IsXButton1Pressed)
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
OnBackClicked(_container, e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnPopRequested(object sender, NavigationRequestedEventArgs e)
|
|
|
|
|
{
|
2017-01-23 22:42:38 +03:00
|
|
|
|
var newCurrent = ((INavigationPageController)Element).Peek(1);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
SetPage(newCurrent, e.Animated, true);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 22:14:56 +03:00
|
|
|
|
void OnPopToRootRequested(object sender, NavigationRequestedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SetPage(e.Page, e.Animated, true);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
void OnPushRequested(object sender, NavigationRequestedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SetPage(e.Page, e.Animated, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnUnloaded(object sender, RoutedEventArgs args)
|
|
|
|
|
{
|
2016-06-16 18:45:09 +03:00
|
|
|
|
PageController?.SendDisappearing();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PushExistingNavigationStack()
|
|
|
|
|
{
|
2017-01-23 22:42:38 +03:00
|
|
|
|
foreach (var page in ((INavigationPageController)Element).Pages)
|
|
|
|
|
{
|
|
|
|
|
SetPage(page, false, false);
|
|
|
|
|
}
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetPage(Page page, bool isAnimated, bool isPopping)
|
|
|
|
|
{
|
|
|
|
|
if (_currentPage != null)
|
|
|
|
|
{
|
|
|
|
|
if (isPopping)
|
|
|
|
|
_currentPage.Cleanup();
|
|
|
|
|
|
|
|
|
|
_container.Content = null;
|
|
|
|
|
|
|
|
|
|
_currentPage.PropertyChanged -= OnCurrentPagePropertyChanged;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-06 15:01:43 +03:00
|
|
|
|
if (!isPopping)
|
|
|
|
|
_previousPage = _currentPage;
|
|
|
|
|
|
2016-03-22 23:02:25 +03:00
|
|
|
|
_currentPage = page;
|
|
|
|
|
|
|
|
|
|
if (page == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
UpdateBackButton();
|
|
|
|
|
UpdateBackButtonTitle();
|
|
|
|
|
|
|
|
|
|
page.PropertyChanged += OnCurrentPagePropertyChanged;
|
|
|
|
|
|
|
|
|
|
IVisualElementRenderer renderer = page.GetOrCreateRenderer();
|
|
|
|
|
|
2016-08-30 20:46:14 +03:00
|
|
|
|
UpdateTitleVisible();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
|
|
|
|
|
if (isAnimated && _transition == null)
|
|
|
|
|
{
|
|
|
|
|
_transition = new ContentThemeTransition();
|
|
|
|
|
_container.ContentTransitions = new TransitionCollection();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isAnimated && _transition != null)
|
|
|
|
|
_container.ContentTransitions.Remove(_transition);
|
|
|
|
|
else if (isAnimated && _container.ContentTransitions.Count == 0)
|
|
|
|
|
_container.ContentTransitions.Add(_transition);
|
|
|
|
|
|
|
|
|
|
_container.Content = renderer.ContainerElement;
|
|
|
|
|
_container.DataContext = page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateBackButtonTitle()
|
|
|
|
|
{
|
|
|
|
|
string title = null;
|
|
|
|
|
if (_previousPage != null)
|
|
|
|
|
title = NavigationPage.GetBackButtonTitle(_previousPage);
|
|
|
|
|
|
|
|
|
|
_container.BackButtonTitle = title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateContainerArea()
|
|
|
|
|
{
|
2016-06-16 18:45:09 +03:00
|
|
|
|
PageController.ContainerArea = new Rectangle(0, 0, _container.ContentWidth, _container.ContentHeight);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateNavigationBarBackground()
|
|
|
|
|
{
|
|
|
|
|
(this as ITitleProvider).BarBackgroundBrush = GetBarBackgroundBrush();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-30 20:46:14 +03:00
|
|
|
|
void UpdateTitleVisible()
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
|
|
|
|
UpdateTitleOnParents();
|
|
|
|
|
|
2016-08-30 20:46:14 +03:00
|
|
|
|
bool showing = _container.TitleVisibility == Visibility.Visible;
|
2016-10-20 22:57:30 +03:00
|
|
|
|
bool newValue = GetIsNavBarPossible() && NavigationPage.GetHasNavigationBar(_currentPage);
|
2016-03-22 23:02:25 +03:00
|
|
|
|
if (showing == newValue)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-08-30 20:46:14 +03:00
|
|
|
|
_container.TitleVisibility = newValue ? Visibility.Visible : Visibility.Collapsed;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
// Force ContentHeight/Width to update, doesn't work from inside PageControl for some reason
|
|
|
|
|
_container.UpdateLayout();
|
|
|
|
|
UpdateContainerArea();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdatePadding()
|
|
|
|
|
{
|
|
|
|
|
_container.TitleInset = Element.Padding.Left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateTitleColor()
|
|
|
|
|
{
|
|
|
|
|
(this as ITitleProvider).BarForegroundBrush = GetBarForegroundBrush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|