Skip to content

Commit

Permalink
[GTK] Fix visibility of hidden pages in the stack (xamarin#3904)
Browse files Browse the repository at this point in the history
When navigating to a new page, we should hide the previous
content and show the new one so that the previous page
renderer is not taken in account for redraws and resizes
  • Loading branch information
ylatuya authored and almirvuk committed Nov 14, 2018
1 parent b19c66a commit 01dcc4e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 35 deletions.
17 changes: 17 additions & 0 deletions Xamarin.Forms.Platform.GTK/Controls/Page.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Gdk;
using Gtk;
using System;
using System.Linq;
using Xamarin.Forms.Platform.GTK.Extensions;

namespace Xamarin.Forms.Platform.GTK.Controls
Expand Down Expand Up @@ -93,6 +94,22 @@ public void SetBackgroundImage(string backgroundImagePath)
}
}

public void PushModal(Widget modal)
{
Children.Last().Hide();
Attach(modal, 0, 1, 0, 1);
modal.ShowAll();
}

public void PopModal(Widget modal)
{
if (Children.Length > 0)
{
Remove(modal);
}
Children.Last().Show();
}

public override void Dispose()
{
base.Dispose();
Expand Down
35 changes: 2 additions & 33 deletions Xamarin.Forms.Platform.GTK/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,7 @@ Task<Page> INavigation.PopModalAsync(bool animated)

Device.BeginInvokeOnMainThread(() =>
{
if (pageControl != null)
{
var page = pageControl.Control;
if (page != null)
{
if (page.Children.Length > 0)
{
page.Remove(modalPage);
}
if (page.Children != null)
{
foreach (var child in page.Children)
{
child.ShowAll();
}
page.ShowAll();
}
}
}
pageControl?.Control?.PopModal(modalPage);
DisposeModelAndChildrenRenderers(modal);
});
Expand Down Expand Up @@ -258,17 +237,7 @@ Task INavigation.PushModalAsync(Page modal, bool animated)
if (page != null)
{
page.Attach(modalRenderer.Container, 0, 1, 0, 1);
if (page.Children != null)
{
foreach (var child in page.Children)
{
child.ShowAll();
}
page.ShowAll();
}
page.PushModal(modalRenderer.Container);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private async Task<bool> AddPageAsync(Page page, bool animated)
if (oldPage != null && Platform.GetRenderer(oldPage) != null)
{
var oldPageRenderer = Platform.GetRenderer(oldPage);
oldPageRenderer.Container.Sensitive = false;
oldPageRenderer.Container.Visible = false;
}

return true;
Expand All @@ -343,7 +343,7 @@ private async Task RemovePageAsync(Page page, bool removeFromStack, bool animate
if (oldPage != null && Platform.GetRenderer(oldPage) != null)
{
var oldPageRenderer = Platform.GetRenderer(oldPage);
oldPageRenderer.Container.Sensitive = true;
oldPageRenderer.Container.Visible = true;
}

(page as IPageController)?.SendDisappearing();
Expand Down

0 comments on commit 01dcc4e

Please sign in to comment.