1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 16:53:26 +00:00

multibutton alert, autofill and save new uri

This commit is contained in:
Kyle Spearrin
2018-04-02 13:37:46 -04:00
parent be11933c60
commit 10df9e7cd5
12 changed files with 313 additions and 40 deletions

View File

@@ -351,6 +351,32 @@ namespace Bit.iOS.Services
return result.Task;
}
public Task<string> DisplayAlertAsync(string title, string message, string cancel, params string[] buttons)
{
var result = new TaskCompletionSource<string>();
var alert = UIAlertController.Create(title ?? string.Empty, message, UIAlertControllerStyle.Alert);
if(!string.IsNullOrWhiteSpace(cancel))
{
alert.AddAction(UIAlertAction.Create(cancel, UIAlertActionStyle.Cancel, x =>
{
result.TrySetResult(cancel);
}));
}
foreach(var button in buttons)
{
alert.AddAction(UIAlertAction.Create(button, UIAlertActionStyle.Default, x =>
{
result.TrySetResult(button);
}));
}
var vc = GetPresentedViewController();
vc?.PresentViewController(alert, true, null);
return result.Task;
}
private UIViewController GetPresentedViewController()
{
var window = UIApplication.SharedApplication.KeyWindow;