1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-15 07:43:37 +00:00

fix for stuck extension sheets when dismissed by swipe (#1117)

* fix for stuck extension sheets when dismissed by swipe

* simplify dismiss action assignments
This commit is contained in:
Matt Portune
2020-10-15 14:34:31 -04:00
committed by GitHub
parent 523e713d7a
commit b163a0fe77
17 changed files with 131 additions and 8 deletions

View File

@@ -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);
}
}
}

View File

@@ -9,6 +9,7 @@ namespace Bit.iOS.Autofill
: base(handle)
{
BiometricIntegrityKey = "autofillBiometricState";
DismissModalAction = Cancel;
}
public CredentialProviderViewController CPViewController { get; set; }

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -6,6 +6,8 @@ namespace Bit.iOS.Core.Controllers
{
public class ExtendedUITableViewController : UITableViewController
{
public Action DismissModalAction { get; set; }
public ExtendedUITableViewController(IntPtr handle)
: base(handle)
{

View File

@@ -6,6 +6,8 @@ namespace Bit.iOS.Core.Controllers
{
public class ExtendedUIViewController : UIViewController
{
public Action DismissModalAction { get; set; }
public ExtendedUIViewController(IntPtr handle)
: base(handle)
{

View File

@@ -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();
}
}
}

View File

@@ -175,6 +175,7 @@
<Compile Include="Utilities\iOSCoreHelpers.cs" />
<Compile Include="Utilities\iOSHelpers.cs" />
<Compile Include="Utilities\ThemeHelpers.cs" />
<Compile Include="Views\CustomPresentationControllerDelegate.cs" />
<Compile Include="Views\ExtensionSearchDelegate.cs" />
<Compile Include="Views\ExtensionTableSource.cs" />
<Compile Include="Views\FormEntryTableViewCell.cs" />

View File

@@ -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);
}
}
}

View File

@@ -10,6 +10,7 @@ namespace Bit.iOS.Extension
: base(handle)
{
BiometricIntegrityKey = "extensionBiometricState";
DismissModalAction = Cancel;
}
public LoadingViewController LoadingController { get; set; }

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}

View File

@@ -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);
}