bitwarden-android/src/App/Pages/VaultGroupingsPageViewModel.cs

94 lines
3 KiB
C#
Raw Normal View History

2019-03-29 19:52:57 +03:00
using Bit.Core.Models.View;
using Bit.Core.Utilities;
2019-03-29 06:52:33 +03:00
using System.Collections.Generic;
2019-03-29 19:52:57 +03:00
using System.Threading.Tasks;
using Xamarin.Forms;
2019-03-29 06:52:33 +03:00
namespace Bit.App.Pages
{
public class VaultGroupingsPageViewModel : BaseViewModel
{
2019-03-29 19:52:57 +03:00
private bool _loading = false;
2019-03-29 06:52:33 +03:00
public VaultGroupingsPageViewModel()
{
PageTitle = "My Vault";
2019-03-29 19:52:57 +03:00
Items = new ExtendedObservableCollection<VaultGroupingsPageListItem>();
LoadCommand = new Command(async () => await LoadAsync());
}
public bool Loading
{
get => _loading;
set => SetProperty(ref _loading, value);
}
public ExtendedObservableCollection<VaultGroupingsPageListItem> Items { get; set; }
public Command LoadCommand { get; set; }
public Task LoadAsync()
{
if(Loading)
{
return Task.FromResult(0);
}
Loading = true;
try
{
Items.ResetWithRange(new List<VaultGroupingsPageListItem>
{
new VaultGroupingsPageListItem
{
Cipher = new CipherView { Name = "Cipher 1" }
},
new VaultGroupingsPageListItem
{
Cipher = new CipherView { Name = "Cipher 2" }
},
new VaultGroupingsPageListItem
{
Cipher = new CipherView { Name = "Cipher 3" }
},
new VaultGroupingsPageListItem
{
Cipher = new CipherView { Name = "Cipher 4" }
},
new VaultGroupingsPageListItem
{
Folder = new FolderView { Name = "Folder 1" }
},
new VaultGroupingsPageListItem
{
Folder = new FolderView { Name = "Folder 2" }
},
new VaultGroupingsPageListItem
{
Folder = new FolderView { Name = "Folder 3" }
},
new VaultGroupingsPageListItem
{
Collection = new Core.Models.View.CollectionView { Name = "Collection 1" }
},
new VaultGroupingsPageListItem
{
Collection = new Core.Models.View.CollectionView { Name = "Collection 2" }
},
});
}
finally
{
Loading = false;
}
return Task.FromResult(0);
2019-03-29 06:52:33 +03:00
}
}
2019-03-29 19:52:57 +03:00
public class VaultGroupingsPageListItem
{
public FolderView Folder { get; set; }
public Core.Models.View.CollectionView Collection { get; set; }
public CipherView Cipher { get; set; }
}
2019-03-29 06:52:33 +03:00
}