Example #1
0
        public PeopleListPageCS()
        {
            Title = "Staw Was People";
            var listView = new ListView();

            var viewModel = new PeopleViewModel();

            viewModel.GetPeople();
            listView.ItemsSource = viewModel.SWPeople;

            // Using ItemTapped
            listView.ItemTapped += async(sender, e) =>
            {
                await DisplayAlert("Tapped", e.Item + " row was tapped", "OK");

                Debug.WriteLine("Tapped: " + e.Item);
                ((ListView)sender).SelectedItem = null; // de-select the row
            };

            // If using ItemSelected
            //          listView.ItemSelected += (sender, e) => {
            //              if (e.SelectedItem == null) return;
            //              Debug.WriteLine("Selected: " + e.SelectedItem);
            //              ((ListView)sender).SelectedItem = null; // de-select the row
            //          };

            Padding = new Thickness(0, 20, 0, 0);
            Content = listView;
        }
        private async Task Init()
        {
            _peopleListView = new ListView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
            };

            var cell = new DataTemplate(typeof(TextCell));

            cell.SetBinding(TextCell.TextProperty, "name");
            cell.SetBinding(TextCell.DetailProperty, new Binding(path: "birth_year"));
            cell.SetBinding(TextCell.DetailProperty, new Binding(path: "mass"));

            _peopleListView.ItemTemplate = cell;

            var viewModel = new PeopleViewModel();

            viewModel.GetPeople();
            _peopleListView.ItemsSource = viewModel.SWPeople;


            this.Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness
                                  (
                    left: 0,
                    right: 0,
                    bottom: 0,
                    top: Device.OnPlatform(iOS: 20, Android: 0, WinPhone: 0)
                                  ),
                Children = { _peopleListView }
            };
        }
        public void GetPeopleTest()
        {
            People people = PeopleViewModel.GetPeople("https://swapi.co/api/people/1/");
            string a      = "Luke Skywalker";

            Assert.AreEqual(a, people.name);
        }
        protected override void OnAppearing()
        {
            var viewModel = new PeopleViewModel();

            viewModel.GetPeople();
            listView.ItemsSource = viewModel.SWPeople;
            people = viewModel.SWPeople;

            //listView.ItemsSource = App.Database.GetItems();
        }
        public void getPeopleExemple()
        {
            /// ObservableCollection<People> A = PeopleViewModel.GetListOfPeople();


            People people = PeopleViewModel.GetPeople("https://swapi.co/api/people/1");

            Console.WriteLine(people.name);
            foreach (string i in people.films)
            {
                Film f = FilmViewModel.GetFilm(i);
                Console.WriteLine(f.title);
            }
        }
Example #6
0
 public FilmPage(String url, List <String> backUrl)
 {
     InitializeComponent();
     filmUrl           = url;
     this.backUrl      = backUrl;
     backButton.Click += GoBack;
     if (this.backUrl.Last() == "")
     {
         backButton.Visibility = Visibility.Hidden;
     }
     else
     {
         backButton.Visibility = Visibility.Visible;
     }
     film              = FilmViewModel.GetFilm(url);
     title.Content    += film.title;
     open.Content     += film.opening_crawl + V;
     director.Content += ' ' + film.director;
     producer.Content += ' ' + film.producer;
     release.Content  += ' ' + ConvertToDateTime(film.release_date);
     created.Content  += ' ' + ConvertToDateTime(film.created);
     edited.Content   += ' ' + ConvertToDateTime(film.edited);
     ListCharacters.MouseDoubleClick += CallPeople;
     ListSpaceShip.MouseDoubleClick  += callStarship;
     ListVehicles.MouseDoubleClick   += CallVehicule;
     ListSpecies.MouseDoubleClick    += CallSpecies;
     ListCharacters.Items.Clear();
     ListSpaceShip.Items.Clear();
     ListSpecies.Items.Clear();
     ListVehicles.Items.Clear();
     foreach (String charac in film.characters)
     {
         ListCharacters.Items.Add(PeopleViewModel.GetPeople(charac));
     }
     foreach (String v in film.vehicles)
     {
         ListVehicles.Items.Add(VehicleViewModel.GetVehicle(v));
     }
     foreach (String s in film.starships)
     {
         ListSpaceShip.Items.Add(StarshipViewModel.GetStarship(s));
     }
     foreach (String spe in film.species)
     {
         ListSpecies.Items.Add(SpeciesViewModel.GetSpecies(spe));
     }
 }
Example #7
0
        public PeoplePage(String url, List <String> backUrl)
        {
            InitializeComponent();
            people        = PeopleViewModel.GetPeople(url);
            name.Content += people.name;
            this.backUrl  = backUrl;
            if (this.backUrl.Last() == "")
            {
                backButton.Visibility = Visibility.Hidden;
            }
            else
            {
                backButton.Visibility = Visibility.Visible;
            }
            mass.Content      += ' ' + people.mass;
            height.Content    += ' ' + people.height;
            birth.Content     += ' ' + people.birth_year;
            eye.Content       += ' ' + people.eye_color;
            gender.Content    += ' ' + people.gender;
            hair.Content      += ' ' + people.hair_color;
            homeworld.Content += ' ' + GetHomeWorld(people.homeworld);
            skin.Content      += ' ' + people.skin_color;
            created.Content   += ' ' + ConvertToDateTime(people.created);
            edited.Content    += ' ' + ConvertToDateTime(people.edited);
            backButton.Click  += GoBack;

            listFilms.MouseDoubleClick     += callFilm;
            listStarships.MouseDoubleClick += callStarship;
            listVehicles.MouseDoubleClick  += CallVehicule;

            listFilms.Items.Clear();
            listStarships.Items.Clear();
            listVehicles.Items.Clear();
            foreach (String f in people.films)
            {
                listFilms.Items.Add(FilmViewModel.GetFilm(f));
            }
            foreach (String s in people.starships)
            {
                listStarships.Items.Add(StarshipViewModel.GetStarship(s));
            }
            foreach (String v in people.vehicles)
            {
                listVehicles.Items.Add(VehicleViewModel.GetVehicle(v));
            }
        }
 public StarshipPage(String url, List <String> backUrl)
 {
     InitializeComponent();
     this.backUrl = backUrl;
     if (this.backUrl.Last() == "")
     {
         backButton.Visibility = Visibility.Hidden;
     }
     else
     {
         backButton.Visibility = Visibility.Visible;
     }
     starship                         = StarshipViewModel.GetStarship(url);
     name.Content                    += ' ' + starship.name;
     model.Content                   += ' ' + starship.model;
     manufacturer.Content            += ' ' + starship.manufacturer;
     credits.Content                 += ' ' + starship.cost_in_credits;
     lenght.Content                  += ' ' + starship.length;
     capacity.Content                += ' ' + starship.cargo_capacity;
     Sclass.Content                  += ' ' + starship.starship_class;
     speed.Content                   += ' ' + starship.max_atmosphering_speed;
     hyperdrive.Content              += ' ' + starship.hyperdrive_rating;
     consumables.Content             += ' ' + starship.consumables;
     crew.Content                    += ' ' + starship.crew;
     passengers.Content              += ' ' + starship.passengers;
     created.Content                 += ' ' + ConvertToDateTime(starship.created);
     edited.Content                  += ' ' + ConvertToDateTime(starship.edited);
     listFilms.MouseDoubleClick      += callFilm;
     listCharacters.MouseDoubleClick += callPeople;
     listFilms.Items.Clear();
     listCharacters.Items.Clear();
     backButton.Click += GoBack;
     foreach (String f in starship.films)
     {
         listFilms.Items.Add(FilmViewModel.GetFilm(f));
     }
     foreach (String p in starship.pilots)
     {
         listCharacters.Items.Add(PeopleViewModel.GetPeople(p));
     }
 }
 public SpeciesPage(String url, List <String> backUrl)
 {
     InitializeComponent();
     species      = SpeciesViewModel.GetSpecies(url);
     this.backUrl = backUrl;
     if (this.backUrl.Last() == "")
     {
         backButton.Visibility = Visibility.Hidden;
     }
     else
     {
         backButton.Visibility = Visibility.Visible;
     }
     name.Content                += species.name;
     height.Content              += ' ' + species.average_height;
     lifespan.Content            += ' ' + species.average_lifespan;
     classification.Content      += ' ' + species.classification;
     designation.Content         += ' ' + species.designation;
     eye.Content                 += ' ' + species.eye_colors;
     hair.Content                += ' ' + species.hair_colors;
     homeworld.Content           += ' ' + GetHomeWorld(species.homeworld);
     language.Content            += ' ' + species.language;
     skin.Content                += ' ' + species.skin_colors;
     created.Content             += ' ' + ConvertToDateTime(species.created);
     edited.Content              += ' ' + ConvertToDateTime(species.edited);
     listFilms.MouseDoubleClick  += callFilm;
     listPeople.MouseDoubleClick += callPeople;
     listPeople.Items.Clear();
     listFilms.Items.Clear();
     foreach (String charac in species.people)
     {
         listPeople.Items.Add(PeopleViewModel.GetPeople(charac));
     }
     foreach (String f in species.films)
     {
         listFilms.Items.Add(FilmViewModel.GetFilm(f));
     }
 }
Example #10
0
 public IActionResult Index()
 {
     return(View(vieweModel.GetPeople()));
 }