public LikedRecipeDetails(recipe r) { var tapImage = new TapGestureRecognizer(); string[] ratingImageLinks = new string[] { "http://i.imgur.com/7qq8zdR.png", "http://i.imgur.com/BRwowMP.png", "http://i.imgur.com/dNUdKiO.png", "http://i.imgur.com/zK4JmCG.png", "http://i.imgur.com/61WSiZf.png", "http://i.imgur.com/7J7BYuv.png" }; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromUri(new Uri(ratingImageLinks[r.rating])); string hourOrHours = "hours"; string minuteOrMinutes = "minutes"; int time = 0; if (r == null) { return; } Label cookingTimeLabel = new Label(); if (r.totalTimeInSeconds == null) { cookingTimeLabel.Text = ""; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(1); } else { time = (int)r.totalTimeInSeconds; int hours = (int)(time / 3600); int leftOverSeconds = time - (hours * 3600); int minutes = (int)(leftOverSeconds / 60); if (hours == 1) { hourOrHours = "hour"; } if (minutes == 1) { minuteOrMinutes = "minute"; } String cookingTime = ""; if (hours != 0) { cookingTime += hours.ToString() + " " + hourOrHours; } if (minutes != 0) { if (hours != 0) { cookingTime += ", "; } cookingTime += minutes.ToString() + " " + minuteOrMinutes; } cookingTimeLabel.Text = "Time to make: " + cookingTime; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(25); } Label ingredientLabel = new Label { Text = "Ingredients:", Font = Font.BoldSystemFontOfSize(25) }; ListView listview = new ListView(); listview.RowHeight = 40; listview.ItemSelected += (sender, e) => { listview.SelectedItem = null; }; List <Ingredient> ingredients = new List <Ingredient>(); for (int i = 0; i < r.ingredients.Length; i++) { ingredients.Add(new Ingredient { name = r.ingredients[i] }); } listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".name"); Button back = new Button { Text = "Back", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; Label header = new Label { Text = r.recipeName, Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; var recipePic = new Image { Aspect = Aspect.AspectFill, HeightRequest = 200, WidthRequest = 200 }; recipePic.Source = ImageSource.FromUri(new Uri(r.smallImageUrls[0].Substring(0, r.smallImageUrls[0].Length - 4))); tapImage.Tapped += (sender, e) => { var client = new HttpClient(); string url = "http://api.kitchen.support/favorites"; string data = "{\n \"api_token\" : \"" + DependencyService.Get <localDataInterface>().load("token") + "\",\n \"recipe_id\" : \"" + r.id + "\"\n}"; var httpContent = new StringContent(data); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = client.PostAsync(new Uri(url), httpContent); if (response.Result.StatusCode.ToString() != "OK") { } }; recipePic.GestureRecognizers.Add(tapImage); Button markComplete = new Button { Text = "Mark as complete", BackgroundColor = Color.FromHex("77D065") }; Button viewRecipeButton = new Button(); viewRecipeButton.Text = "View Recipe"; viewRecipeButton.BackgroundColor = Color.FromHex("77D065"); viewRecipeButton.Clicked += delegate { Device.OpenUri(new Uri("http://www.yummly.com/recipe/" + r.yummly_id)); }; markComplete.Clicked += (sender, e) => { var client = new HttpClient(); string url = "http://api.kitchen.support/completed"; string data = "{\n \"api_token\" : \"" + DependencyService.Get <localDataInterface>().load("token") + "\",\n \"recipe_id\" : \"" + r.id + "\"\n}"; var httpContent = new StringContent(data); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = client.PostAsync(new Uri(url), httpContent); if (response.Result.StatusCode.ToString() != "OK") { } }; Button dislike = new Button { Text = "Dislike Recipe", BackgroundColor = Color.FromHex("77D065") }; dislike.Clicked += (sender, e) => { /*var likeClient = new HttpClient(); * string likeUrl = "http://api.kitchen.support/likes"; * string data = "{\n \"api_token\" : \"" + DependencyService.Get<localDataInterface>().load("token") + "\",\n \"recipe_id\" : \"" + r.id + "\"\n}"; * var dislikeRequest = (HttpWebRequest)WebRequest.Create(likeUrl); * dislikeRequest.Method = "DELETE"; * dislikeRequest.ContentType = "application/json"; * dislikeRequest.Accept = "application/json"; * //byte[] byt = "recipient=12345ABC"; * * var dislikeResponse = dislikeRequest.GetResponseAsync(); * if (dislikeResponse.Status.ToString() != "OK") * { * * }*/ Navigation.PopModalAsync(); }; int favorites = (int)r.favorites; string favoritesStatement = ""; if (favorites == 0 || r.favorites == null) { favoritesStatement = "Tap the image to be the first to like this recipe!"; } else { favoritesStatement = "Tap the image to join the "; if (favorites == 1) { favoritesStatement += "1 person who has favorited this recipe!"; } else { favoritesStatement += favorites.ToString() + " people who have favorited this recipe!"; } } Label favoritesLabel = new Label { Text = favoritesStatement, Font = Font.BoldSystemFontOfSize(15), HorizontalOptions = LayoutOptions.Center }; var scroll = new ScrollView { Content = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { back, header, recipePic, favoritesLabel, ratingImage, cookingTimeLabel, ingredientLabel, listview, viewRecipeButton, markComplete, dislike } }, }; this.Content = scroll; back.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; }
public RecipeDetails(recipe r) { Label header = new Label { Text = r.recipeName, Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; var recipePic = new Image { Aspect = Aspect.AspectFill, HeightRequest = 200, WidthRequest = 200 }; recipePic.Source = ImageSource.FromUri(new Uri(r.smallImageUrls[0].Substring(0, r.smallImageUrls[0].Length - 4))); /*String ratingImageName = r.rating.ToString() + "star.png"; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromFile(ratingImageName);*/ string[] ratingImageLinks = new string[] { "http://i.imgur.com/7qq8zdR.png", "http://i.imgur.com/BRwowMP.png", "http://i.imgur.com/dNUdKiO.png", "http://i.imgur.com/zK4JmCG.png", "http://i.imgur.com/61WSiZf.png", "http://i.imgur.com/7J7BYuv.png" }; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromUri(new Uri(ratingImageLinks[r.rating])); string hourOrHours = "hours"; string minuteOrMinutes = "minutes"; int time = 0; if (r == null) { return; } Label cookingTimeLabel = new Label(); if (r.totalTimeInSeconds == null) { cookingTimeLabel.Text = ""; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(1); } else { time = (int) r.totalTimeInSeconds; int hours = (int)(time / 3600); int leftOverSeconds = time - (hours * 3600); int minutes = (int)(leftOverSeconds / 60); if (hours == 1) { hourOrHours = "hour"; } if (minutes == 1) { minuteOrMinutes = "minute"; } String cookingTime = ""; if (hours != 0) { cookingTime += hours.ToString() + " " + hourOrHours; } if (minutes != 0) { if (hours != 0) cookingTime += ", "; cookingTime += minutes.ToString() + " " + minuteOrMinutes; } cookingTimeLabel.Text = "Time to make: " + cookingTime; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(25); } Label ingredientLabel = new Label { Text = "Ingredients:", Font = Font.BoldSystemFontOfSize(25) }; listview = new ListView(); listview.RowHeight = 40; ingredients = new List<Ingredient>(); for (int i = 0; i < r.ingredients.Length; i++) { ingredients.Add(new Ingredient { name = r.ingredients[i], quantity = 0, unit = " " }); } listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".name"); //listview.ItemTemplate.SetBinding(TextCell.DetailProperty, ".unitAndQuantity"); Button viewRecipeButton = new Button(); viewRecipeButton.Text = "View Recipe"; viewRecipeButton.BackgroundColor = Color.FromHex("77D065"); viewRecipeButton.Clicked += delegate { Device.OpenUri(new Uri("http://bfy.tw/333q")); }; this.Content = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { header, recipePic, ratingImage, cookingTimeLabel, ingredientLabel, listview, viewRecipeButton } }; }
public LikedRecipeDetails(recipe r) { var tapImage = new TapGestureRecognizer(); string[] ratingImageLinks = new string[] { "http://i.imgur.com/7qq8zdR.png", "http://i.imgur.com/BRwowMP.png", "http://i.imgur.com/dNUdKiO.png", "http://i.imgur.com/zK4JmCG.png", "http://i.imgur.com/61WSiZf.png", "http://i.imgur.com/7J7BYuv.png" }; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromUri(new Uri(ratingImageLinks[r.rating])); string hourOrHours = "hours"; string minuteOrMinutes = "minutes"; int time = 0; if (r == null) { return; } Label cookingTimeLabel = new Label(); if (r.totalTimeInSeconds == null) { cookingTimeLabel.Text = ""; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(1); } else { time = (int)r.totalTimeInSeconds; int hours = (int)(time / 3600); int leftOverSeconds = time - (hours * 3600); int minutes = (int)(leftOverSeconds / 60); if (hours == 1) { hourOrHours = "hour"; } if (minutes == 1) { minuteOrMinutes = "minute"; } String cookingTime = ""; if (hours != 0) { cookingTime += hours.ToString() + " " + hourOrHours; } if (minutes != 0) { if (hours != 0) cookingTime += ", "; cookingTime += minutes.ToString() + " " + minuteOrMinutes; } cookingTimeLabel.Text = "Time to make: " + cookingTime; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(25); } Label ingredientLabel = new Label { Text = "Ingredients:", Font = Font.BoldSystemFontOfSize(25) }; ListView listview = new ListView(); listview.RowHeight = 40; listview.ItemSelected += (sender, e) => { listview.SelectedItem = null; }; List<Ingredient> ingredients = new List<Ingredient>(); for (int i = 0; i < r.ingredients.Length; i++) { ingredients.Add(new Ingredient { name = r.ingredients[i] }); } listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".name"); Button back = new Button { Text = "Back", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; Label header = new Label { Text = r.recipeName, Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; var recipePic = new Image { Aspect = Aspect.AspectFill, HeightRequest = 200, WidthRequest = 200 }; recipePic.Source = ImageSource.FromUri(new Uri(r.smallImageUrls[0].Substring(0, r.smallImageUrls[0].Length - 4))); tapImage.Tapped += (sender, e) => { var client = new HttpClient(); string url = "http://api.kitchen.support/favorites"; string data = "{\n \"api_token\" : \"" + DependencyService.Get<localDataInterface>().load("token") + "\",\n \"recipe_id\" : \"" + r.id + "\"\n}"; var httpContent = new StringContent(data); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = client.PostAsync(new Uri(url), httpContent); if (response.Result.StatusCode.ToString() != "OK") { } }; recipePic.GestureRecognizers.Add(tapImage); Button markComplete = new Button { Text = "Mark as complete", BackgroundColor = Color.FromHex("77D065") }; Button viewRecipeButton = new Button(); viewRecipeButton.Text = "View Recipe"; viewRecipeButton.BackgroundColor = Color.FromHex("77D065"); viewRecipeButton.Clicked += delegate { Device.OpenUri(new Uri("http://www.yummly.com/recipe/" + r.yummly_id)); }; markComplete.Clicked += (sender, e) => { var client = new HttpClient(); string url = "http://api.kitchen.support/completed"; string data = "{\n \"api_token\" : \"" + DependencyService.Get<localDataInterface>().load("token") + "\",\n \"recipe_id\" : \"" + r.id + "\"\n}"; var httpContent = new StringContent(data); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = client.PostAsync(new Uri(url), httpContent); if (response.Result.StatusCode.ToString() != "OK") { } }; Button dislike = new Button { Text = "Dislike Recipe", BackgroundColor = Color.FromHex("77D065") }; dislike.Clicked += (sender, e) => { /*var likeClient = new HttpClient(); string likeUrl = "http://api.kitchen.support/likes"; string data = "{\n \"api_token\" : \"" + DependencyService.Get<localDataInterface>().load("token") + "\",\n \"recipe_id\" : \"" + r.id + "\"\n}"; var dislikeRequest = (HttpWebRequest)WebRequest.Create(likeUrl); dislikeRequest.Method = "DELETE"; dislikeRequest.ContentType = "application/json"; dislikeRequest.Accept = "application/json"; //byte[] byt = "recipient=12345ABC"; var dislikeResponse = dislikeRequest.GetResponseAsync(); if (dislikeResponse.Status.ToString() != "OK") { }*/ Navigation.PopModalAsync(); }; int favorites = (int)r.favorites; string favoritesStatement = ""; if (favorites == 0 || r.favorites == null) { favoritesStatement = "Tap the image to be the first to like this recipe!"; } else { favoritesStatement = "Tap the image to join the "; if (favorites == 1) { favoritesStatement += "1 person who has favorited this recipe!"; } else { favoritesStatement += favorites.ToString() + " people who have favorited this recipe!"; } } Label favoritesLabel = new Label { Text = favoritesStatement, Font = Font.BoldSystemFontOfSize(15), HorizontalOptions = LayoutOptions.Center }; var scroll = new ScrollView { Content = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { back, header, recipePic, favoritesLabel, ratingImage, cookingTimeLabel, ingredientLabel, listview, viewRecipeButton, markComplete, dislike } }, }; this.Content = scroll; back.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; }
public RecipeInterface() { { this.Title = " Kitchen.Support"; var tapImage = new TapGestureRecognizer(); Button dislike = new Button { Text = "Dislike this recipe", BackgroundColor = Color.FromHex("77D065") }; dislike.Clicked += (sender, e) => { }; recipe r = new recipe(); r.completed = false; r.recipeName = "There are hot Kraft Singles in your area!"; r.liked = false; r.favorited = false; r.id = 69; r.totalTimeInSeconds = 420; r.rating = 5; r.smallImageUrls = new string[1]; r.smallImageUrls[0] = "http://www.blisstree.com/wp-content/uploads/2014/02/kraft-singles-.jpg"; r.ingredients = new string[1]; r.ingredients[0] = "You"; r.favorites = 69; string[] ratingImageLinks = new string[] { "http://i.imgur.com/7qq8zdR.png", "http://i.imgur.com/BRwowMP.png", "http://i.imgur.com/dNUdKiO.png", "http://i.imgur.com/zK4JmCG.png", "http://i.imgur.com/61WSiZf.png", "http://i.imgur.com/7J7BYuv.png" }; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromUri(new Uri(ratingImageLinks[r.rating])); string hourOrHours = "hours"; string minuteOrMinutes = "minutes"; int time = 0; if (r == null) { return; } Label cookingTimeLabel = new Label(); if (r.totalTimeInSeconds == null) { cookingTimeLabel.Text = ""; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(1); } else { time = (int)r.totalTimeInSeconds; int hours = (int)(time / 3600); int leftOverSeconds = time - (hours * 3600); int minutes = (int)(leftOverSeconds / 60); if (hours == 1) { hourOrHours = "hour"; } if (minutes == 1) { minuteOrMinutes = "minute"; } String cookingTime = ""; if (hours != 0) { cookingTime += hours.ToString() + " " + hourOrHours; } if (minutes != 0) { if (hours != 0) { cookingTime += ", "; } cookingTime += minutes.ToString() + " " + minuteOrMinutes; } cookingTimeLabel.Text = "Time to make: " + cookingTime; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(25); } Label ingredientLabel = new Label { Text = "Ingredients:", Font = Font.BoldSystemFontOfSize(25) }; ListView listview = new ListView(); listview.RowHeight = 40; listview.ItemSelected += (sender, e) => { listview.SelectedItem = null; }; List <Ingredient> ingredients = new List <Ingredient>(); for (int i = 0; i < r.ingredients.Length; i++) { ingredients.Add(new Ingredient { name = r.ingredients[i] }); } listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".name"); Button back = new Button { Text = "Back", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; Label header = new Label { Text = r.recipeName, Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; var recipePic = new Image { Aspect = Aspect.AspectFill, HeightRequest = 200, WidthRequest = 200 }; recipePic.Source = ImageSource.FromUri(new Uri(r.smallImageUrls[0])); Button markComplete = new Button { Text = "Mark as complete", BackgroundColor = Color.FromHex("77D065") }; Button viewRecipeButton = new Button(); viewRecipeButton.Text = "View Recipe"; viewRecipeButton.BackgroundColor = Color.FromHex("77D065"); viewRecipeButton.Clicked += delegate { }; markComplete.Clicked += (sender, e) => { }; int favorites = (int)r.favorites; string favoritesStatement = ""; if (favorites == 0 || r.favorites == null) { favoritesStatement = "Tap the image to be the first to favorite this recipe!"; } else { favoritesStatement = "Tap the image to join the "; if (favorites == 1) { favoritesStatement += "1 person who has favorited this recipe!"; } else { favoritesStatement += favorites.ToString() + " people who have favorited this recipe!"; } } Label favoritesLabel = new Label { Text = favoritesStatement, Font = Font.BoldSystemFontOfSize(15), HorizontalOptions = LayoutOptions.Center }; var stack = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { back, header, recipePic, favoritesLabel, ratingImage, cookingTimeLabel, ingredientLabel, listview, viewRecipeButton, markComplete } }; var scroll = new ScrollView { Content = stack }; this.Content = scroll; back.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; } }
public RecipeDetails(recipe r) { Label header = new Label { Text = r.recipeName, Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; var recipePic = new Image { Aspect = Aspect.AspectFill, HeightRequest = 200, WidthRequest = 200 }; recipePic.Source = ImageSource.FromUri(new Uri(r.smallImageUrls[0].Substring(0, r.smallImageUrls[0].Length - 4))); /*String ratingImageName = r.rating.ToString() + "star.png"; * var ratingImage = new Image { Aspect = Aspect.AspectFit }; * ratingImage.Source = ImageSource.FromFile(ratingImageName);*/ string[] ratingImageLinks = new string[] { "http://i.imgur.com/7qq8zdR.png", "http://i.imgur.com/BRwowMP.png", "http://i.imgur.com/dNUdKiO.png", "http://i.imgur.com/zK4JmCG.png", "http://i.imgur.com/61WSiZf.png", "http://i.imgur.com/7J7BYuv.png" }; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromUri(new Uri(ratingImageLinks[r.rating])); string hourOrHours = "hours"; string minuteOrMinutes = "minutes"; int time = 0; if (r == null) { return; } Label cookingTimeLabel = new Label(); if (r.totalTimeInSeconds == null) { cookingTimeLabel.Text = ""; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(1); } else { time = (int)r.totalTimeInSeconds; int hours = (int)(time / 3600); int leftOverSeconds = time - (hours * 3600); int minutes = (int)(leftOverSeconds / 60); if (hours == 1) { hourOrHours = "hour"; } if (minutes == 1) { minuteOrMinutes = "minute"; } String cookingTime = ""; if (hours != 0) { cookingTime += hours.ToString() + " " + hourOrHours; } if (minutes != 0) { if (hours != 0) { cookingTime += ", "; } cookingTime += minutes.ToString() + " " + minuteOrMinutes; } cookingTimeLabel.Text = "Time to make: " + cookingTime; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(25); } Label ingredientLabel = new Label { Text = "Ingredients:", Font = Font.BoldSystemFontOfSize(25) }; listview = new ListView(); listview.RowHeight = 40; ingredients = new List <Ingredient>(); for (int i = 0; i < r.ingredients.Length; i++) { ingredients.Add(new Ingredient { name = r.ingredients[i], quantity = 0, unit = " " }); } listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".name"); //listview.ItemTemplate.SetBinding(TextCell.DetailProperty, ".unitAndQuantity"); Button viewRecipeButton = new Button(); viewRecipeButton.Text = "View Recipe"; viewRecipeButton.BackgroundColor = Color.FromHex("77D065"); viewRecipeButton.Clicked += delegate { Device.OpenUri(new Uri("http://bfy.tw/333q")); }; this.Content = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { header, recipePic, ratingImage, cookingTimeLabel, ingredientLabel, listview, viewRecipeButton } }; }
public RecipeInterface() { { this.Title = " Kitchen.Support"; var tapImage = new TapGestureRecognizer(); Button dislike = new Button { Text = "Dislike this recipe", BackgroundColor = Color.FromHex("77D065") }; dislike.Clicked += (sender, e) => { }; recipe r = new recipe(); r.completed = false; r.recipeName = "There are hot Kraft Singles in your area!"; r.liked = false; r.favorited = false; r.id = 69; r.totalTimeInSeconds = 420; r.rating = 5; r.smallImageUrls = new string[1]; r.smallImageUrls[0] = "http://www.blisstree.com/wp-content/uploads/2014/02/kraft-singles-.jpg"; r.ingredients = new string[1]; r.ingredients[0] = "You"; r.favorites = 69; string[] ratingImageLinks = new string[] { "http://i.imgur.com/7qq8zdR.png", "http://i.imgur.com/BRwowMP.png", "http://i.imgur.com/dNUdKiO.png", "http://i.imgur.com/zK4JmCG.png", "http://i.imgur.com/61WSiZf.png", "http://i.imgur.com/7J7BYuv.png" }; var ratingImage = new Image { Aspect = Aspect.AspectFit }; ratingImage.Source = ImageSource.FromUri(new Uri(ratingImageLinks[r.rating])); string hourOrHours = "hours"; string minuteOrMinutes = "minutes"; int time = 0; if (r == null) { return; } Label cookingTimeLabel = new Label(); if (r.totalTimeInSeconds == null) { cookingTimeLabel.Text = ""; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(1); } else { time = (int)r.totalTimeInSeconds; int hours = (int)(time / 3600); int leftOverSeconds = time - (hours * 3600); int minutes = (int)(leftOverSeconds / 60); if (hours == 1) { hourOrHours = "hour"; } if (minutes == 1) { minuteOrMinutes = "minute"; } String cookingTime = ""; if (hours != 0) { cookingTime += hours.ToString() + " " + hourOrHours; } if (minutes != 0) { if (hours != 0) cookingTime += ", "; cookingTime += minutes.ToString() + " " + minuteOrMinutes; } cookingTimeLabel.Text = "Time to make: " + cookingTime; cookingTimeLabel.Font = Font.BoldSystemFontOfSize(25); } Label ingredientLabel = new Label { Text = "Ingredients:", Font = Font.BoldSystemFontOfSize(25) }; ListView listview = new ListView(); listview.RowHeight = 40; listview.ItemSelected += (sender, e) => { listview.SelectedItem = null; }; List<Ingredient> ingredients = new List<Ingredient>(); for (int i = 0; i < r.ingredients.Length; i++) { ingredients.Add(new Ingredient { name = r.ingredients[i] }); } listview.ItemsSource = ingredients; listview.ItemTemplate = new DataTemplate(typeof(TextCell)); listview.ItemTemplate.SetBinding(TextCell.TextProperty, ".name"); Button back = new Button { Text = "Back", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start }; Label header = new Label { Text = r.recipeName, Font = Font.BoldSystemFontOfSize(40), HorizontalOptions = LayoutOptions.Center }; var recipePic = new Image { Aspect = Aspect.AspectFill, HeightRequest = 200, WidthRequest = 200 }; recipePic.Source = ImageSource.FromUri(new Uri(r.smallImageUrls[0])); Button markComplete = new Button { Text = "Mark as complete", BackgroundColor = Color.FromHex("77D065") }; Button viewRecipeButton = new Button(); viewRecipeButton.Text = "View Recipe"; viewRecipeButton.BackgroundColor = Color.FromHex("77D065"); viewRecipeButton.Clicked += delegate { }; markComplete.Clicked += (sender, e) => { }; int favorites = (int)r.favorites; string favoritesStatement = ""; if (favorites == 0 || r.favorites == null) { favoritesStatement = "Tap the image to be the first to favorite this recipe!"; } else { favoritesStatement = "Tap the image to join the "; if (favorites == 1) { favoritesStatement += "1 person who has favorited this recipe!"; } else { favoritesStatement += favorites.ToString() + " people who have favorited this recipe!"; } } Label favoritesLabel = new Label { Text = favoritesStatement, Font = Font.BoldSystemFontOfSize(15), HorizontalOptions = LayoutOptions.Center }; var stack = new StackLayout { Spacing = 20, Padding = 50, VerticalOptions = LayoutOptions.Center, Children = { back, header, recipePic, favoritesLabel, ratingImage, cookingTimeLabel, ingredientLabel, listview, viewRecipeButton, markComplete } }; var scroll = new ScrollView { Content = stack }; this.Content = scroll; back.Clicked += (sender, e) => { Navigation.PopModalAsync(); }; } }