mirror of
https://github.com/bitwarden/mobile
synced 2025-02-02 11:37:14 +01:00
BaseContentPage on groupings page
This commit is contained in:
parent
b4f4f24c24
commit
a018369ae8
@ -18,7 +18,7 @@ namespace Bit.App.Pages
|
||||
|
||||
protected async Task LoadOnAppearedAsync(View viewToSet, bool fromModal, Func<Task> workFunction)
|
||||
{
|
||||
async Task LoadAsync()
|
||||
async Task DoWorkAsync()
|
||||
{
|
||||
await workFunction.Invoke();
|
||||
if(viewToSet != null)
|
||||
@ -26,15 +26,15 @@ namespace Bit.App.Pages
|
||||
Content = viewToSet;
|
||||
}
|
||||
}
|
||||
if(Device.RuntimePlatform == Device.iOS)
|
||||
if(!fromModal || Device.RuntimePlatform == Device.iOS)
|
||||
{
|
||||
await LoadAsync();
|
||||
await DoWorkAsync();
|
||||
return;
|
||||
}
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(fromModal ? 400 : 200);
|
||||
Device.BeginInvokeOnMainThread(async () => await LoadAsync());
|
||||
await Task.Delay(400);
|
||||
Device.BeginInvokeOnMainThread(async () => await DoWorkAsync());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
<pages:BaseContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Bit.App.Pages.GroupingsPage"
|
||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||
@ -64,11 +64,7 @@
|
||||
CollectionTemplate="{StaticResource collectionTemplate}" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<StackLayout>
|
||||
<ActivityIndicator VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="Center"
|
||||
IsRunning="True"
|
||||
IsVisible="{Binding Loading}"></ActivityIndicator>
|
||||
<StackLayout x:Name="_mainLayout">
|
||||
<StackLayout VerticalOptions="CenterAndExpand"
|
||||
Padding="20, 0"
|
||||
Spacing="20"
|
||||
@ -105,4 +101,4 @@
|
||||
</ListView>
|
||||
</StackLayout>
|
||||
|
||||
</ContentPage>
|
||||
</pages:BaseContentPage>
|
||||
|
@ -1,17 +1,12 @@
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public partial class GroupingsPage : ContentPage
|
||||
public partial class GroupingsPage : BaseContentPage
|
||||
{
|
||||
private readonly IBroadcasterService _broadcasterService;
|
||||
private readonly ISyncService _syncService;
|
||||
@ -25,6 +20,7 @@ namespace Bit.App.Pages
|
||||
string collectionId = null, string pageTitle = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
SetActivityIndicator();
|
||||
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
||||
_syncService = ServiceContainer.Resolve<ISyncService>("syncService");
|
||||
_viewModel = BindingContext as GroupingsPageViewModel;
|
||||
@ -52,18 +48,21 @@ namespace Bit.App.Pages
|
||||
}
|
||||
});
|
||||
|
||||
if(!_syncService.SyncInProgress)
|
||||
await LoadOnAppearedAsync(_mainLayout, false, async () =>
|
||||
{
|
||||
await _viewModel.LoadAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(5000);
|
||||
if(!_viewModel.Loaded)
|
||||
if(!_syncService.SyncInProgress)
|
||||
{
|
||||
await _viewModel.LoadAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(5000);
|
||||
if(!_viewModel.Loaded)
|
||||
{
|
||||
await _viewModel.LoadAsync();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
|
Loading…
x
Reference in New Issue
Block a user