| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.EventSystems; |
| | 5 | | using UnityEngine.UI; |
| | 6 | | using TMPro; |
| | 7 | |
|
| | 8 | | public class NFTIconComponentView : BaseComponentView, INFTIconComponentView, IComponentModelConfig<NFTIconComponentMode |
| | 9 | | { |
| | 10 | |
|
| | 11 | | [SerializeField] internal ButtonComponentView marketplaceButton; |
| | 12 | | [SerializeField] internal TMP_Text nftName; |
| | 13 | | [SerializeField] internal TMP_Text nftNameMarketPlace; |
| | 14 | | [SerializeField] internal GameObject marketplaceSection; |
| | 15 | | [SerializeField] internal ImageComponentView nftImage; |
| | 16 | | [SerializeField] internal ImageComponentView typeImage; |
| | 17 | | [SerializeField] internal Image backgroundImage; |
| | 18 | | [SerializeField] internal NFTTypeIconsAndColors nftTypesIcons; |
| | 19 | |
|
| | 20 | | [SerializeField] internal NFTIconComponentModel model; |
| | 21 | |
|
| 0 | 22 | | public Button.ButtonClickedEvent onMarketplaceButtonClick => marketplaceButton?.onClick; |
| | 23 | |
|
| | 24 | | public void Configure(NFTIconComponentModel newModel) |
| | 25 | | { |
| 0 | 26 | | if (model == newModel) |
| 0 | 27 | | return; |
| | 28 | |
|
| 0 | 29 | | model = newModel; |
| 0 | 30 | | RefreshControl(); |
| 0 | 31 | | } |
| | 32 | |
|
| | 33 | | public override void RefreshControl() |
| | 34 | | { |
| 0 | 35 | | if (model == null) |
| 0 | 36 | | return; |
| | 37 | |
|
| 0 | 38 | | SetName(model.name); |
| 0 | 39 | | SetMarketplaceURI(model.marketplaceURI); |
| 0 | 40 | | SetImageURI(model.imageURI); |
| 0 | 41 | | SetType(model.type); |
| 0 | 42 | | SetRarity(model.rarity); |
| 0 | 43 | | } |
| | 44 | |
|
| | 45 | | public void SetName(string name) |
| | 46 | | { |
| 1 | 47 | | model.name = name; |
| | 48 | |
|
| 1 | 49 | | if (nftName != null) |
| 1 | 50 | | nftName.text = name; |
| | 51 | |
|
| 1 | 52 | | if(nftNameMarketPlace != null) |
| 1 | 53 | | nftNameMarketPlace.text = name; |
| 1 | 54 | | } |
| | 55 | |
|
| | 56 | | public void SetMarketplaceURI(string marketplaceURI) |
| | 57 | | { |
| 1 | 58 | | model.marketplaceURI = marketplaceURI; |
| 1 | 59 | | } |
| | 60 | |
|
| | 61 | | public void SetImageURI(string imageURI) |
| | 62 | | { |
| 0 | 63 | | model.imageURI = imageURI; |
| | 64 | |
|
| 0 | 65 | | nftImage.SetImage(imageURI); |
| 0 | 66 | | } |
| | 67 | |
|
| | 68 | | public void SetType(string type) |
| | 69 | | { |
| 0 | 70 | | model.type = type; |
| | 71 | |
|
| 0 | 72 | | typeImage.SetImage(nftTypesIcons.GetTypeImage(type)); |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | public void SetRarity(string rarity) |
| | 76 | | { |
| 0 | 77 | | model.rarity = rarity; |
| | 78 | |
|
| 0 | 79 | | backgroundImage.color = nftTypesIcons.GetColor(rarity); |
| 0 | 80 | | } |
| | 81 | |
|
| | 82 | | public override void OnFocus() |
| | 83 | | { |
| 1 | 84 | | base.OnFocus(); |
| | 85 | |
|
| 1 | 86 | | marketplaceSection.SetActive(true); |
| 1 | 87 | | } |
| | 88 | |
|
| | 89 | | public override void OnLoseFocus() |
| | 90 | | { |
| 5 | 91 | | base.OnLoseFocus(); |
| | 92 | |
|
| 5 | 93 | | marketplaceSection.SetActive(false); |
| 5 | 94 | | } |
| | 95 | |
|
| | 96 | | } |