1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-15 10:25:20 +01:00
bitwarden-mobile/src/iOS.Extension/LoginAddViewController.cs

81 lines
2.6 KiB
C#
Raw Normal View History

2019-06-28 14:57:08 +02:00
using System;
2019-07-01 21:12:40 +02:00
using Bit.iOS.Core.Utilities;
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)
{
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
{
if (LoginListController != null)
2019-06-28 14:57:08 +02:00
{
LoginListController.DismissModal();
}
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)
{
Cancel();
}
private void Cancel()
2019-06-28 14:57:08 +02: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)
{
if (segue.DestinationViewController is UINavigationController navController)
2019-06-28 14:57:08 +02:00
{
if (navController.TopViewController is PasswordGeneratorViewController passwordGeneratorController)
2019-06-28 14:57:08 +02:00
{
passwordGeneratorController.PasswordOptions = Context.PasswordOptions;
passwordGeneratorController.Parent = this;
segue.DestinationViewController.PresentationController.Delegate =
new CustomPresentationControllerDelegate(passwordGeneratorController.DismissModalAction);
2019-06-28 14:57:08 +02:00
}
}
}
}
}