1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-31 15:36:07 +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() public ItemsViewModel()
{ {
//this.ItemSourceType = itemSourceType;
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false)); LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false));
//Filter = Main.GetFilterViewModel(ItemSourceType); SearchCommand = new Command<string>((text) => Filter.SearchText = text );
//Filter.LoadItemsCommand = LoadItemsCommand;
SearchCommand = new Command<string>((text) =>
{
Filter.SearchText = text;
});
} }
public Command<string> SearchCommand { get; private set; } public Command<string> SearchCommand { get; private set; }
public ICommand LoadItemsCommand { get; protected 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; private FilterViewModel _Filter;
public FilterViewModel Filter public FilterViewModel Filter
@ -85,18 +61,27 @@ namespace AideDeJeu.ViewModels
if (_SelectedItem != null) if (_SelectedItem != null)
{ {
Main.Navigator.GotoItemDetailPageAsync(_SelectedItem); Main.Navigator.GotoItemDetailPageAsync(_SelectedItem);
//Main.GotoItemCommand.Execute(_SelectedItem);
} }
} }
} }
public Items AllItems; private Items _AllItems;
public async Task InitAsync() public Items AllItems
{ {
//AllItems = await Main.GetAllItemsAsync(ItemSourceType); get
Title = AllItems.Name; {
Filter = AllItems.GetNewFilterViewModel(); //Main.GetFilterViewModel(ItemSourceType); return _AllItems;
Filter.LoadItemsCommand = LoadItemsCommand; }
set
{
_AllItems = value;
if (_AllItems != null)
{
Title = _AllItems.Name;
Filter = _AllItems.GetNewFilterViewModel();
Filter.LoadItemsCommand = LoadItemsCommand;
}
}
} }
async Task LoadItemsAsync(CancellationToken cancellationToken = default) async Task LoadItemsAsync(CancellationToken cancellationToken = default)
@ -105,8 +90,6 @@ namespace AideDeJeu.ViewModels
Main.IsLoading = true; Main.IsLoading = true;
try try
{ {
//var filterViewModel = Filter;
//var allItems = await Main.GetAllItemsAsync(ItemSourceType);
var items = await Filter.FilterItems(AllItems, cancellationToken: cancellationToken); var items = await Filter.FilterItems(AllItems, cancellationToken: cancellationToken);
Items = items.ToList(); Items = items.ToList();
} }

View file

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