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
|
|
|
|
|
{
|
2019-03-29 20:24:44 +03:00
|
|
|
|
public class GroupingsPageViewModel : BaseViewModel
|
2019-03-29 06:52:33 +03:00
|
|
|
|
{
|
2019-03-29 19:52:57 +03:00
|
|
|
|
private bool _loading = false;
|
|
|
|
|
|
2019-03-29 20:24:44 +03:00
|
|
|
|
public GroupingsPageViewModel()
|
2019-03-29 06:52:33 +03:00
|
|
|
|
{
|
|
|
|
|
PageTitle = "My Vault";
|
2019-03-29 20:24:44 +03:00
|
|
|
|
Items = new ExtendedObservableCollection<GroupingsPageListItem>();
|
2019-03-29 19:52:57 +03:00
|
|
|
|
LoadCommand = new Command(async () => await LoadAsync());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Loading
|
|
|
|
|
{
|
|
|
|
|
get => _loading;
|
|
|
|
|
set => SetProperty(ref _loading, value);
|
|
|
|
|
}
|
2019-03-29 20:24:44 +03:00
|
|
|
|
public ExtendedObservableCollection<GroupingsPageListItem> Items { get; set; }
|
2019-03-29 19:52:57 +03:00
|
|
|
|
public Command LoadCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public Task LoadAsync()
|
|
|
|
|
{
|
|
|
|
|
if(Loading)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(0);
|
|
|
|
|
}
|
|
|
|
|
Loading = true;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2019-03-29 20:24:44 +03:00
|
|
|
|
Items.ResetWithRange(new List<GroupingsPageListItem>
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Cipher = new CipherView { Name = "Cipher 1" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Cipher = new CipherView { Name = "Cipher 2" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Cipher = new CipherView { Name = "Cipher 3" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Cipher = new CipherView { Name = "Cipher 4" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Folder = new FolderView { Name = "Folder 1" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Folder = new FolderView { Name = "Folder 2" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Folder = new FolderView { Name = "Folder 3" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Collection = new Core.Models.View.CollectionView { Name = "Collection 1" }
|
|
|
|
|
},
|
2019-03-29 20:24:44 +03:00
|
|
|
|
new GroupingsPageListItem
|
2019-03-29 19:52:57 +03:00
|
|
|
|
{
|
|
|
|
|
Collection = new Core.Models.View.CollectionView { Name = "Collection 2" }
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Loading = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.FromResult(0);
|
2019-03-29 06:52:33 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|