1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 06:56:10 +00:00
This commit is contained in:
Yan Maniez 2018-07-15 15:48:45 +02:00
parent 8765112c55
commit 341b0eb4dc
2 changed files with 18 additions and 37 deletions

View file

@ -16,35 +16,11 @@ namespace AideDeJeu.ViewModels
public ItemsViewModel()
{
//this.ItemSourceType = itemSourceType;
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false));
//Filter = Main.GetFilterViewModel(ItemSourceType);
//Filter.LoadItemsCommand = LoadItemsCommand;
SearchCommand = new Command<string>((text) =>
{
Filter.SearchText = text;
});
SearchCommand = new Command<string>((text) => Filter.SearchText = text );
}
public Command<string> SearchCommand { get; private set; }
public ICommand LoadItemsCommand { get; protected set; }
public async Task ExecuteGotoItemCommandAsync(Item item)
{
await Main.Navigator.GotoItemDetailPageAsync(item);
}
//private ItemSourceType _ItemSourceType = ItemSourceType.SpellHD;
//public ItemSourceType ItemSourceType
//{
// get
// {
// return _ItemSourceType;
// }
// set
// {
// SetProperty(ref _ItemSourceType, value);
// OnPropertyChanged(nameof(Items));
// }
//}
private FilterViewModel _Filter;
public FilterViewModel Filter
@ -85,18 +61,27 @@ namespace AideDeJeu.ViewModels
if (_SelectedItem != null)
{
Main.Navigator.GotoItemDetailPageAsync(_SelectedItem);
//Main.GotoItemCommand.Execute(_SelectedItem);
}
}
}
public Items AllItems;
public async Task InitAsync()
private Items _AllItems;
public Items AllItems
{
//AllItems = await Main.GetAllItemsAsync(ItemSourceType);
Title = AllItems.Name;
Filter = AllItems.GetNewFilterViewModel(); //Main.GetFilterViewModel(ItemSourceType);
Filter.LoadItemsCommand = LoadItemsCommand;
get
{
return _AllItems;
}
set
{
_AllItems = value;
if (_AllItems != null)
{
Title = _AllItems.Name;
Filter = _AllItems.GetNewFilterViewModel();
Filter.LoadItemsCommand = LoadItemsCommand;
}
}
}
async Task LoadItemsAsync(CancellationToken cancellationToken = default)
@ -105,8 +90,6 @@ namespace AideDeJeu.ViewModels
Main.IsLoading = true;
try
{
//var filterViewModel = Filter;
//var allItems = await Main.GetAllItemsAsync(ItemSourceType);
var items = await Filter.FilterItems(AllItems, cancellationToken: cancellationToken);
Items = items.ToList();
}

View file

@ -32,10 +32,8 @@ namespace AideDeJeu.ViewModels
public async Task<ItemsViewModel> GetItemsViewModelAsync(string source)
{
var allItems = await GetAllItemsAsync(source);
var itemsViewModel = new ItemsViewModel();
itemsViewModel.AllItems = allItems;
await itemsViewModel.InitAsync();
itemsViewModel.AllItems = await GetAllItemsAsync(source);
return itemsViewModel;
}