summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRui Marinho <me@ruimarinho.net>2016-06-16 17:20:12 +0100
committerGitHub <noreply@github.com>2016-06-16 17:20:12 +0100
commit87f1418d2ffe1913a0b1c312119d839a5bb234ba (patch)
tree40ab7198b1000683f90fa27da12c3495165e5a12
parented517a3027fb8a273b1f4226622cf88378091cd9 (diff)
downloadxamarin-forms-87f1418d2ffe1913a0b1c312119d839a5bb234ba.tar.gz
xamarin-forms-87f1418d2ffe1913a0b1c312119d839a5bb234ba.tar.bz2
xamarin-forms-87f1418d2ffe1913a0b1c312119d839a5bb234ba.zip
[iOS] Call UpdateLeftBarButtonItem when page is removed (#209)
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41038.cs94
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs8
3 files changed, 101 insertions, 2 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41038.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41038.cs
new file mode 100644
index 00000000..6b3fb911
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla41038.cs
@@ -0,0 +1,94 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 41038, "MasterDetailPage loses menu icon on iOS after reusing NavigationPage as Detail")]
+ public class Bugzilla41038 : TestMasterDetailPage // or TestMasterDetailPage, etc ...
+ {
+ NavigationPage _navPage;
+
+ protected override void Init()
+ {
+ Title = "Main";
+
+ var btnViewA = new Button() { Text = "ViewA" };
+ btnViewA.Clicked += Button_Clicked;
+
+ var btnViewB = new Button() { Text = "ViewB" };
+ btnViewB.Clicked += Button_Clicked;
+
+ var stack = new StackLayout();
+ stack.Children.Add(btnViewA);
+ stack.Children.Add(btnViewB);
+
+ var master = new ContentPage() { Title = "Master", Content = stack };
+
+ _navPage = new NavigationPage(new ViewA());
+
+ Master = master;
+ Detail = _navPage;
+
+ }
+
+ private async void Button_Clicked(object sender, EventArgs e)
+ {
+ Page root = _navPage.Navigation.NavigationStack[0];
+
+ await _navPage.Navigation.PopToRootAsync(false);
+
+ Page newRoot = null;
+
+ var btn = (Button)sender;
+ if (btn.Text == "ViewA")
+ newRoot = new ViewA();
+ else
+ newRoot = new ViewB();
+
+
+ await _navPage.Navigation.PushAsync(newRoot);
+ _navPage.Navigation.RemovePage(root);
+ IsPresented = false;
+
+ }
+
+ public class ViewA : ContentPage
+ {
+ public ViewA()
+ {
+ Title = "ViewA";
+ Content = new Label() { Text = "View A" };
+ }
+ }
+
+ public class ViewB : ContentPage
+ {
+ public ViewB()
+ {
+ Title = "ViewB";
+ Content = new Label() { Text = "View B" };
+ }
+ }
+
+ #if UITEST && __IOS__
+ [Test]
+ public void Bugzilla41038Test()
+ {
+ RunningApp.WaitForElement("Master");
+ RunningApp.Tap("Master");
+ RunningApp.WaitForElement("ViewB");
+ RunningApp.Tap("ViewB");
+ RunningApp.WaitForElement("Master");
+ RunningApp.Screenshot("I see the master toogle");
+ }
+ #endif
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 8d7f9a7a..ed0d9730 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -405,6 +405,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39963.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39987.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40704.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41038.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
index be069e98..d0798ed3 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
@@ -525,6 +525,8 @@ namespace Xamarin.Forms.Platform.iOS
_removeControllers = _removeControllers.Remove(target);
ViewControllers = _removeControllers;
}
+ var parentingViewController = ViewControllers.Last() as ParentingViewController;
+ UpdateLeftBarButtonItem(parentingViewController, page);
}
void RemoveViewControllers(bool animated)
@@ -629,11 +631,13 @@ namespace Xamarin.Forms.Platform.iOS
}
}
- void UpdateLeftBarButtonItem(ParentingViewController containerController)
+ void UpdateLeftBarButtonItem(ParentingViewController containerController, Page pageBeingRemoved = null)
{
+ if (containerController == null)
+ return;
var currentChild = containerController.Child;
var firstPage = ((INavigationPageController)Element).StackCopy.LastOrDefault();
- if ((currentChild != firstPage && NavigationPage.GetHasBackButton(currentChild)) || _parentMasterDetailPage == null)
+ if ((firstPage != pageBeingRemoved && currentChild != firstPage && NavigationPage.GetHasBackButton(currentChild)) || _parentMasterDetailPage == null)
return;
if (!_parentMasterDetailPage.ShouldShowToolbarButton())