mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-25 16:47:55 +01:00
show loading indicator if syncing an no items
This commit is contained in:
parent
e753acbc3f
commit
9bbddd6aeb
@ -29,9 +29,9 @@ namespace Bit.App.Controls
|
||||
{
|
||||
if(_syncIndicator)
|
||||
{
|
||||
MessagingCenter.Subscribe<ISyncService, bool>(_syncService, "SyncCompleted",
|
||||
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted",
|
||||
(sender, success) => Device.BeginInvokeOnMainThread(() => IsBusy = _syncService.SyncInProgress));
|
||||
MessagingCenter.Subscribe<ISyncService>(_syncService, "SyncStarted",
|
||||
MessagingCenter.Subscribe<ISyncService>(Application.Current, "SyncStarted",
|
||||
(sender) => Device.BeginInvokeOnMainThread(() => IsBusy = _syncService.SyncInProgress));
|
||||
}
|
||||
|
||||
@ -48,8 +48,8 @@ namespace Bit.App.Controls
|
||||
{
|
||||
if(_syncIndicator)
|
||||
{
|
||||
MessagingCenter.Unsubscribe<ISyncService, bool>(_syncService, "SyncCompleted");
|
||||
MessagingCenter.Unsubscribe<ISyncService>(_syncService, "SyncStarted");
|
||||
MessagingCenter.Unsubscribe<Application, bool>(Application.Current, "SyncCompleted");
|
||||
MessagingCenter.Unsubscribe<Application>(Application.Current, "SyncStarted");
|
||||
}
|
||||
|
||||
if(_syncIndicator)
|
||||
|
@ -61,6 +61,7 @@ namespace Bit.App.Pages
|
||||
public Cipher[] Ciphers { get; set; } = new Cipher[] { };
|
||||
public ListView ListView { get; set; }
|
||||
public SearchBar Search { get; set; }
|
||||
public ActivityIndicator LoadingIndicator { get; set; }
|
||||
public StackLayout NoDataStackLayout { get; set; }
|
||||
public StackLayout ResultsStackLayout { get; set; }
|
||||
private AddCipherToolBarItem AddCipherItem { get; set; }
|
||||
@ -156,12 +157,14 @@ namespace Bit.App.Pages
|
||||
Title = AppResources.SearchVault;
|
||||
}
|
||||
|
||||
Content = new ActivityIndicator
|
||||
LoadingIndicator = new ActivityIndicator
|
||||
{
|
||||
IsRunning = true,
|
||||
VerticalOptions = LayoutOptions.CenterAndExpand,
|
||||
HorizontalOptions = LayoutOptions.Center
|
||||
};
|
||||
|
||||
Content = LoadingIndicator;
|
||||
}
|
||||
|
||||
private void SearchBar_SearchButtonPressed(object sender, EventArgs e)
|
||||
@ -249,7 +252,7 @@ namespace Bit.App.Pages
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
MessagingCenter.Subscribe<ISyncService, bool>(_syncService, "SyncCompleted", (sender, success) =>
|
||||
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||
{
|
||||
if(success)
|
||||
{
|
||||
@ -273,7 +276,7 @@ namespace Bit.App.Pages
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
MessagingCenter.Unsubscribe<ISyncService, bool>(_syncService, "SyncCompleted");
|
||||
MessagingCenter.Unsubscribe<Application, bool>(Application.Current, "SyncCompleted");
|
||||
|
||||
AddCipherItem?.Dispose();
|
||||
ListView.ItemSelected -= CipherSelected;
|
||||
@ -345,6 +348,10 @@ namespace Bit.App.Pages
|
||||
{
|
||||
Content = ResultsStackLayout;
|
||||
}
|
||||
else if(_syncService.SyncInProgress)
|
||||
{
|
||||
Content = LoadingIndicator;
|
||||
}
|
||||
else
|
||||
{
|
||||
Content = NoDataStackLayout;
|
||||
|
@ -119,7 +119,7 @@ namespace Bit.App.Pages
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
MessagingCenter.Subscribe<ISyncService, bool>(_syncService, "SyncCompleted", (sender, success) =>
|
||||
MessagingCenter.Subscribe<Application, bool>(Application.Current, "SyncCompleted", (sender, success) =>
|
||||
{
|
||||
if(success)
|
||||
{
|
||||
@ -168,7 +168,7 @@ namespace Bit.App.Pages
|
||||
protected override void OnDisappearing()
|
||||
{
|
||||
base.OnDisappearing();
|
||||
MessagingCenter.Unsubscribe<ISyncService, bool>(_syncService, "SyncCompleted");
|
||||
MessagingCenter.Unsubscribe<Application, bool>(Application.Current, "SyncCompleted");
|
||||
|
||||
ListView.ItemSelected -= GroupingSelected;
|
||||
AddCipherItem?.Dispose();
|
||||
@ -229,6 +229,10 @@ namespace Bit.App.Pages
|
||||
{
|
||||
Content = ListView;
|
||||
}
|
||||
else if(_syncService.SyncInProgress)
|
||||
{
|
||||
Content = LoadingIndicator;
|
||||
}
|
||||
else
|
||||
{
|
||||
Content = NoDataStackLayout;
|
||||
|
@ -554,7 +554,7 @@ namespace Bit.App.Services
|
||||
}
|
||||
|
||||
SyncInProgress = true;
|
||||
MessagingCenter.Send(this, "SyncStarted");
|
||||
MessagingCenter.Send(Application.Current, "SyncStarted");
|
||||
}
|
||||
|
||||
private void SyncCompleted(bool successfully)
|
||||
@ -565,7 +565,7 @@ namespace Bit.App.Services
|
||||
}
|
||||
|
||||
SyncInProgress = false;
|
||||
MessagingCenter.Send(this, "SyncCompleted", successfully);
|
||||
MessagingCenter.Send(Application.Current, "SyncCompleted", successfully);
|
||||
}
|
||||
|
||||
private bool CheckSuccess<T>(ApiResult<T> result, bool logout = false)
|
||||
|
Loading…
Reference in New Issue
Block a user