1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-14 07:13:33 +00:00

show/hide loading are async now

This commit is contained in:
Kyle Spearrin
2018-03-22 11:07:41 -04:00
parent 215ded8a77
commit b5747fbb44
17 changed files with 85 additions and 57 deletions

View File

@@ -286,13 +286,15 @@ namespace Bit.iOS.Services
throw new NotImplementedException();
}
public void ShowLoading(string text)
public Task ShowLoadingAsync(string text)
{
if(_progressAlert != null)
{
HideLoading();
HideLoadingAsync().GetAwaiter().GetResult();
}
var result = new TaskCompletionSource<int>();
var loadingIndicator = new UIActivityIndicatorView(new CGRect(10, 5, 50, 50));
loadingIndicator.HidesWhenStopped = true;
loadingIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray;
@@ -303,19 +305,22 @@ namespace Bit.iOS.Services
_progressAlert.View.Add(loadingIndicator);
var vc = GetPresentedViewController();
vc?.PresentViewController(_progressAlert, false, null);
vc?.PresentViewController(_progressAlert, false, () => result.TrySetResult(0));
return result.Task;
}
public void HideLoading()
public Task HideLoadingAsync()
{
var result = new TaskCompletionSource<int>();
if(_progressAlert == null)
{
return;
result.TrySetResult(0);
}
_progressAlert.DismissViewController(false, null);
_progressAlert.DismissViewController(false, () => result.TrySetResult(0));
_progressAlert.Dispose();
_progressAlert = null;
return result.Task;
}
public Task LaunchAppAsync(string appName, Page page)