mirror of
https://github.com/bitwarden/android.git
synced 2024-11-01 23:54:06 +03:00
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
|
using System;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Xamarin.Forms;
|
|||
|
|
|||
|
namespace Bit.App.Pages
|
|||
|
{
|
|||
|
public class BaseContentPage : ContentPage
|
|||
|
{
|
|||
|
protected void SetActivityIndicator()
|
|||
|
{
|
|||
|
Content = new ActivityIndicator
|
|||
|
{
|
|||
|
IsRunning = true,
|
|||
|
VerticalOptions = LayoutOptions.CenterAndExpand,
|
|||
|
HorizontalOptions = LayoutOptions.Center
|
|||
|
};
|
|||
|
}
|
|||
|
|
|||
|
protected async Task LoadOnAppearedAsync(View viewToSet, bool fromModal, Func<Task> workFunction)
|
|||
|
{
|
|||
|
async Task LoadAsync()
|
|||
|
{
|
|||
|
await workFunction.Invoke();
|
|||
|
if(viewToSet != null)
|
|||
|
{
|
|||
|
Content = viewToSet;
|
|||
|
}
|
|||
|
}
|
|||
|
if(Device.RuntimePlatform == Device.iOS)
|
|||
|
{
|
|||
|
await LoadAsync();
|
|||
|
return;
|
|||
|
}
|
|||
|
await Task.Run(async () =>
|
|||
|
{
|
|||
|
await Task.Delay(fromModal ? 400 : 200);
|
|||
|
Device.BeginInvokeOnMainThread(async () => await LoadAsync());
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|