2019-06-28 14:57:08 +02:00
|
|
|
using System;
|
2019-07-01 21:12:40 +02:00
|
|
|
using Bit.iOS.Core.Utilities;
|
2020-10-15 20:34:31 +02:00
|
|
|
using Bit.iOS.Core.Views;
|
2019-06-28 14:57:08 +02:00
|
|
|
using Foundation;
|
|
|
|
using UIKit;
|
|
|
|
|
|
|
|
namespace Bit.iOS.Extension
|
|
|
|
{
|
|
|
|
public partial class LoginAddViewController : Core.Controllers.LoginAddViewController
|
|
|
|
{
|
|
|
|
public LoginAddViewController(IntPtr handle)
|
|
|
|
: base(handle)
|
2020-10-15 20:34:31 +02:00
|
|
|
{
|
|
|
|
DismissModalAction = Cancel;
|
|
|
|
}
|
2019-06-28 14:57:08 +02:00
|
|
|
|
|
|
|
public LoginListViewController LoginListController { get; set; }
|
|
|
|
public LoadingViewController LoadingController { get; set; }
|
|
|
|
|
|
|
|
public override UINavigationItem BaseNavItem => NavItem;
|
|
|
|
public override UIBarButtonItem BaseCancelButton => CancelBarButton;
|
|
|
|
public override UIBarButtonItem BaseSaveButton => SaveBarButton;
|
|
|
|
|
2019-07-01 21:12:40 +02:00
|
|
|
public override void ViewDidLoad()
|
|
|
|
{
|
|
|
|
base.ViewDidLoad();
|
|
|
|
SaveBarButton.TintColor = ThemeHelpers.NavBarTextColor;
|
|
|
|
CancelBarButton.TintColor = ThemeHelpers.NavBarTextColor;
|
|
|
|
}
|
|
|
|
|
2019-07-22 21:50:59 +02:00
|
|
|
public override Action<string> Success => id =>
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
if (LoginListController != null)
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
|
|
|
LoginListController.DismissModal();
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
else if (LoadingController != null)
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
2019-07-22 21:50:59 +02:00
|
|
|
LoadingController.CompleteUsernamePasswordRequest(id, UsernameCell.TextField.Text,
|
2019-06-28 14:57:08 +02:00
|
|
|
PasswordCell.TextField.Text, null, null);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
partial void CancelBarButton_Activated(UIBarButtonItem sender)
|
2020-10-15 20:34:31 +02:00
|
|
|
{
|
|
|
|
Cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Cancel()
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
if (LoginListController != null)
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
|
|
|
DismissViewController(true, null);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-07-22 21:50:59 +02:00
|
|
|
LoadingController.CompleteRequest(null, null);
|
2019-06-28 14:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async partial void SaveBarButton_Activated(UIBarButtonItem sender)
|
|
|
|
{
|
|
|
|
await this.SaveAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
|
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
if (segue.DestinationViewController is UINavigationController navController)
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
if (navController.TopViewController is PasswordGeneratorViewController passwordGeneratorController)
|
2019-06-28 14:57:08 +02:00
|
|
|
{
|
|
|
|
passwordGeneratorController.PasswordOptions = Context.PasswordOptions;
|
|
|
|
passwordGeneratorController.Parent = this;
|
2020-10-15 20:34:31 +02:00
|
|
|
segue.DestinationViewController.PresentationController.Delegate =
|
|
|
|
new CustomPresentationControllerDelegate(passwordGeneratorController.DismissModalAction);
|
2019-06-28 14:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|