Esempio n. 1
0
        async void IngredientSearchBar_SearchButtonPressed(object sender, EventArgs e)
        {
            if (IngredientSearchBar.Placeholder == "Sök recept" || IngredientSearchBar.Placeholder == "Hittade inga recept")
            {
                var keyword = IngredientSearchBar.Text;

                IngredientSearchBar.Text = null;

                IngredientSearchBar.Placeholder = RandomFunctionality.WhatMeal("Alla recept");

                progbar.IsVisible = true;
                progbar.Progress  = 0;

                progbar.ProgressTo(0.65, 7000, Easing.Linear);

                RModel.RecipeList.Clear();

                RecipeListView.BindingContext = RModel;

                List <string> recipes = new List <string> {
                };

                var scraper = new RecipesScraper();

                await Task.WhenAll(
                    scraper.GetRecipesTasteline(keyword, "1"),
                    scraper.GetRecipesTasteline(keyword, "2"),
                    scraper.GetRecipesTasteline(keyword, "3"),
                    scraper.GetRecipesKoket(keyword),
                    scraper.GetRecipesMittkok(keyword),
                    scraper.GetRecipesCoop(keyword)
                    );

                var recipeList = scraper.ListSorter(scraper.ListOfRecipes);

                if (recipeList.Count == 0)
                {
                    IngredientSearchBar.Placeholder = "Hittade inga recept";
                }
                else
                {
                    foreach (Recipe recipe in recipeList)
                    {
                        recipes.Add(recipe.Title);
                        RModel.RecipeList.Add(recipe);
                    }
                    IngredientSearchBar.Placeholder = "Sök recept";
                }

                await progbar.ProgressTo(1, 600, Easing.Linear);

                progbar.IsVisible = false;
            }
        }
Esempio n. 2
0
        private async void btnsearch_Clicked(object sender, EventArgs e)
        {
            await btnsearch.ScaleTo(1.1, 80);

            await btnsearch.ScaleTo(1, 80, Easing.BounceOut);

            if (IngredientSearchBar.Placeholder == "Sök recept" || IngredientSearchBar.Placeholder == "Hittade inga recept")
            {
                IngredientSearchBar.Placeholder = RandomFunctionality.WhatMeal(selectedCategory);

                tp.CurrentPage = tp.Children[1];

                progbar.IsVisible = true;
                progbar.Progress  = 0;

                progbar.ProgressTo(0.65, 7000, Easing.Linear);

                List <string> listan = new List <string>();

                foreach (var item in PersonalIngredientList)
                {
                    if (item.selectedItem)
                    {
                        listan.Add(item.Name);
                    }
                }

                string searchword = selectedCategory;

                if (selectedCategory.Equals("Alla recept"))
                {
                    searchword = "";
                }

                foreach (var ord in listan)
                {
                    searchword += " " + ord;
                }

                RModel.RecipeList.Clear();

                RecipeListView.BindingContext = RModel;

                List <string> recipes = new List <string> {
                };

                var scraper = new RecipesScraper();

                await Task.WhenAll(
                    scraper.GetRecipesTasteline(searchword, "1"),
                    scraper.GetRecipesTasteline(searchword, "2"),
                    scraper.GetRecipesTasteline(searchword, "3"),
                    scraper.GetRecipesKoket(searchword),
                    scraper.GetRecipesMittkok(searchword),
                    scraper.GetRecipesCoop(searchword)
                    );

                var recipeList = scraper.ListSorter(scraper.ListOfRecipes);

                if (recipeList.Count == 0)
                {
                    IngredientSearchBar.Placeholder = "Hittade inga recept";
                }
                else
                {
                    foreach (Recipe recipe in recipeList)
                    {
                        recipes.Add(recipe.Title);
                        RModel.RecipeList.Add(recipe);
                    }
                    IngredientSearchBar.Placeholder = "Sök recept";
                }

                await progbar.ProgressTo(1, 600, Easing.Linear);

                progbar.IsVisible = false;
            }
        }