private async void checkLiked() { List <Elephant> elephants = await ElephantRepo.GetAnimalsAsync(); foreach (var elephant_item in ElephantRepo.favorites) { if (elephant_item.Name == elephant.Name) { btnLike.Text = "Remove from favourites"; btnLike.BackgroundColor = Color.FromHex("A40E4C"); } } }
private async void elephantButton_Clicked(object sender, EventArgs e) { Button btn = (Button)sender; var name = btn.Text; List <Elephant> elephants = await ElephantRepo.GetAnimalsAsync(); foreach (var elephant_item in elephants) { if (elephant_item.Name == name) { Navigation.PushAsync(new ElephantDetail(elephant_item)); } } }
private async void SearchBar_TextChanged(object sender, TextChangedEventArgs e) { SearchBar searchBar = (SearchBar)sender; List<Elephant> elephants = await ElephantRepo.GetFeMaleElephants(); if (string.IsNullOrEmpty(e.NewTextValue)) { lvwElephant.ItemsSource = elephants; } else { //list.ItemsSource = tempdata.Where(x => x.Name.StartsWith(e.NewTextValue)); lvwElephant.ItemsSource = elephants.Take(47).Where(x => x.Name.ToUpper().StartsWith(searchBar.Text.ToUpper())); } }
void btnLike_Clicked(System.Object sender, System.EventArgs e) { if (btnLike.Text == "Add to favourites") { btnLike.Text = "Remove from favourites"; btnLike.BackgroundColor = Color.FromHex("A40E4C"); btnLike.TextColor = Color.White; ElephantRepo.addToFavorite(elephant); } else if (btnLike.Text == "Remove from favourites") { btnLike.Text = "Add to favourites"; btnLike.BackgroundColor = Color.FromHex("65A281"); ElephantRepo.RemoveFromFavorite(elephant); } }
private async Task ShowElephants() { List <Elephant> elephants = await ElephantRepo.GetAnimalsAsync(); lvwElephant.ItemsSource = elephants; }
private async Task ShowElephants() { List<Elephant> elephants = await ElephantRepo.GetFeMaleElephants(); lvwElephant.ItemsSource = elephants; }