1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-14 15:23:35 +00:00

[EC-259] Added Account Switching to Share extension on iOS (#1971)

* EC-259 Added Account switching on share extension on iOS, also improved performance for this and exception handling

* EC-259 code formatting

* EC-259 Added account switching to Share extension Send view

* EC-259 Fixed navigation on share extension when a forms page is already presented

* EC-259 Fix send text UI update when going from the iOS extension

* EC-259 Improved DateTimeViewModel with helper property to easily setup date and time at the same time and applied on usage
This commit is contained in:
Federico Maccaroni
2022-07-12 14:12:23 -03:00
committed by GitHub
parent d621a5d2f3
commit 292908f53f
28 changed files with 1509 additions and 423 deletions

View File

@@ -1,11 +1,22 @@
using Bit.App.Controls;
using Bit.Core.Utilities;
using Bit.iOS.Core.Utilities;
using System;
using UIKit;
namespace Bit.iOS.ShareExtension
{
public partial class LockPasswordViewController : Core.Controllers.LockPasswordViewController
public partial class LockPasswordViewController : Core.Controllers.BaseLockPasswordViewController
{
AccountSwitchingOverlayView _accountSwitchingOverlayView;
AccountSwitchingOverlayHelper _accountSwitchingOverlayHelper;
public LockPasswordViewController()
{
BiometricIntegrityKey = Bit.Core.Constants.iOSShareExtensionBiometricIntegrityKey;
DismissModalAction = Cancel;
}
public LockPasswordViewController(IntPtr handle)
: base(handle)
{
@@ -17,24 +28,80 @@ namespace Bit.iOS.ShareExtension
public override UINavigationItem BaseNavItem => _navItem;
public override UIBarButtonItem BaseCancelButton => _cancelButton;
public override UIBarButtonItem BaseSubmitButton => _submitButton;
public override Action Success => () => LoadingController.DismissLockAndContinue();
public override Action Cancel => () => LoadingController.CompleteRequest();
public override Action Success => () =>
{
LoadingController?.Navigate(Bit.Core.Enums.NavigationTarget.Home);
LoadingController = null;
};
public override Action Cancel => () =>
{
LoadingController?.CompleteRequest();
LoadingController = null;
};
public override void ViewDidLoad()
public override UITableView TableView => _mainTableView;
public override async void ViewDidLoad()
{
base.ViewDidLoad();
_cancelButton.TintColor = ThemeHelpers.NavBarTextColor;
_submitButton.TintColor = ThemeHelpers.NavBarTextColor;
_accountSwitchingOverlayHelper = new AccountSwitchingOverlayHelper();
_accountSwitchingButton.Image = await _accountSwitchingOverlayHelper.CreateAvatarImageAsync();
_accountSwitchingOverlayView = _accountSwitchingOverlayHelper.CreateAccountSwitchingOverlayView(_overlayView);
}
protected override void UpdateNavigationBarTheme()
{
UpdateNavigationBarTheme(_navBar);
}
partial void AccountSwitchingButton_Activated(UIBarButtonItem sender)
{
_accountSwitchingOverlayHelper.OnToolbarItemActivated(_accountSwitchingOverlayView, _overlayView);
}
partial void SubmitButton_Activated(UIBarButtonItem sender)
{
var task = CheckPasswordAsync();
CheckPasswordAsync().FireAndForget();
}
partial void CancelButton_Activated(UIBarButtonItem sender)
{
Cancel();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (TableView != null)
{
TableView.Source?.Dispose();
}
if (_accountSwitchingButton?.Image != null)
{
var img = _accountSwitchingButton.Image;
_accountSwitchingButton.Image = null;
img.Dispose();
}
if (_accountSwitchingOverlayView != null && _overlayView?.Subviews != null)
{
foreach (var subView in _overlayView.Subviews)
{
subView.RemoveFromSuperview();
subView.Dispose();
}
_accountSwitchingOverlayView = null;
_overlayView.RemoveFromSuperview();
}
_accountSwitchingOverlayHelper = null;
}
base.Dispose(disposing);
}
}
}