Revert "[GTK] Fix visibility of hidden pages in the stack (#3904) (#8096)
authorAndres G. Aragoneses <knocte@gmail.com>
Wed, 23 Oct 2019 23:02:59 +0000 (07:02 +0800)
committerSamantha Houts <samhouts@users.noreply.github.com>
Wed, 23 Oct 2019 23:02:59 +0000 (16:02 -0700)
* Revert "[GTK] Fix visibility of hidden pages in the stack (#3904)"

This reverts commit b5b9404bda761e7e5941da7ff26f1d42dd62d1b2.

# Conflicts:
# Xamarin.Forms.Platform.GTK/Controls/Page.cs

* Added test sample for #6663
Fixes #6663

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6663.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.CustomAttributes/TestAttributes.cs
Xamarin.Forms.Platform.GTK/Controls/Page.cs
Xamarin.Forms.Platform.GTK/Platform.cs
Xamarin.Forms.Platform.GTK/Renderers/NavigationPageRenderer.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6663.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6663.cs
new file mode 100644 (file)
index 0000000..99b0675
--- /dev/null
@@ -0,0 +1,78 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using NUnit.Framework;
+using Xamarin.UITest;
+using Xamarin.Forms.Core.UITests;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Github, 6663, "Fix visibility of hidden pages in the stack", PlatformAffected.Gtk)]
+#if UITEST
+       [NUnit.Framework.Category(UITestCategories.Navigation)]
+#endif
+       public class Issue6663 : ContentPage
+       {
+               public Issue6663()
+               {
+                       Title = "Issue 6663";
+                       BackgroundColor = Color.Green;
+
+                       var layout = new StackLayout();
+
+                       var instructions = new Label
+                       {
+                               Text = "Press the button below to navigate to a new page. Navigate back and verify that the navigation bar is visible and the page is rendered correctly."
+                       };
+
+                       var navigateButton = new Button
+                       {
+                               Text = "Navigate"
+                       };
+
+                       navigateButton.Clicked += (sender, e) =>
+                       {
+                               Navigation.PushAsync(new Issue663SecondPage());
+                       };
+
+                       layout.Children.Add(instructions);
+                       layout.Children.Add(navigateButton);
+
+                       Content = layout;
+               }
+       }
+
+       internal class Issue663SecondPage : ContentPage
+       {
+               public Issue663SecondPage()
+               {
+                       Title = "Issue 6663 SecondPage";
+                       BackgroundColor = Color.Red;
+
+                       var layout = new StackLayout();
+
+                       var instructions = new Label
+                       {
+                               Text = "Press the button below to navigate back."
+                       };
+
+                       var navigateButton = new Button
+                       {
+                               Text = "Navigate Back"
+                       };
+
+                       navigateButton.Clicked += (sender, e) =>
+                       {
+                               Navigation.PopAsync();
+                       };
+
+                       layout.Children.Add(instructions);
+                       layout.Children.Add(navigateButton);
+
+                       Content = layout;
+               }
+       }
+}
\ No newline at end of file
index 87734b6..fbb6caa 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)Issue6127.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7283.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue5395.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Issue6663.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue8004.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Issue7886.xaml.cs">
       <DependentUpon>Issue7886.xaml</DependentUpon>
index 130a043..08c6211 100644 (file)
@@ -149,6 +149,7 @@ namespace Xamarin.Forms.CustomAttributes
                UWP = 1 << 4,
                WPF = 1 << 5,
                macOS = 1 << 6,
+               Gtk = 1 << 7,
                All = ~0,
                Default = 0
        }
index dfacec4..0c32dc3 100644 (file)
@@ -1,7 +1,6 @@
 using Gdk;
 using Gtk;
 using System;
-using System.Linq;
 using Xamarin.Forms.Platform.GTK.Extensions;
 
 namespace Xamarin.Forms.Platform.GTK.Controls
@@ -67,22 +66,6 @@ namespace Xamarin.Forms.Platform.GTK.Controls
                        _image.Pixbuf = await imageSource.GetNativeImageAsync();
                }
 
-               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 Destroy()
                {
                        base.Destroy();
index a726009..7084e44 100644 (file)
@@ -188,7 +188,28 @@ namespace Xamarin.Forms.Platform.GTK
 
                        Device.BeginInvokeOnMainThread(() =>
                        {
-                               pageControl?.Control?.PopModal(modalPage);
+                               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();
+                                               }
+                                       }
+                               }
 
                                DisposeModelAndChildrenRenderers(modal);
                        });
@@ -250,7 +271,17 @@ namespace Xamarin.Forms.Platform.GTK
 
                                        if (page != null)
                                        {
-                                               page.PushModal(modalRenderer.Container);
+                                               page.Attach(modalRenderer.Container, 0, 1, 0, 1);
+
+                                               if (page.Children != null)
+                                               {
+                                                       foreach (var child in page.Children)
+                                                       {
+                                                               child.ShowAll();
+                                                       }
+
+                                                       page.ShowAll();
+                                               }
                                        }
                                }
                        });
index 1cd77c6..8869718 100644 (file)
@@ -345,7 +345,7 @@ namespace Xamarin.Forms.Platform.GTK.Renderers
                        if (oldPage != null && Platform.GetRenderer(oldPage) != null)
                        {
                                var oldPageRenderer = Platform.GetRenderer(oldPage);
-                               oldPageRenderer.Container.Visible = false;
+                               oldPageRenderer.Container.Sensitive = false;
                        }
 
                        return true;
@@ -358,7 +358,7 @@ namespace Xamarin.Forms.Platform.GTK.Renderers
                        if (oldPage != null && Platform.GetRenderer(oldPage) != null)
                        {
                                var oldPageRenderer = Platform.GetRenderer(oldPage);
-                               oldPageRenderer.Container.Visible = true;
+                               oldPageRenderer.Container.Sensitive = true;
                        }
 
                        (page as IPageController)?.SendDisappearing();