| | 1 | | using System; |
| | 2 | | using TMPro; |
| | 3 | | using UIComponents.Scripts.Components; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Backpack |
| | 8 | | { |
| | 9 | | public class NftSubCategoryFilterComponentView : BaseComponentView<NftSubCategoryFilterModel> |
| | 10 | | { |
| | 11 | | [SerializeField] internal Button navigateButton; |
| | 12 | | [SerializeField] internal Button exitButton; |
| | 13 | | [SerializeField] internal TMP_Text categoryName; |
| | 14 | | [SerializeField] internal Image icon; |
| | 15 | | [SerializeField] internal Image backgroundImage; |
| | 16 | | [SerializeField] internal Color selectedBackgroundColor; |
| | 17 | | [SerializeField] internal Color selectedFontColor; |
| | 18 | | [SerializeField] internal Color unselectedBackgroundColor; |
| | 19 | | [SerializeField] internal Color unselectedFontColor; |
| | 20 | | [SerializeField] internal Color selectedIconColor; |
| | 21 | | [SerializeField] internal Color unselectedIconColor; |
| | 22 | |
|
| | 23 | | public event Action<NftSubCategoryFilterModel> OnNavigate; |
| | 24 | | public event Action<NftSubCategoryFilterModel> OnExit; |
| | 25 | |
|
| 3 | 26 | | public NftSubCategoryFilterModel Model => model; |
| | 27 | |
|
| | 28 | | public override void Awake() |
| | 29 | | { |
| 48 | 30 | | base.Awake(); |
| | 31 | |
|
| 48 | 32 | | navigateButton.onClick.AddListener(() => OnNavigate?.Invoke(model)); |
| 48 | 33 | | exitButton.onClick.AddListener(() => OnExit?.Invoke(model)); |
| 48 | 34 | | } |
| | 35 | |
|
| | 36 | | public override void RefreshControl() |
| | 37 | | { |
| 12 | 38 | | categoryName.text = model.Name; |
| | 39 | |
|
| 12 | 40 | | if (model.ShowResultCount) |
| 5 | 41 | | categoryName.text += $" ({model.ResultCount})"; |
| | 42 | |
|
| 12 | 43 | | exitButton.gameObject.SetActive(model.ShowRemoveButton); |
| | 44 | |
|
| 12 | 45 | | icon.sprite = model.Icon; |
| 12 | 46 | | icon.gameObject.SetActive(model.Icon != null); |
| | 47 | |
|
| 12 | 48 | | backgroundImage.color = model.IsSelected ? selectedBackgroundColor : unselectedBackgroundColor; |
| 12 | 49 | | categoryName.color = model.IsSelected ? selectedFontColor : unselectedFontColor; |
| 12 | 50 | | icon.color = model.IsSelected ? selectedIconColor : unselectedIconColor; |
| 12 | 51 | | } |
| | 52 | | } |
| | 53 | | } |