summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45743.cs78
-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/Platform.cs16
3 files changed, 91 insertions, 4 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45743.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45743.cs
new file mode 100644
index 00000000..46b9c22d
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45743.cs
@@ -0,0 +1,78 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 45743, "[iOS] Calling DisplayAlert via BeginInvokeOnMainThread blocking other calls on iOS", PlatformAffected.iOS)]
+ public class Bugzilla45743 : TestNavigationPage
+ {
+ protected override void Init()
+ {
+ PushAsync(new ContentPage
+ {
+ Content = new StackLayout
+ {
+ AutomationId = "Page1",
+ Children =
+ {
+ new Label { Text = "Page 1" }
+ }
+ }
+ });
+
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await DisplayAlert("Title", "Message", "Accept", "Cancel");
+ });
+
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await PushAsync(new ContentPage
+ {
+ AutomationId = "Page2",
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Label { Text = "Page 2" }
+ }
+ }
+ });
+ });
+
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await DisplayAlert("Title 2", "Message", "Accept", "Cancel");
+ });
+
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await DisplayActionSheet("ActionSheet Title", "Cancel", "Close", new string[] { "Test", "Test 2" });
+ });
+ }
+
+#if UITEST
+
+#if __IOS__
+ [Test]
+ public void Bugzilla45743Test()
+ {
+ RunningApp.WaitForElement(q => q.Marked("ActionSheet Title"));
+ RunningApp.Tap("Close");
+ RunningApp.WaitForElement(q => q.Marked("Title 2"));
+ RunningApp.Tap("Accept");
+ RunningApp.WaitForElement(q => q.Marked("Title"));
+ RunningApp.Tap("Accept");
+ Assert.True(RunningApp.Query(q => q.Text("Page 2")).Length > 0);
+ }
+#endif
+
+#endif
+ }
+} \ No newline at end of file
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 677ddb9f..263feb5d 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
@@ -133,6 +133,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42832.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44044.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla44338.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla45743.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs
index 04874db8..8db28f6f 100644
--- a/Xamarin.Forms.Platform.iOS/Platform.cs
+++ b/Xamarin.Forms.Platform.iOS/Platform.cs
@@ -54,9 +54,8 @@ namespace Xamarin.Forms.Platform.iOS
alert.AddAction(UIAlertAction.Create(arguments.Cancel, UIAlertActionStyle.Cancel, a => arguments.SetResult(false)));
if (arguments.Accept != null)
alert.AddAction(UIAlertAction.Create(arguments.Accept, UIAlertActionStyle.Default, a => arguments.SetResult(true)));
- var page = _modals.Any() ? _modals.Last() : Page;
- var vc = GetRenderer(page).ViewController;
- vc.PresentViewController(alert, true, null);
+
+ PresentAlert(alert);
}
else
{
@@ -121,7 +120,7 @@ namespace Xamarin.Forms.Platform.iOS
alert.PopoverPresentationController.PermittedArrowDirections = 0; // No arrow
}
- pageRenderer.ViewController.PresentViewController(alert, true, null);
+ PresentAlert(alert);
}
else
{
@@ -431,6 +430,15 @@ namespace Xamarin.Forms.Platform.iOS
return Page == page || _modals.Contains(page);
}
+ void PresentAlert(UIAlertController alert)
+ {
+ var window = new UIWindow { BackgroundColor = Color.Transparent.ToUIColor() };
+ window.RootViewController = new UIViewController();
+ window.RootViewController.View.BackgroundColor = Color.Transparent.ToUIColor();
+ window.MakeKeyAndVisible();
+ window.RootViewController.PresentViewController(alert, true, null);
+ }
+
async Task PresentModal(Page modal, bool animated)
{
var modalRenderer = GetRenderer(modal);