public MainPageViewModel(INavigationService navigationService, IPokeApi pokeApi, IPageDialogService pageDialogService)
            : base(navigationService)
        {
            Title = "Main Page";

            _pokeApi           = pokeApi;
            _pageDialogService = pageDialogService;

            NavegarCommand = new DelegateCommand <Pokemon>(async(pokemon) => await NavegarCommandExecute(pokemon));
            GaleriaCommand = new DelegateCommand <Pokemon>(async(pokemon) => await GaleriaCommandExecute(pokemon));
            RefreshCommand = new DelegateCommand(async() => await RefreshCommandExecute());

            Pokemons = new InfiniteScrollCollection <Pokemon>
            {
                OnLoadMore = async() =>
                {
                    IsBusy = true;
                    var items = new List <Pokemon>();
                    PokemonList = await _pokeApi.ObterListaPokemons(offset : OffSet);

                    if (PokemonList != null)
                    {
                        foreach (var poke in PokemonList.results)
                        {
                            var pokemon = await _pokeApi.ObterPokemon(poke.url);

                            if (pokemon != null)
                            {
                                items.Add(pokemon);
                            }
                        }
                        offset += 20;
                    }
                    IsBusy = false;

                    return(items);
                },
                OnCanLoadMore = () =>
                {
                    if (!string.IsNullOrEmpty(PokemonList.next))
                    {
                        return(true);
                    }

                    return(false);
                }
            };

            Pokemons.LoadMoreAsync();
        }
Beispiel #2
0
 public PokedexViewModel(IPokeApi repositoryService)
 {
 }
Beispiel #3
0
 public PokemonRepository(ILogger <PokemonRepository> logger, IPokeApi api)
 {
     _logger             = logger;
     _api                = api;
     _escapeCleanerRegex = new Regex(@"[\n\t\f\a]", RegexOptions.Compiled);
 }
Beispiel #4
0
 public PokeApiAdapter(IPokeApi pokeApi)
 {
     this.pokeApi = pokeApi ?? throw new ArgumentNullException(nameof(pokeApi));
 }
Beispiel #5
0
 public DetalhePokemonViewModel(INavigationService navigationService, IPokeApi pokeApi, IPageDialogService pageDialogService) : base(navigationService)
 {
 }