| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public class NftPageView : BaseComponentView |
| | 5 | | { |
| | 6 | |
|
| | 7 | | public event Action<string, string> OnClickBuyNft; |
| | 8 | | public event Action OnFocusAnyNtf; |
| | 9 | |
|
| | 10 | | [SerializeField] private NFTIconComponentView[] nftElements; |
| | 11 | |
|
| 0 | 12 | | public bool IsNftInfoActived { get; set; } = false; |
| | 13 | |
|
| | 14 | | public void SetPageElementsContent(NFTIconComponentModel[] nftModels) |
| | 15 | | { |
| 0 | 16 | | for (int i = 0; i < nftModels.Length; i++) |
| | 17 | | { |
| 0 | 18 | | if (nftModels[i] != null) |
| | 19 | | { |
| 0 | 20 | | nftElements[i].gameObject.SetActive(true); |
| 0 | 21 | | nftElements[i].Configure(nftModels[i]); |
| 0 | 22 | | RegisterNftElementActions(nftElements[i], i); |
| | 23 | | } |
| | 24 | | else |
| | 25 | | { |
| 0 | 26 | | nftElements[i].gameObject.SetActive(false); |
| | 27 | | } |
| | 28 | | } |
| 0 | 29 | | } |
| | 30 | |
|
| | 31 | | public void ConfigureNFTItemInfo(NFTItemInfo nftItemInfoModal, WearableItem[] wearableItems, bool showCategoryInfo) |
| | 32 | | { |
| 0 | 33 | | for (int i = 0; i < nftElements.Length; i++) |
| | 34 | | { |
| 0 | 35 | | if (wearableItems[i] != null) |
| 0 | 36 | | nftElements[i].ConfigureNFTItemInfo(nftItemInfoModal, wearableItems[i], showCategoryInfo); |
| | 37 | | } |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public void CloseAllNFTItemInfos() |
| | 41 | | { |
| 0 | 42 | | for (int i = 0; i < nftElements.Length; i++) |
| 0 | 43 | | nftElements[i].SetNFTItemInfoActive(false); |
| 0 | 44 | | } |
| | 45 | |
|
| | 46 | | private void RegisterNftElementActions(NFTIconComponentView nftElement, int idIndex) |
| | 47 | | { |
| 0 | 48 | | nftElement.onMarketplaceButtonClick.RemoveAllListeners(); |
| 0 | 49 | | nftElement.onDetailInfoButtonClick.RemoveAllListeners(); |
| 0 | 50 | | nftElement.onMarketplaceButtonClick.AddListener(() => ClickOnBuyWearable(nftElement.model.nftInfo)); |
| 0 | 51 | | nftElement.onDetailInfoButtonClick.AddListener(() => ClickOnDetailInfo(idIndex, showInLeftSide: idIndex == 3)); |
| 0 | 52 | | nftElement.onFocused -= FocusNftItem; |
| 0 | 53 | | nftElement.onFocused += FocusNftItem; |
| 0 | 54 | | } |
| | 55 | |
|
| | 56 | | private void ClickOnBuyWearable(NftInfo idsAndCategory) |
| | 57 | | { |
| 0 | 58 | | OnClickBuyNft?.Invoke(idsAndCategory.Id, idsAndCategory.Category); |
| 0 | 59 | | } |
| | 60 | |
|
| | 61 | | private void ClickOnDetailInfo(int index, bool showInLeftSide) |
| | 62 | | { |
| 0 | 63 | | if (IsNftInfoActived) |
| 0 | 64 | | nftElements[index].SetNFTItemInfoActive(true, showInLeftSide); |
| 0 | 65 | | } |
| | 66 | |
|
| | 67 | | private void FocusNftItem(bool isFocused) |
| | 68 | | { |
| 0 | 69 | | if (!isFocused) |
| 0 | 70 | | return; |
| | 71 | |
|
| 0 | 72 | | OnFocusAnyNtf?.Invoke(); |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | public override void RefreshControl() |
| | 76 | | { |
| 0 | 77 | | } |
| | 78 | | } |