async void ShowPanelProducNew(StackLayout newProductLayout, string nameBlock, TypeNewsProduct type, int countProduct, int countProductOnPage) { List <Product> productNewList = null; newProductLayout.Padding = new Thickness(18, Constants.TopPaddingNewProductLayout, 18, 0); newProductLayout.Spacing = heightSpacingTitle; newProductLayout.HeightRequest = heightNewProduct; newProductLayout.VerticalOptions = LayoutOptions.FillAndExpand; TapGestureRecognizer tapProduct = new TapGestureRecognizer(); tapProduct.Tapped += ProductClick; Label lblProductNewClothes = new Label { Text = nameBlock, TextColor = ApplicationStyle.GreenColor, FontSize = Utils.GetSize(13), HeightRequest = Constants.HeightTitleNew, }; newProductLayout.Children.Add(lblProductNewClothes); ActivityIndicator indicator = new ActivityIndicator { Color = Device.OnPlatform(Color.Black, Color.Gray, Color.Default), IsRunning = true, VerticalOptions = LayoutOptions.CenterAndExpand, }; newProductLayout.Children.Add(indicator); if (type == TypeNewsProduct.ClothingAndShoes) { if (OnePage.productNew1List == null) { //#if !DEBUG productNewList = await Product.GetProductsNewsClothesListAsync(countProduct); //# endif OnePage.productNew1List = productNewList; } else { productNewList = OnePage.productNew1List; } } else { if (OnePage.productNew2List == null) { productNewList = await Product.GetProductsNewsOthesListAsync(countProduct); OnePage.productNew2List = productNewList; } else { productNewList = OnePage.productNew2List; } } ContentView contentView; if (productNewList != null) { //contentView = null; contentView = new CarouselView(CarouselLayout.IndicatorStyleEnum.Dots, new ProductNewViewModel(productNewList, tapProduct, countProductOnPage), new DataTemplate(typeof(ProductGridTemplate))); } else { contentView = new ContentView { Content = new Label { Text = "Не удалось загрузить новинки", VerticalOptions = LayoutOptions.CenterAndExpand } } }; indicator.IsVisible = false; newProductLayout.Children.Add(new ContentView { HeightRequest = heightNewProduct - heightSpacingTitle - Constants.HeightTitleNew, VerticalOptions = LayoutOptions.FillAndExpand, Content = contentView }); } void ProductClick(object sender, EventArgs e) { ProductNewTemplate productTemp = sender as ProductNewTemplate; OnePage.redirectApp.RedirectToPage(PageName.Catalog, true, false, false); OnePage.redirectApp.catalogView.GoToProductAsync(productTemp.Name, productTemp.Id, false); } void CategoryClick(object sender, EventArgs e) { ButtonCategoryTemplate item = sender as ButtonCategoryTemplate; if (item.CatalogID == CatalogEnum.All) { OnePage.redirectApp.RedirectToPage(PageName.Catalog, false, false); OnePage.redirectApp.catalogView.GotoMainCategory(); } else { OnePage.redirectApp.RedirectToPage(PageName.Catalog, true, false, false); Category category = OnePage.categoryList.FirstOrDefault(g => g.ID == (int)item.CatalogID); if (category == null) { category = new Category { ID = (int)item.CatalogID, Description = new CategoriesDescription { Name = item.Name.Replace("\r", "") } }; } OnePage.redirectApp.catalogView.GoToCategory(category, null, false); } } }
BoxView ShownCategoryPanel(out Grid gridCategory) { BoxView bottomBorder = new BoxView { VerticalOptions = LayoutOptions.End, HeightRequest = heightBottomBorder, BackgroundColor = ApplicationStyle.LineColor, }; gridCategory = new Grid { IsClippedToBounds = true, ColumnSpacing = 0, HeightRequest = heightCategoryPanel, BackgroundColor = ApplicationStyle.LineColor, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(25, GridUnitType.Star) }, new ColumnDefinition { Width = Utils.GetSize(0.5) }, new ColumnDefinition { Width = new GridLength(25, GridUnitType.Star) }, new ColumnDefinition { Width = Utils.GetSize(0.5) }, new ColumnDefinition { Width = new GridLength(25, GridUnitType.Star) }, new ColumnDefinition { Width = Utils.GetSize(0.5) }, new ColumnDefinition { Width = new GridLength(25, GridUnitType.Star) }, new ColumnDefinition { Width = Utils.GetSize(0.5) }, } }; ButtonCategoryTemplate btnDress = new ButtonCategoryTemplate(CatalogEnum.Women, "Женская\r\n одежда", Device.OnPlatform("Catalog/dress_main_.png", "dress_menu_.png", "dress_menu_.png")); ButtonCategoryTemplate btnMen = new ButtonCategoryTemplate(CatalogEnum.Men, "Мужская\r\n одежда", Device.OnPlatform("Catalog/men_main_.png", "pidjak_menu_.png", "pidjak_menu_.png")); ButtonCategoryTemplate btnBag = new ButtonCategoryTemplate(CatalogEnum.Accessory, "Аксессуары", Device.OnPlatform("Catalog/bag_main_.png", "bag_menu_.png", "bag_menu_.png")); ButtonCategoryTemplate btnCatalog = new ButtonCategoryTemplate(CatalogEnum.All, " Все\r\n категории", Device.OnPlatform("Catalog/catalog_main_.png", "menu_menu_.png", "menu_menu_.png")); gridCategory.Children.Add(btnDress, 0, 0); gridCategory.Children.Add(new BoxView { WidthRequest = Utils.GetSize(0.5) }, 1, 0); gridCategory.Children.Add(btnMen, 2, 0); gridCategory.Children.Add(new BoxView { WidthRequest = Utils.GetSize(0.5) }, 3, 0); gridCategory.Children.Add(btnBag, 4, 0); gridCategory.Children.Add(new BoxView { WidthRequest = Utils.GetSize(0.5) }, 5, 0); gridCategory.Children.Add(btnCatalog, 6, 0); gridCategory.Children.Add(new BoxView { WidthRequest = Utils.GetSize(0.5), BackgroundColor = Color.White }, 7, 0); TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += CategoryClick; btnDress.GestureRecognizers.Add(tapGestureRecognizer); btnMen.GestureRecognizers.Add(tapGestureRecognizer); btnBag.GestureRecognizers.Add(tapGestureRecognizer); btnCatalog.GestureRecognizers.Add(tapGestureRecognizer); return(bottomBorder); }