public PlatformGameListViewModel() { IsRefreshing = false; RefreshCommand = new Command(async() => { IsRefreshing = true; await PopulateData(false); IsRefreshing = false; }); ItemAppearingCommand = new Command <Models.Juego>(execute: async(Models.Juego juego) => { if (IsLoadingMoreData) { return; } if (juego == JuegosResult.Last() && LoadedElementCount < MaxLoadedElements) { IsLoadingMoreData = true; await PopulateData(true); IsLoadingMoreData = false; } }); }
public async Task PopulateData(bool more) { if (more) { ++Page; LoadedElementCount += 20; } else { Page = 1; LoadedElementCount = 20; } var juegoService = new Services.JuegoService(); var result = await juegoService.GetGamesSearch(Page, SearchQuery); if (!more) { JuegosResult.Clear(); } AddAll(result.Results); }
public SearchPageViewModel() { IsRefreshing = false; RefreshCommand = new Command(async() => { IsRefreshing = true; await PopulateData(false); IsRefreshing = false; }); ItemAppearingCommand = new Command <Models.Juego>(execute: async(Models.Juego juego) => { if (IsLoadingMoreData) { return; } if (juego == JuegosResult.Last() && LoadedElementCount < MaxLoadedElements) { IsLoadingMoreData = true; await PopulateData(true); IsLoadingMoreData = false; } }); SearchCommand = new Command <string>(execute: async(string text) => { if (string.IsNullOrEmpty(text) || string.IsNullOrWhiteSpace(text)) { return; } SearchQuery = text; IsRefreshing = true; await PopulateData(false); IsRefreshing = false; }); }