[Windows] Fix modal pages being laid out below soft buttons (#395)

This commit is contained in:
Jimmy Garrido 2016-12-16 17:08:03 -08:00 коммит произвёл Rui Marinho
Родитель 3216ce4ccd
Коммит 6c8abfdc14
2 изменённых файлов: 5 добавлений и 37 удалений

Просмотреть файл

@ -14,18 +14,6 @@ namespace Xamarin.Forms.Platform.WinRT
_status.Hiding += OnStatusBarHiding;
}
internal override Rectangle WindowBounds
{
get
{
bool landscape = Device.Info.CurrentOrientation.IsLandscape ();
double offset = (landscape) ? _status.OccludedRect.Width : _status.OccludedRect.Height;
Rectangle original = base.WindowBounds;
return new Rectangle (original.X, original.Y, original.Width - ((landscape) ? offset : 0), original.Height - ((landscape) ? 0 : offset));
}
}
readonly StatusBar _status;
void OnStatusBarHiding (StatusBar sender, object args)

Просмотреть файл

@ -213,14 +213,14 @@ namespace Xamarin.Forms.Platform.WinRT
return new SizeRequest();
}
internal virtual Rectangle WindowBounds
internal virtual Rectangle ContainerBounds
{
get { return _bounds; }
}
internal void UpdatePageSizes()
{
Rectangle bounds = WindowBounds;
Rectangle bounds = ContainerBounds;
if (bounds.IsEmpty)
return;
foreach (Page root in _navModel.Roots)
@ -435,27 +435,7 @@ namespace Xamarin.Forms.Platform.WinRT
void UpdateBounds()
{
_bounds = new Rectangle(0, 0, _page.ActualWidth, _page.ActualHeight);
#if WINDOWS_UWP
StatusBar statusBar = MobileStatusBar;
if (statusBar != null)
{
bool landscape = Device.Info.CurrentOrientation.IsLandscape();
bool titleBar = CoreApplication.GetCurrentView().TitleBar.IsVisible;
double offset = landscape ? statusBar.OccludedRect.Width : statusBar.OccludedRect.Height;
_bounds = new Rectangle(0, 0, _page.ActualWidth - (landscape ? offset : 0), _page.ActualHeight - (landscape ? 0 : offset));
// Even if the MainPage is a ContentPage not inside of a NavigationPage, the calculated bounds
// assume the TitleBar is there even if it isn't visible. When UpdatePageSizes is called,
// _container.ActualWidth is correct because it's aware that the TitleBar isn't there, but the
// bounds aren't, and things can subsequently run under the StatusBar.
if (!titleBar)
{
_bounds.Width -= (_bounds.Width - _container.ActualWidth);
}
}
#endif
_bounds = new Rectangle(0, 0, _container.ActualWidth, _container.ActualHeight);
}
void OnRendererSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
@ -481,7 +461,7 @@ namespace Xamarin.Forms.Platform.WinRT
previousPage.Cleanup();
}
newPage.Layout(new Rectangle(0, 0, _page.ActualWidth, _page.ActualHeight));
newPage.Layout(ContainerBounds);
IVisualElementRenderer pageRenderer = newPage.GetOrCreateRenderer();
_container.Children.Add(pageRenderer.ContainerElement);
@ -726,7 +706,7 @@ namespace Xamarin.Forms.Platform.WinRT
if (Device.Idiom == TargetIdiom.Phone)
{
double height = WindowBounds.Height;
double height = _page.ActualHeight;
stack.Height = height;
stack.Width = size.Width;
border.BorderThickness = new Windows.UI.Xaml.Thickness(0);