This repository has been archived by the owner on May 1, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Handle user popping pages out of order (#934)
* [iOS] Handle when user can call pop a page that was already disposed/removed * [Controls] Fix bug number
- Loading branch information
Showing
5 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
Xamarin.Forms.ControlGallery.iOS/CustomRendererBugzila38731.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using UIKit; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.ControlGallery.iOS; | ||
using Xamarin.Forms.Controls.Issues; | ||
|
||
[assembly: ExportRenderer(typeof(Bugzilla38731), typeof(CustomRendererBugzila38731))] | ||
[assembly: ExportRenderer(typeof(Bugzilla38731.PageTwo), typeof(CustomRendererBugzila38731))] | ||
[assembly: ExportRenderer(typeof(Bugzilla38731.PageThree), typeof(CustomRendererBugzila38731))] | ||
[assembly: ExportRenderer(typeof(Bugzilla38731.PageFour), typeof(CustomRendererBugzila38731))] | ||
|
||
namespace Xamarin.Forms.ControlGallery.iOS | ||
{ | ||
public class CustomRendererBugzila38731 : Platform.iOS.PageRenderer | ||
{ | ||
public override void ViewWillAppear(bool animated) | ||
{ | ||
base.ViewWillAppear(animated); | ||
|
||
if (NavigationController.ViewControllers.Length > 1) | ||
{ | ||
NavigationController.TopViewController.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem( | ||
UIImage.FromFile("bank.png"), UIBarButtonItemStyle.Plain, (sender, args) => | ||
{ | ||
NavigationController.PopViewController(true); | ||
}), true); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38731.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
#endif | ||
|
||
// Apply the default category of "Issues" to all of the tests in this assembly | ||
// We use this as a catch-all for tests which haven't been individually categorized | ||
#if UITEST | ||
[assembly: NUnit.Framework.Category("Issues")] | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Bugzilla, 38731, "Xamarin.Forms.Platform.iOS.NavigationRenderer.GetAppearedOrDisappearedTask NullReferenceExceptionObject", PlatformAffected.Default)] | ||
public class Bugzilla38731 : TestContentPage // or TestMasterDetailPage, etc ... | ||
{ | ||
protected override void Init() | ||
{ | ||
var label = new Label(); | ||
label.Text = "Page one..."; | ||
label.HorizontalTextAlignment = TextAlignment.Center; | ||
|
||
var button = new Button(); | ||
button.AutomationId = "btn1"; | ||
button.Text = "Navigate to page two"; | ||
button.Clicked += Button_Clicked; | ||
|
||
var content = new StackLayout(); | ||
content.Children.Add(label); | ||
content.Children.Add(button); | ||
|
||
Title = "Page one"; | ||
Content = content; | ||
} | ||
|
||
void Button_Clicked(object sender, EventArgs e) | ||
{ | ||
Navigation.PushAsync(new PageTwo()); | ||
} | ||
|
||
public class PageTwo : ContentPage | ||
{ | ||
public PageTwo() | ||
{ | ||
var label = new Label(); | ||
label.Text = "Page two..."; | ||
label.HorizontalTextAlignment = TextAlignment.Center; | ||
|
||
var button = new Button(); | ||
button.AutomationId = "btn2"; | ||
button.Text = "Navigate to page three"; | ||
button.Clicked += Button_Clicked; | ||
|
||
var content = new StackLayout(); | ||
content.Children.Add(label); | ||
content.Children.Add(button); | ||
|
||
Title = "Page two"; | ||
Content = content; | ||
} | ||
|
||
void Button_Clicked(object sender, EventArgs e) | ||
{ | ||
Navigation.PushAsync(new PageThree()); | ||
} | ||
} | ||
|
||
public class PageThree : ContentPage | ||
{ | ||
public PageThree() | ||
{ | ||
var label = new Label(); | ||
label.Text = "Page three..."; | ||
label.HorizontalTextAlignment = TextAlignment.Center; | ||
|
||
var button = new Button(); | ||
button.AutomationId = "btn3"; | ||
button.Text = "Navigate to page four"; | ||
button.Clicked += Button_Clicked; | ||
|
||
var content = new StackLayout(); | ||
content.Children.Add(label); | ||
content.Children.Add(button); | ||
|
||
Title = "Page three"; | ||
Content = content; | ||
} | ||
|
||
void Button_Clicked(object sender, EventArgs e) | ||
{ | ||
Navigation.PushAsync(new PageFour()); | ||
} | ||
} | ||
|
||
public class PageFour : ContentPage | ||
{ | ||
public PageFour() | ||
{ | ||
var label = new Label(); | ||
label.Text = "Last page... Tap back very quick"; | ||
label.HorizontalTextAlignment = TextAlignment.Center; | ||
|
||
var content = new StackLayout(); | ||
content.Children.Add(label); | ||
|
||
Title = "Page four"; | ||
Content = content; | ||
} | ||
} | ||
|
||
#if UITEST | ||
[Test] | ||
public void Bugzilla38731Test () | ||
{ | ||
RunningApp.Tap(q => q.Marked("btn1")); | ||
RunningApp.Tap(q => q.Marked("btn2")); | ||
RunningApp.Tap(q => q.Marked("btn3")); | ||
RunningApp.Back(); | ||
RunningApp.Back(); | ||
RunningApp.Back(); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters