public bool SelectCategory(int catId, bool scrollToSelected = false) { if (this.ActiveCategory != null && this.ActiveCategory.CategoryId == catId) { return(false); } int index = -1; for (int i = 0; i < this.categories.Count; i++) { if (this.categories[i].CategoryId == catId) { index = i; this.categories[i].Select(); this.ActiveCategory = this.categories[i]; } else { this.categories[i].Deselect(); } } if (this.positioner != null) { this.positioner.CheckFit(index); } else if (scrollToSelected) { this.layout.ScrollToIndex(index); } return(true); }
public void Compose(List <CategoryInfo> catInfos, bool filterCompleted) { this.btnPrefab = ((!SafeLayout.IsTablet) ? this.phoneBtnPrefab : this.tabletBtnPrefab); CategoryBar.ViewConfig config = (!SafeLayout.IsTablet) ? this.phoneConfig : this.tabletConfig; this.layout.Init(config); string textByKey = LocalizationService.Instance.GetTextByKey("filter_showAllCategories"); CategoryFilterButton categoryFilterButton = this.CreateButton(); categoryFilterButton.Init(CategoryBar.ShowAllCategoryId, textByKey); this.layout.Add(categoryFilterButton); this.categories.Add(categoryFilterButton); for (int i = 0; i < catInfos.Count; i++) { CategoryFilterButton categoryFilterButton2 = this.CreateButton(); categoryFilterButton2.Init(catInfos[i].id, catInfos[i].name); this.layout.Add(categoryFilterButton2); this.categories.Add(categoryFilterButton2); } this.positioner = this.layout.transform.parent.GetComponent <ScrollElementPositioner>(); if (this.positioner != null) { List <Vector2> list = new List <Vector2>(); for (int j = 0; j < this.categories.Count; j++) { list.Add(((RectTransform)this.categories[j].transform).anchoredPosition); } this.positioner.Init(list, config.padding, config.spacing); } }
public void OnCategoryClick(CategoryFilterButton btn) { if (this.pageController.Select.OpenCategory(btn.CategoryId, false)) { this.popupManager.CloseActive(); } }
public void Compose(List <CategoryInfo> catInfos, bool filterCompleted) { Vector2 anchoredPosition = this.rootRt.anchoredPosition; this.rootRt.anchoredPosition = new Vector2(-7000f, 0f); this.rootRt.gameObject.SetActive(true); string textByKey = LocalizationService.Instance.GetTextByKey("filter_hideColored"); string textByKey2 = LocalizationService.Instance.GetTextByKey("filter_showAllCategories"); this.completeFilterButton.Init(-1, textByKey); int num = 0; VerticalLayoutGroup component = this.content.GetComponent <VerticalLayoutGroup>(); num += component.padding.top; num += component.padding.bottom; if (filterCompleted) { this.completeFilterButton.Select(); } else { this.completeFilterButton.Deselect(); } CategoryFilterButton categoryFilterButton = this.CreateButton(); categoryFilterButton.Init(ContentFilterNavBar.ShowAllCategoryId, textByKey2); this.categories.Add(categoryFilterButton); for (int i = 0; i < catInfos.Count; i++) { CategoryFilterButton categoryFilterButton2 = this.CreateButton(); categoryFilterButton2.Init(catInfos[i].id, catInfos[i].name); this.categories.Add(categoryFilterButton2); } int num2 = Mathf.Min(this.maxButtonsCount, this.categories.Count); if (num2 < this.categories.Count) { num += this.buttonOffset / 2; } int num3 = this.completeFilterButton.PrefferedTextWidth(); for (int j = 0; j < this.categories.Count; j++) { int num4 = this.categories[j].PrefferedTextWidth(); if (num4 > num3) { num3 = num4; } } ((RectTransform)this.content).sizeDelta = new Vector2(((RectTransform)this.content).sizeDelta.x, (float)(this.buttonOffset * this.categories.Count)); ((RectTransform)this.content.parent).sizeDelta = new Vector2(((RectTransform)this.content.parent).sizeDelta.x, (float)(this.buttonOffset * num2 + num)); this.bgRt.sizeDelta += new Vector2((float)(num3 + 80), ((RectTransform)this.content.parent).sizeDelta.y); this.rootRt.gameObject.SetActive(false); this.rootRt.anchoredPosition = anchoredPosition; }
public bool SelectCategory(int catId) { if (this.ActiveCategory != null && this.ActiveCategory.CategoryId == catId) { return(false); } for (int i = 0; i < this.categories.Count; i++) { if (this.categories[i].CategoryId == catId) { this.categories[i].Select(); this.ActiveCategory = this.categories[i]; } else { this.categories[i].Deselect(); } } return(true); }
public void Add(CategoryFilterButton btn) { int num = btn.PrefferedWidth(); int num2 = this.viewConfig.spacing + num; if (this.count > 0) { this.nexItemPos += new Vector2((float)this.viewConfig.spacing, 0f); } btn.transform.SetParent(base.transform); btn.transform.localScale = Vector3.one; RectTransform rectTransform = (RectTransform)btn.transform; rectTransform.anchoredPosition = this.nexItemPos; rectTransform.sizeDelta = new Vector2((float)num, rectTransform.sizeDelta.y); this.positions.Add(rectTransform.anchoredPosition); this.nexItemPos += new Vector2((float)num, 0f); this.rt.sizeDelta += new Vector2((float)num2, this.rt.sizeDelta.y); this.count++; }
public void Compose(List <CategoryInfo> catInfos, bool filterCompleted) { int num = this.safeLayoutOffset + (int)this.openPosition.y; string textByKey = LocalizationService.Instance.GetTextByKey("filter_hideColored"); string textByKey2 = LocalizationService.Instance.GetTextByKey("filter_showAllCategories"); this.completeFilterButton.Init(-1, textByKey); if (filterCompleted) { this.completeFilterButton.Select(); } else { this.completeFilterButton.Deselect(); } CategoryFilterButton categoryFilterButton = this.CreateButton(); categoryFilterButton.Init(ContentFilterNavBar.ShowAllCategoryId, textByKey2); this.categories.Add(categoryFilterButton); for (int i = 0; i < catInfos.Count; i++) { CategoryFilterButton categoryFilterButton2 = this.CreateButton(); categoryFilterButton2.Init(catInfos[i].id, catInfos[i].name); this.categories.Add(categoryFilterButton2); } int num2 = Mathf.Min(this.maxButtonsCount, this.categories.Count); int num3 = 0; if (num2 < this.categories.Count) { num3 += this.buttonOffset / 2; } ((RectTransform)this.content).sizeDelta = new Vector2(((RectTransform)this.content).sizeDelta.x, (float)(this.buttonOffset * this.categories.Count)); ((RectTransform)this.content.parent).sizeDelta = new Vector2(((RectTransform)this.content.parent).sizeDelta.x, (float)(this.buttonOffset * num2 + num3)); this.openPosition = new Vector2(0f, (float)(num + this.buttonOffset * num2 + num3)); }