// populates the home tab private void PopulateHomeTab(JObject result) { //set the logo Logo.Source = Utils.GetRestaurantField(result, "LogoUrl"); Logo.WidthRequest = Application.Current.MainPage.Height / 8; Logo.HeightRequest = Application.Current.MainPage.Height / 8; NameLabel.Text = Utils.GetRestaurantField(result, "Name"); CuisinesLabel.Text = Utils.GetRestaurantField(result, "CuisineTypes"); //set the price range of that restuarant int price = 0; if (result["PricePoint"].Type != JTokenType.Null) { price = Int32.Parse(result["PricePoint"].ToString(), CultureInfo.CurrentCulture); } PriceLabel.Text = Utils.GetRestaurantField(result, "PricePoint", "£", price); HomeStars.Value = Convert.ToDouble(Utils.GetRestaurantField(result, "AverageReviewScore")); DescriptionLabel.Text = Utils.GetRestaurantField(consumer, "ShortDescription"); //set functionality of clicking the ViewMore button on the HomePage var viewMoreTap = new TapGestureRecognizer(); viewMoreTap.Tapped += async(s, e) => { await Navigation.PushPopupAsync(new AboutPopup(Utils.GetRestaurantField(consumer, "Description"))); }; ViewMoreLabel.GestureRecognizers.Clear(); ViewMoreLabel.GestureRecognizers.Add(viewMoreTap); OpeningInformationLabel.Text = Utils.GetRestaurantField(consumer, "OpeningInformation").Replace("<br/>", Environment.NewLine); //Set the Social Media of each restaurant if (consumer["SocialNetworks"].Type == JTokenType.Null || string.IsNullOrEmpty(consumer["SocialNetworks"].ToString())) { SocialMediaLabel.IsVisible = true; SocialMediaLabel.Text = "No social media"; } else if (consumer["SocialNetworks"] is JArray) { JToken[] arr = consumer["SocialNetworks"].ToArray(); int column = 0; foreach (var a in arr) { //create a button for each social media platform - to link to it Button button = new Button { Text = a["Type"].ToString(), Margin = new Thickness(15, 10, 0, 0), TextColor = Color.FromHex("#11a0dc"), FontSize = 12, CornerRadius = 18, BorderWidth = 2, BorderColor = Color.FromHex("#11a0dc"), VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Start }; button.SetDynamicResource(Button.BackgroundColorProperty, "BarBackgroundColor"); HomeGrid.Children.Add(button, column, 15); column++; button.Clicked += async(sender, args) => await Browser.OpenAsync(a["Url"].ToString(), BrowserLaunchMode.SystemPreferred); } } //set up the maps for the application double latitude = Convert.ToDouble(result["Latitude"].ToString(), CultureInfo.CurrentCulture); double longitude = Convert.ToDouble(result["Longitude"].ToString(), CultureInfo.CurrentCulture); string name = result["Name"].ToString(); //add a pin for the current restaurant var pin = new Pin() { Position = new Position(latitude, longitude), Label = name, }; MapArea.Pins.Add(pin); MapArea.MoveToRegion(new MapSpan(new Position(latitude, longitude), 0.01, 0.01)); // open up directions to restaurant in map app when map area is clicked MapArea.MapClicked += async(object sender, MapClickedEventArgs e) => { await Xamarin.Essentials.Map.OpenAsync( new Location(latitude, longitude), new MapLaunchOptions { Name = name, NavigationMode = NavigationMode.Default } ); }; }