diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs
index c52769ddb..020d6f502 100644
--- a/src/iOS.Autofill/CredentialProviderViewController.cs
+++ b/src/iOS.Autofill/CredentialProviderViewController.cs
@@ -12,6 +12,7 @@ using UIKit;
using Xamarin.Forms;
using Bit.App.Utilities;
using Bit.App.Models;
+using Bit.iOS.Core.Views;
using CoreNFC;
namespace Bit.iOS.Autofill
@@ -158,19 +159,27 @@ namespace Bit.iOS.Autofill
{
listLoginController.Context = _context;
listLoginController.CPViewController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(listLoginController.DismissModalAction);
}
else if (navController.TopViewController is LoginSearchViewController listSearchController)
{
listSearchController.Context = _context;
listSearchController.CPViewController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(listSearchController.DismissModalAction);
}
else if (navController.TopViewController is LockPasswordViewController passwordViewController)
{
passwordViewController.CPViewController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(passwordViewController.DismissModalAction);
}
else if (navController.TopViewController is SetupViewController setupViewController)
{
setupViewController.CPViewController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(setupViewController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Autofill/LockPasswordViewController.cs b/src/iOS.Autofill/LockPasswordViewController.cs
index 35fa2267f..11b3343a3 100644
--- a/src/iOS.Autofill/LockPasswordViewController.cs
+++ b/src/iOS.Autofill/LockPasswordViewController.cs
@@ -9,6 +9,7 @@ namespace Bit.iOS.Autofill
: base(handle)
{
BiometricIntegrityKey = "autofillBiometricState";
+ DismissModalAction = Cancel;
}
public CredentialProviderViewController CPViewController { get; set; }
diff --git a/src/iOS.Autofill/LoginAddViewController.cs b/src/iOS.Autofill/LoginAddViewController.cs
index 8e04326bb..6aea37ca9 100644
--- a/src/iOS.Autofill/LoginAddViewController.cs
+++ b/src/iOS.Autofill/LoginAddViewController.cs
@@ -1,4 +1,5 @@
using System;
+using Bit.iOS.Core.Views;
using Foundation;
using UIKit;
@@ -8,7 +9,9 @@ namespace Bit.iOS.Autofill
{
public LoginAddViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public LoginListViewController LoginListController { get; set; }
public LoginSearchViewController LoginSearchController { get; set; }
@@ -24,6 +27,11 @@ namespace Bit.iOS.Autofill
};
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
DismissViewController(true, null);
}
@@ -41,6 +49,8 @@ namespace Bit.iOS.Autofill
{
passwordGeneratorController.PasswordOptions = Context.PasswordOptions;
passwordGeneratorController.Parent = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(passwordGeneratorController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Autofill/LoginListViewController.cs b/src/iOS.Autofill/LoginListViewController.cs
index 8c2207889..f44ce040c 100644
--- a/src/iOS.Autofill/LoginListViewController.cs
+++ b/src/iOS.Autofill/LoginListViewController.cs
@@ -16,7 +16,9 @@ namespace Bit.iOS.Autofill
{
public LoginListViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public Context Context { get; set; }
public CredentialProviderViewController CPViewController { get; set; }
@@ -42,6 +44,11 @@ namespace Bit.iOS.Autofill
}
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
CPViewController.CompleteRequest();
}
@@ -64,12 +71,16 @@ namespace Bit.iOS.Autofill
{
addLoginController.Context = Context;
addLoginController.LoginListController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(addLoginController.DismissModalAction);
}
if (navController.TopViewController is LoginSearchViewController searchLoginController)
{
searchLoginController.Context = Context;
searchLoginController.CPViewController = CPViewController;
searchLoginController.FromList = true;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(searchLoginController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Autofill/LoginSearchViewController.cs b/src/iOS.Autofill/LoginSearchViewController.cs
index 78b28c84f..756eb079f 100644
--- a/src/iOS.Autofill/LoginSearchViewController.cs
+++ b/src/iOS.Autofill/LoginSearchViewController.cs
@@ -14,7 +14,9 @@ namespace Bit.iOS.Autofill
{
public LoginSearchViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public Context Context { get; set; }
public CredentialProviderViewController CPViewController { get; set; }
@@ -46,6 +48,11 @@ namespace Bit.iOS.Autofill
}
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
if (FromList)
{
@@ -70,6 +77,8 @@ namespace Bit.iOS.Autofill
{
addLoginController.Context = Context;
addLoginController.LoginSearchController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(addLoginController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Autofill/PasswordGeneratorViewController.cs b/src/iOS.Autofill/PasswordGeneratorViewController.cs
index fbb1ff8fb..7331fd40e 100644
--- a/src/iOS.Autofill/PasswordGeneratorViewController.cs
+++ b/src/iOS.Autofill/PasswordGeneratorViewController.cs
@@ -7,7 +7,9 @@ namespace Bit.iOS.Autofill
{
public PasswordGeneratorViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public LoginAddViewController Parent { get; set; }
public override UINavigationItem BaseNavItem => NavItem;
@@ -21,6 +23,11 @@ namespace Bit.iOS.Autofill
}
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
DismissViewController(true, null);
}
diff --git a/src/iOS.Autofill/SetupViewController.cs b/src/iOS.Autofill/SetupViewController.cs
index a7444d1ef..bc487fe26 100644
--- a/src/iOS.Autofill/SetupViewController.cs
+++ b/src/iOS.Autofill/SetupViewController.cs
@@ -10,7 +10,9 @@ namespace Bit.iOS.Autofill
{
public SetupViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public CredentialProviderViewController CPViewController { get; set; }
@@ -33,6 +35,11 @@ namespace Bit.iOS.Autofill
}
partial void BackButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
CPViewController.CompleteRequest();
}
diff --git a/src/iOS.Core/Controllers/ExtendedUITableViewController.cs b/src/iOS.Core/Controllers/ExtendedUITableViewController.cs
index 8b491907d..c11ea4c3f 100644
--- a/src/iOS.Core/Controllers/ExtendedUITableViewController.cs
+++ b/src/iOS.Core/Controllers/ExtendedUITableViewController.cs
@@ -6,6 +6,8 @@ namespace Bit.iOS.Core.Controllers
{
public class ExtendedUITableViewController : UITableViewController
{
+ public Action DismissModalAction { get; set; }
+
public ExtendedUITableViewController(IntPtr handle)
: base(handle)
{
diff --git a/src/iOS.Core/Controllers/ExtendedUIViewController.cs b/src/iOS.Core/Controllers/ExtendedUIViewController.cs
index cf26ab478..8d0db352b 100644
--- a/src/iOS.Core/Controllers/ExtendedUIViewController.cs
+++ b/src/iOS.Core/Controllers/ExtendedUIViewController.cs
@@ -6,6 +6,8 @@ namespace Bit.iOS.Core.Controllers
{
public class ExtendedUIViewController : UIViewController
{
+ public Action DismissModalAction { get; set; }
+
public ExtendedUIViewController(IntPtr handle)
: base(handle)
{
diff --git a/src/iOS.Core/Views/CustomPresentationControllerDelegate.cs b/src/iOS.Core/Views/CustomPresentationControllerDelegate.cs
new file mode 100644
index 000000000..dae2b6e7a
--- /dev/null
+++ b/src/iOS.Core/Views/CustomPresentationControllerDelegate.cs
@@ -0,0 +1,22 @@
+using System;
+using Foundation;
+using UIKit;
+
+namespace Bit.iOS.Core.Views
+{
+ public class CustomPresentationControllerDelegate : UIAdaptivePresentationControllerDelegate
+ {
+ private readonly Action DismissModalAction;
+
+ public CustomPresentationControllerDelegate(Action dismissModalAction)
+ {
+ DismissModalAction = dismissModalAction;
+ }
+
+ [Export("presentationControllerDidDismiss:")]
+ public override void DidDismiss(UIPresentationController presentationController)
+ {
+ DismissModalAction?.Invoke();
+ }
+ }
+}
diff --git a/src/iOS.Core/iOS.Core.csproj b/src/iOS.Core/iOS.Core.csproj
index 6f067c1c6..132168b40 100644
--- a/src/iOS.Core/iOS.Core.csproj
+++ b/src/iOS.Core/iOS.Core.csproj
@@ -175,6 +175,7 @@
+
diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs
index 8db33651e..b9ee3dbed 100644
--- a/src/iOS.Extension/LoadingViewController.cs
+++ b/src/iOS.Extension/LoadingViewController.cs
@@ -18,6 +18,7 @@ using Xamarin.Forms;
using Bit.App.Pages;
using Bit.App.Models;
using Bit.App.Utilities;
+using Bit.iOS.Core.Views;
namespace Bit.iOS.Extension
{
@@ -94,20 +95,28 @@ namespace Bit.iOS.Extension
{
listLoginController.Context = _context;
listLoginController.LoadingController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(listLoginController.DismissModalAction);
}
else if (navController.TopViewController is LoginAddViewController addLoginController)
{
addLoginController.Context = _context;
addLoginController.LoadingController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(addLoginController.DismissModalAction);
}
else if (navController.TopViewController is LockPasswordViewController passwordViewController)
{
passwordViewController.LoadingController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(passwordViewController.DismissModalAction);
}
else if (navController.TopViewController is SetupViewController setupViewController)
{
setupViewController.Context = _context;
setupViewController.LoadingController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(setupViewController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Extension/LockPasswordViewController.cs b/src/iOS.Extension/LockPasswordViewController.cs
index ae7a400d4..34995b614 100644
--- a/src/iOS.Extension/LockPasswordViewController.cs
+++ b/src/iOS.Extension/LockPasswordViewController.cs
@@ -10,6 +10,7 @@ namespace Bit.iOS.Extension
: base(handle)
{
BiometricIntegrityKey = "extensionBiometricState";
+ DismissModalAction = Cancel;
}
public LoadingViewController LoadingController { get; set; }
diff --git a/src/iOS.Extension/LoginAddViewController.cs b/src/iOS.Extension/LoginAddViewController.cs
index 012744bc6..bb2e662b1 100644
--- a/src/iOS.Extension/LoginAddViewController.cs
+++ b/src/iOS.Extension/LoginAddViewController.cs
@@ -1,5 +1,6 @@
using System;
using Bit.iOS.Core.Utilities;
+using Bit.iOS.Core.Views;
using Foundation;
using UIKit;
@@ -9,7 +10,9 @@ namespace Bit.iOS.Extension
{
public LoginAddViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public LoginListViewController LoginListController { get; set; }
public LoadingViewController LoadingController { get; set; }
@@ -39,6 +42,11 @@ namespace Bit.iOS.Extension
};
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
if (LoginListController != null)
{
@@ -63,6 +71,8 @@ namespace Bit.iOS.Extension
{
passwordGeneratorController.PasswordOptions = Context.PasswordOptions;
passwordGeneratorController.Parent = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(passwordGeneratorController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Extension/LoginListViewController.cs b/src/iOS.Extension/LoginListViewController.cs
index 88c097bfe..b95081708 100644
--- a/src/iOS.Extension/LoginListViewController.cs
+++ b/src/iOS.Extension/LoginListViewController.cs
@@ -18,7 +18,9 @@ namespace Bit.iOS.Extension
{
public LoginListViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public Context Context { get; set; }
public LoadingViewController LoadingController { get; set; }
@@ -56,6 +58,11 @@ namespace Bit.iOS.Extension
}
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
LoadingController.CompleteRequest(null, null);
}
@@ -73,6 +80,8 @@ namespace Bit.iOS.Extension
{
addLoginController.Context = Context;
addLoginController.LoginListController = this;
+ segue.DestinationViewController.PresentationController.Delegate =
+ new CustomPresentationControllerDelegate(addLoginController.DismissModalAction);
}
}
}
diff --git a/src/iOS.Extension/PasswordGeneratorViewController.cs b/src/iOS.Extension/PasswordGeneratorViewController.cs
index ddec501f9..5b14733e2 100644
--- a/src/iOS.Extension/PasswordGeneratorViewController.cs
+++ b/src/iOS.Extension/PasswordGeneratorViewController.cs
@@ -8,7 +8,9 @@ namespace Bit.iOS.Extension
{
public PasswordGeneratorViewController(IntPtr handle)
: base(handle)
- { }
+ {
+ DismissModalAction = Cancel;
+ }
public LoginAddViewController Parent { get; set; }
public override UINavigationItem BaseNavItem => NavItem;
@@ -29,6 +31,11 @@ namespace Bit.iOS.Extension
}
partial void CancelBarButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
DismissViewController(true, null);
}
diff --git a/src/iOS.Extension/SetupViewController.cs b/src/iOS.Extension/SetupViewController.cs
index b15df213b..284998e37 100644
--- a/src/iOS.Extension/SetupViewController.cs
+++ b/src/iOS.Extension/SetupViewController.cs
@@ -13,6 +13,7 @@ namespace Bit.iOS.Extension
: base(handle)
{
ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
+ DismissModalAction = Cancel;
}
public Context Context { get; set; }
@@ -37,6 +38,11 @@ namespace Bit.iOS.Extension
}
partial void BackButton_Activated(UIBarButtonItem sender)
+ {
+ Cancel();
+ }
+
+ private void Cancel()
{
LoadingController.CompleteRequest(null, null);
}