public PopularMoviesPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            Page = 1;

            AlertBoxCommand = new DelegateCommand(async() =>
            {
                if (SelectedSortLbl == "Most Popular")
                {
                    PopularLbl  = "✔ Most Popular";
                    HighestRate = "  Highest Rated";
                }
                else
                {
                    PopularLbl  = "   Most Popular";
                    HighestRate = "✔ Highest Rated";
                }
                var ans = await UserDialogs.Instance.ActionSheetAsync("Filter", "Cancel", null, null, PopularLbl, HighestRate);
                if (ans != "Cancel")
                {
                    SelectedSortLbl = ans.Replace(SelectLbl, "").Trim();
                    Page            = 1;
                    PopularMovies.Clear();
                    LoadData();
                }
            });

            MessagingCenter.Subscribe <string>("", "OnAppearing", val =>
            {
                OnAppearing();
            });
            MovieDetailCommand = new DelegateCommand <MovieModel>((val) =>
            {
                var param = new NavigationParameters();
                param.Add("Id", val.id);
                NavigationService.NavigateAsync("MovieDetailsPage", param, useModalNavigation: true);
            });
            LoadMoreDataCommand = new DelegateCommand(LoadData);
        }
Пример #2
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                PopularMovies.Clear();
                var popularMovies = await MoviesService.GetPopularMovies();

                foreach (var movie in popularMovies)
                {
                    PopularMovies.Add(movie);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }