1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-04 01:23:15 +00:00

display alert action

This commit is contained in:
Kyle Spearrin
2019-05-17 14:04:16 -04:00
parent a3e165fa06
commit f73a5d6307
3 changed files with 97 additions and 0 deletions

View File

@@ -264,6 +264,29 @@ namespace Bit.iOS.Services
return UIDevice.CurrentDevice.Model;
}
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 void ImagePicker_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
{
if(sender is UIImagePickerController picker)