2019-04-19 22:45:16 +02:00
|
|
|
|
using Bit.Core.Abstractions;
|
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
using System;
|
2019-03-29 18:24:44 +01:00
|
|
|
|
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
|
|
|
|
|
{
|
2019-04-19 22:45:16 +02:00
|
|
|
|
private readonly IBroadcasterService _broadcasterService;
|
|
|
|
|
private readonly ISyncService _syncService;
|
|
|
|
|
private readonly GroupingsPageViewModel _viewModel;
|
2019-03-29 18:24:44 +01:00
|
|
|
|
|
|
|
|
|
public GroupingsPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-04-19 22:45:16 +02:00
|
|
|
|
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
|
|
|
|
_syncService = ServiceContainer.Resolve<ISyncService>("syncService");
|
2019-03-29 18:24:44 +01:00
|
|
|
|
_viewModel = BindingContext as GroupingsPageViewModel;
|
2019-04-24 17:23:03 +02:00
|
|
|
|
_viewModel.Page = this;
|
2019-03-29 18:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected async override void OnAppearing()
|
|
|
|
|
{
|
|
|
|
|
base.OnAppearing();
|
2019-04-19 22:45:16 +02:00
|
|
|
|
_broadcasterService.Subscribe(nameof(GroupingsPage), async (message) =>
|
|
|
|
|
{
|
|
|
|
|
if(message.Command == "syncCompleted")
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(500);
|
|
|
|
|
// await _viewModel.LoadAsync();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if(!_syncService.SyncInProgress)
|
|
|
|
|
{
|
|
|
|
|
await _viewModel.LoadAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay(5000);
|
|
|
|
|
if(!_viewModel.Loaded)
|
|
|
|
|
{
|
|
|
|
|
await _viewModel.LoadAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDisappearing()
|
|
|
|
|
{
|
|
|
|
|
base.OnDisappearing();
|
|
|
|
|
_broadcasterService.Unsubscribe(nameof(GroupingsPage));
|
2019-03-29 18:24:44 +01:00
|
|
|
|
}
|
2019-04-24 17:23:03 +02:00
|
|
|
|
|
|
|
|
|
private async void RowSelected(object sender, SelectedItemChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(!(e.SelectedItem is GroupingsPageListItem item))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(item.Cipher != null)
|
|
|
|
|
{
|
|
|
|
|
await _viewModel.SelectCipherAsync(item.Cipher);
|
|
|
|
|
}
|
|
|
|
|
else if(item.Folder != null || item.Collection != null)
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-03-29 18:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
}
|