< Summary

Class:DCL.Social.Passports.PassportNavigationComponentView
Assembly:PassportHUD
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Passport/Passport/PassportNavigation/PassportNavigationComponentView.cs
Covered lines:0
Uncovered lines:343
Coverable lines:343
Total lines:773
Line coverage:0% (0 of 343)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:50
Method coverage:0% (0 of 50)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
PassportNavigationComponentView()0%2100%
PassportNavigationComponentView()0%2100%
Start()0%2100%
OpenViewAllSection(...)0%6200%
CloseAllSections()0%2100%
EnableAboutSection(...)0%2100%
EnableCollectiblesSection(...)0%6200%
InitializeView()0%2100%
SetGuestUser(...)0%2100%
SetName(...)0%2100%
SetOwnUserTexts(...)0%12300%
SetDescription(...)0%6200%
Get(...)0%12300%
SetAdditionalInfo(...)0%12300%
SetLinks(...)0%12300%
AddCoordinateLinks(...)0%6200%
OnDescriptionClicked(...)0%30500%
ClickedLink(...)0%6200%
SetEquippedWearables(...)0%20400%
SetCollectibleWearables(...)0%6200%
SetCollectibleEmotes(...)0%6200%
SetCollectibleNames(...)0%6200%
SetCollectibleLands(...)0%6200%
SetHasBlockedOwnUser(...)0%2100%
OpenCollectiblesTab()0%2100%
SetInitialPage()0%2100%
SetViewAllButtonActive(...)0%30500%
CloseAllNFTItemInfos()0%20400%
ClickOnBuyWearable(...)0%6200%
FocusEquippedNftItem(...)0%6200%
FocusAnyNtfItem()0%2100%
ReleaseAllNftIconsPoolObjects()0%2100%
ReleaseNftIconsPoolObjects(...)0%6200%
ReleaseAllNftPagesPoolObjects()0%2100%
GetNftIconEntryPool()0%2100%
GetLinkEntryPool()0%6200%
GetAdditionalInfoFieldEntryPool()0%6200%
GetNftPagesEntryPool(...)0%2100%
GetNftEntryPool(...)0%6200%
RefreshControl()0%2100%
SetCollectibleWearablesLoadingActive(...)0%2100%
SetCollectibleEmotesLoadingActive(...)0%2100%
SetCollectibleNamesLoadingActive(...)0%2100%
SetCollectibleLandsLoadingActive(...)0%2100%
SetCollectibleSectionLoadingActive(...)0%6200%
CreateNamePageView(...)0%2100%
CreateNamePageElements(...)0%20400%
CreateWearablePageView(...)0%20400%
CreateEmotePageView(...)0%20400%
CreateLandPageView(...)0%30500%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/Passport/Passport/PassportNavigation/PassportNavigationComponentView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using DCLServices.Lambdas.LandsService;
 3using DCLServices.Lambdas.NamesService;
 4using System;
 5using System.Collections.Generic;
 6using System.Linq;
 7using TMPro;
 8using UIComponents.Scripts.Utils;
 9using UnityEngine;
 10using UnityEngine.EventSystems;
 11using UnityEngine.Networking;
 12using UnityEngine.UI;
 13
 14namespace DCL.Social.Passports
 15{
 16    [Serializable]
 17    internal class AdditionalInfoIconMapping
 18    {
 19        public AdditionalInfoField name;
 20        public Sprite icon;
 21    }
 22
 23    public class PassportNavigationComponentView : BaseComponentView, IPassportNavigationComponentView, IAdditionalInfoF
 24    {
 25        private const string GUEST_TEXT = "is a guest";
 26        private const string BLOCKED_TEXT = "blocked you!";
 27        private const string OWN_PLAYER = "\n         You don't ";
 28        private const string OTHER_PLAYERS = "\n         This person doesn't ";
 29        private const string NO_WEARABLES_TEXT = "own any Wearables yet.";
 30        private const string NO_EMOTES_TEXT = "own any Emotes yet.";
 31        private const string NO_NAMES_TEXT = "own any NAMEs yet.";
 32        private const string NO_LANDS_TEXT = "own any LANDs yet.";
 33        private const string NAME_TYPE = "name";
 34        private const string EMOTE_TYPE = "emote";
 35        private const string LAND_RARITY = "land";
 36        private const int PAGE_SIZE = 4;
 37
 38        [SerializeField] private GameObject aboutPanel;
 39        [SerializeField] private RectTransform aboutContainerTransform;
 40        [SerializeField] private GameObject wearablesPanel;
 41        [SerializeField] private Toggle aboutToggle;
 42        [SerializeField] private Toggle collectiblesToggle;
 43        [SerializeField] private GameObject guestPanel;
 44        [SerializeField] private GameObject normalPanel;
 45        [SerializeField] private GameObject hasBlockedPanel;
 46        [SerializeField] private Transform equippedWearablesContainer;
 47        [SerializeField] private TextMeshProUGUI usernameText;
 48        [SerializeField] private TextMeshProUGUI blockedUsernameText;
 49        [SerializeField] private TextMeshProUGUI descriptionText;
 50        [SerializeField] private GameObject emptyDescriptionGO;
 51        [SerializeField] private CarouselComponentView nftWearablesCarousel;
 52        [SerializeField] private TMP_Text emptyWearablesText;
 53        [SerializeField] private GameObject nftWearablesLoadingSpinner;
 54        [SerializeField] private CarouselComponentView nftEmotesCarousel;
 55        [SerializeField] private TMP_Text emptyEmotesText;
 56        [SerializeField] private GameObject nftEmotesLoadingSpinner;
 57        [SerializeField] private CarouselComponentView nftNamesCarousel;
 58        [SerializeField] private TMP_Text emptyNamesText;
 59        [SerializeField] private GameObject nftNamesLoadingSpinner;
 60        [SerializeField] private CarouselComponentView nftLandsCarousel;
 61        [SerializeField] private TMP_Text emptyLandsText;
 62        [SerializeField] private GameObject nftLandsLoadingSpinner;
 63        [SerializeField] private Transform nftWearablesCarouselContent;
 64        [SerializeField] private Transform nftEmotesCarouselContent;
 65        [SerializeField] private Transform nftNamesCarouselContent;
 66        [SerializeField] private Transform nftLandsCarouselContent;
 67        [SerializeField] private GameObject wearableUIReferenceObject;
 68        [SerializeField] private GameObject nftPageUIReferenceObject;
 69        [SerializeField] private GameObject additionalInfoContainer;
 70        [SerializeField] private GameObject additionalInfoPrefabReference;
 71        [SerializeField] internal List<AdditionalInfoIconMapping> additionalInfoIconsMapping;
 72        [SerializeField] private GameObject linksContainer;
 73        [SerializeField] private GameObject linksTitle;
 74        [SerializeField] private GameObject linkPrefabReference;
 75        [SerializeField] private GameObject aboutToggleOn;
 76        [SerializeField] private GameObject aboutToggleOff;
 77        [SerializeField] private GameObject collectiblesToggleOn;
 78        [SerializeField] private GameObject collectiblesToggleOff;
 79        [SerializeField] private TMP_Text aboutText;
 80        [SerializeField] private TMP_Text collectiblesText;
 81        [SerializeField] private OpenUrlView openUrlView;
 82        [SerializeField] internal NFTItemInfo nftItemInfo;
 83        [SerializeField] internal ScrollRect nftWearablesScrollRect;
 84        [SerializeField] internal ScrollRect nftEmotesScrollRect;
 85        [SerializeField] internal ScrollRect nftNamesScrollRect;
 86        [SerializeField] internal ScrollRect nftLandsScrollRect;
 87        [SerializeField] internal ScrollRect collectiblesMainScrollRect;
 88
 89        [SerializeField] private ButtonComponentView viewAllWearables;
 90        [SerializeField] private ButtonComponentView viewAllEmotes;
 91        [SerializeField] private ButtonComponentView viewAllNAMEs;
 92        [SerializeField] private ButtonComponentView viewAllLANDs;
 93        [SerializeField] private Button copyDescriptionButton;
 94        [SerializeField] private ShowHideAnimator copyDescriptionToast;
 95
 096        private static readonly Vector3 NFT_ICON_SCALE = new Vector3(0.75f, 0.75f, 0.75f);
 97        public event Action<string, string> OnClickBuyNft;
 98        public event Action OnClickedLink;
 99        public event Action OnClickCollectibles;
 100        public event Action<PassportSection> OnClickedViewAll;
 101        public event Action<ParcelCoordinates> OnClickDescriptionCoordinates;
 102        public event Action OnCopyDescription;
 103
 104        private const string NFT_ICON_POOL_NAME_PREFIX = "NFTIconsEntriesPool_Passport_";
 105        private const string NFT_PAGES_POOL_NAME_PREFIX = "NFTPagesEntriesPool_Passport_";
 106        private const int MAX_NFT_ICON_ENTRIES = 20;
 107        private const int MAX_NFT_PAGES_ENTRIES = 20;
 108        private const string COORD_LINK_ID = "coord://";
 109
 0110        private List<PoolableObject> nftIconPoolableQueue = new ();
 0111        private List<PoolableObject> nftWearablesPagesPoolableQueue = new ();
 0112        private List<PoolableObject> nftEmotesPagesPoolableQueue = new ();
 0113        private List<PoolableObject> nftNamesPagesPoolableQueue = new ();
 0114        private List<PoolableObject> nftLandsPagesPoolableQueue = new ();
 0115        private List<PoolableObject> linksPoolObjects = new ();
 0116        private List<PoolableObject> additionalInfoFieldsPoolObjects = new ();
 117
 118        private Pool nftIconsEntryPool;
 119        private Pool nftWearablesPagesEntryPool;
 120        private Pool nftEmotesPagesEntryPool;
 121        private Pool nftNamesPagesEntryPool;
 122        private Pool nftLandsPagesEntryPool;
 123        private Pool linksEntryPool;
 124        private Pool additionalInfoFieldsEntryPool;
 0125        private readonly List<NFTIconComponentView> equippedNftWearableViews = new ();
 0126        private readonly List<NftPageView> ownedNftWearablePageViews = new ();
 0127        private readonly List<NftPageView> ownedNftEmotePageViews = new ();
 128
 129        public void Start()
 130        {
 0131            collectiblesToggle.isOn = false;
 0132            aboutToggle.isOn = true;
 0133            aboutToggle.onValueChanged.AddListener(EnableAboutSection);
 0134            collectiblesToggle.onValueChanged.AddListener(EnableCollectiblesSection);
 0135            nftWearablesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos());
 0136            nftEmotesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos());
 0137            nftNamesScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos());
 0138            nftLandsScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos());
 0139            collectiblesMainScrollRect.onValueChanged.AddListener((pos) => CloseAllNFTItemInfos());
 140
 0141            viewAllWearables.onClick.AddListener(() => OpenViewAllSection(PassportSection.Wearables));
 0142            viewAllEmotes.onClick.AddListener(() => OpenViewAllSection(PassportSection.Emotes));
 0143            viewAllNAMEs.onClick.AddListener(() => OpenViewAllSection(PassportSection.Names));
 0144            viewAllLANDs.onClick.AddListener(() => OpenViewAllSection(PassportSection.Lands));
 0145            copyDescriptionButton.onClick.AddListener(() =>
 146            {
 0147                OnCopyDescription?.Invoke();
 0148                copyDescriptionToast.gameObject.SetActive(true);
 0149                copyDescriptionToast.ShowDelayHide(3);
 0150            });
 151
 0152            descriptionText.SubscribeToClickEvents(OnDescriptionClicked);
 0153            nftWearablesPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Wearables");
 0154            nftEmotesPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Emotes");
 0155            nftNamesPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Names");
 0156            nftLandsPagesEntryPool = GetNftPagesEntryPool(NFT_PAGES_POOL_NAME_PREFIX + "Lands");
 0157            nftIconsEntryPool = GetNftIconEntryPool();
 0158            linksEntryPool = GetLinkEntryPool();
 0159            additionalInfoFieldsEntryPool = GetAdditionalInfoFieldEntryPool();
 0160        }
 161
 162        private void OpenViewAllSection(PassportSection section)
 163        {
 0164            CloseAllNFTItemInfos();
 0165            OnClickedViewAll?.Invoke(section);
 0166        }
 167
 168        public void CloseAllSections()
 169        {
 0170            aboutPanel.SetActive(false);
 0171            wearablesPanel.SetActive(false);
 0172        }
 173
 174        private void EnableAboutSection(bool isActive)
 175        {
 0176            aboutPanel.SetActive(isActive);
 0177            aboutText.color = Color.white;
 0178            collectiblesText.color = Color.black;
 0179            aboutToggleOn.SetActive(true);
 0180            aboutToggleOff.SetActive(false);
 0181            collectiblesToggleOn.SetActive(false);
 0182            collectiblesToggleOff.SetActive(true);
 0183            CloseAllNFTItemInfos();
 0184        }
 185
 186        private void EnableCollectiblesSection(bool isActive)
 187        {
 0188            OnClickCollectibles?.Invoke();
 0189            wearablesPanel.SetActive(isActive);
 0190            aboutText.color = Color.black;
 0191            collectiblesText.color = Color.white;
 0192            aboutToggleOn.SetActive(false);
 0193            aboutToggleOff.SetActive(true);
 0194            collectiblesToggleOn.SetActive(true);
 0195            collectiblesToggleOff.SetActive(false);
 0196            nftWearablesCarousel.ResetManualCarousel();
 0197            nftEmotesCarousel.ResetManualCarousel();
 0198            nftNamesCarousel.ResetManualCarousel();
 0199            nftLandsCarousel.ResetManualCarousel();
 0200            CloseAllNFTItemInfos();
 0201        }
 202
 203        public void InitializeView()
 204        {
 0205            ReleaseAllNftPagesPoolObjects();
 0206            ReleaseAllNftIconsPoolObjects();
 0207            SetInitialPage();
 0208        }
 209
 210        public void SetGuestUser(bool isGuest)
 211        {
 0212            guestPanel.SetActive(isGuest);
 0213            normalPanel.SetActive(!isGuest);
 0214            hasBlockedPanel.SetActive(false);
 0215        }
 216
 217        public void SetName(string username)
 218        {
 0219            usernameText.text = $"{username} {GUEST_TEXT}";
 0220            blockedUsernameText.text = $"{username} {BLOCKED_TEXT}";
 0221        }
 222
 223        public void SetOwnUserTexts(bool isOwnUser)
 224        {
 0225            string prefix = isOwnUser ? OWN_PLAYER : OTHER_PLAYERS;
 0226            emptyWearablesText.text = $"{prefix}{NO_WEARABLES_TEXT}";
 0227            emptyEmotesText.text = $"{prefix}{NO_EMOTES_TEXT}";
 0228            emptyNamesText.text = $"{prefix}{NO_NAMES_TEXT}";
 0229            emptyLandsText.text = $"{prefix}{NO_LANDS_TEXT}";
 0230        }
 231
 232        public void SetDescription(string description)
 233        {
 0234            if (string.IsNullOrEmpty(description))
 235            {
 0236                emptyDescriptionGO.SetActive(true);
 0237                descriptionText.gameObject.SetActive(false);
 238            }
 239            else
 240            {
 0241                emptyDescriptionGO.SetActive(false);
 0242                descriptionText.gameObject.SetActive(true);
 0243                description = AddCoordinateLinks(description);
 0244                descriptionText.text = description;
 245            }
 0246        }
 247
 248        public Sprite Get(AdditionalInfoField field)
 249        {
 0250            foreach (AdditionalInfoIconMapping iconMapping in additionalInfoIconsMapping)
 0251                if (iconMapping.name == field)
 0252                    return iconMapping.icon;
 253
 0254            return null;
 0255        }
 256
 257        public void SetAdditionalInfo(List<(Sprite logo, string title, string value)> additionalFields)
 258        {
 0259            additionalInfoContainer.SetActive(additionalFields.Count > 0);
 260
 0261            foreach (PoolableObject poolObj in additionalInfoFieldsPoolObjects)
 0262                poolObj.Release();
 263
 0264            additionalInfoFieldsPoolObjects.Clear();
 265
 0266            foreach (var additionalField in additionalFields)
 267            {
 0268                PoolableObject poolObj = additionalInfoFieldsEntryPool.Get();
 0269                additionalInfoFieldsPoolObjects.Add(poolObj);
 0270                AdditionalInfoEntryView newAdditionalField = poolObj.gameObject.GetComponent<AdditionalInfoEntryView>();
 0271                newAdditionalField.transform.SetParent(additionalInfoContainer.transform, false);
 0272                newAdditionalField.SetInfo(additionalField.logo, additionalField.title, additionalField.value);
 273            }
 0274        }
 275
 276        public void SetLinks(List<UserProfileModel.Link> links)
 277        {
 0278            linksTitle.SetActive(links.Count > 0);
 0279            linksContainer.SetActive(links.Count > 0);
 280
 0281            foreach (PoolableObject poolObj in linksPoolObjects)
 0282                poolObj.Release();
 283
 0284            linksPoolObjects.Clear();
 285
 0286            foreach (var link in links)
 287            {
 0288                PoolableObject poolObj = linksEntryPool.Get();
 0289                linksPoolObjects.Add(poolObj);
 0290                PassportLinkView newLink = poolObj.gameObject.GetComponent<PassportLinkView>();
 0291                newLink.transform.SetParent(linksContainer.transform, false);
 0292                newLink.OnClickLink -= ClickedLink;
 0293                newLink.SetLinkTitle(link.title);
 0294                newLink.SetLink(link.url);
 0295                newLink.OnClickLink += ClickedLink;
 296            }
 0297        }
 298
 299        private string AddCoordinateLinks(string description)
 300        {
 0301            return CoordinateUtils.ReplaceTextCoordinates(description, (text, coordinates) =>
 0302                $"<link=coord://{text}><color=#4886E3><u>{text}</u></color></link>");
 303        }
 304
 305        private void OnDescriptionClicked(PointerEventData clickData)
 306        {
 0307            if (clickData.button != PointerEventData.InputButton.Left) return;
 308
 0309            int linkIndex = TMP_TextUtilities.FindIntersectingLink(descriptionText, clickData.position, descriptionText.
 0310            if (linkIndex == -1) return;
 311
 0312            string link = descriptionText.textInfo.linkInfo[linkIndex].GetLinkID();
 0313            if (!link.StartsWith(COORD_LINK_ID)) return;
 314
 0315            string coordText = link[COORD_LINK_ID.Length..];
 0316            ParcelCoordinates coordinates = CoordinateUtils.ParseCoordinatesString(coordText);
 0317            OnClickDescriptionCoordinates?.Invoke(coordinates);
 0318        }
 319
 320        private void ClickedLink(string obj)
 321        {
 0322            openUrlView.SetUrlInfo(UnityWebRequest.UnEscapeURL(obj), obj);
 0323            openUrlView.SetVisibility(true);
 0324            OnClickedLink?.Invoke();
 0325        }
 326
 327        public void SetEquippedWearables(WearableItem[] wearables, string bodyShapeId)
 328        {
 0329            HashSet<string> hidesList = WearableItem.ComposeHiddenCategories(bodyShapeId, wearables.ToList());
 330
 0331            equippedNftWearableViews.Clear();
 332
 0333            foreach (var wearable in wearables)
 334            {
 0335                if (wearable == null)
 336                    continue;
 337
 0338                if (!hidesList.Contains(wearable.data.category))
 339                {
 0340                    PoolableObject poolableObject = nftIconsEntryPool.Get();
 0341                    nftIconPoolableQueue.Add(poolableObject);
 0342                    poolableObject.gameObject.transform.SetParent(equippedWearablesContainer, false);
 0343                    poolableObject.gameObject.transform.localScale = NFT_ICON_SCALE;
 0344                    NFTIconComponentView nftIconComponentView = poolableObject.gameObject.GetComponent<NFTIconComponentV
 0345                    nftIconComponentView.onMarketplaceButtonClick.RemoveAllListeners();
 0346                    nftIconComponentView.onDetailInfoButtonClick.RemoveAllListeners();
 0347                    nftIconComponentView.onFocused -= FocusEquippedNftItem;
 0348                    nftIconComponentView.onMarketplaceButtonClick.AddListener(() => ClickOnBuyWearable(wearable.id, wear
 0349                    nftIconComponentView.onDetailInfoButtonClick.AddListener(() => nftIconComponentView.SetNFTItemInfoAc
 0350                    nftIconComponentView.onFocused += FocusEquippedNftItem;
 351
 0352                    NFTIconComponentModel nftModel = new NFTIconComponentModel()
 353                    {
 354                        showMarketplaceButton = wearable.IsCollectible(),
 355                        showType = wearable.IsCollectible(),
 356                        type = wearable.data.category,
 357                        marketplaceURI = "",
 358                        name = wearable.GetName(),
 359                        rarity = wearable.rarity,
 360                        imageURI = wearable.ComposeThumbnailUrl()
 361                    };
 362
 0363                    nftIconComponentView.Configure(nftModel);
 0364                    nftIconComponentView.ConfigureNFTItemInfo(nftItemInfo, wearable, true);
 0365                    equippedNftWearableViews.Add(nftIconComponentView);
 366                }
 367            }
 368
 0369            Utils.ForceRebuildLayoutImmediate(aboutContainerTransform);
 0370        }
 371
 372        public void SetCollectibleWearables(WearableItem[] wearables)
 373        {
 0374            nftWearablesCarousel.gameObject.SetActive(wearables.Length > 0);
 0375            nftWearablesCarousel.ExtractItems();
 0376            nftWearablesPagesEntryPool.ReleaseAll();
 0377            emptyWearablesText.gameObject.SetActive(wearables.Length <= 0);
 0378            ownedNftWearablePageViews.Clear();
 379
 0380            for (int i = 0; i < wearables.Length; i += PAGE_SIZE)
 381            {
 0382                NftPageView nftPageView = CreateWearablePageView(wearables, i);
 0383                ownedNftWearablePageViews.Add(nftPageView);
 0384                nftWearablesCarousel.AddItem(nftPageView);
 385            }
 386
 0387            nftWearablesCarousel.SetManualControlsActive();
 0388            nftWearablesCarousel.GenerateDotsSelector();
 0389        }
 390
 391        public void SetCollectibleEmotes(WearableItem[] wearables)
 392        {
 0393            nftEmotesCarousel.gameObject.SetActive(wearables.Length > 0);
 0394            nftEmotesCarousel.ExtractItems();
 0395            nftEmotesPagesEntryPool.ReleaseAll();
 0396            emptyEmotesText.gameObject.SetActive(wearables.Length <= 0);
 397
 0398            for (int i = 0; i < wearables.Length; i += PAGE_SIZE)
 399            {
 0400                NftPageView nftPageView = CreateEmotePageView(wearables, i);
 0401                ownedNftEmotePageViews.Add(nftPageView);
 0402                nftEmotesCarousel.AddItem(nftPageView);
 403            }
 404
 0405            nftEmotesCarousel.SetManualControlsActive();
 0406            nftEmotesCarousel.GenerateDotsSelector();
 0407        }
 408
 409        public void SetCollectibleNames(NamesResponse.NameEntry[] names)
 410        {
 0411            nftNamesCarousel.gameObject.SetActive(names.Length > 0);
 0412            nftNamesCarousel.ExtractItems();
 0413            nftNamesPagesEntryPool.ReleaseAll();
 0414            emptyNamesText.gameObject.SetActive(names.Length <= 0);
 415
 0416            for (int i = 0; i < names.Length; i += PAGE_SIZE)
 417            {
 0418                PoolableObject nftPagePoolElement = nftNamesPagesEntryPool.Get();
 0419                nftNamesPagesPoolableQueue.Add(nftPagePoolElement);
 0420                nftPagePoolElement.gameObject.transform.SetParent(nftNamesCarouselContent, false);
 0421                NftPageView nftPageView = CreateNamePageView(names, nftPagePoolElement, i);
 0422                nftNamesCarousel.AddItem(nftPageView);
 423            }
 424
 0425            nftNamesCarousel.SetManualControlsActive();
 0426            nftNamesCarousel.GenerateDotsSelector();
 0427        }
 428
 429        public void SetCollectibleLands(LandsResponse.LandEntry[] lands)
 430        {
 0431            nftLandsCarousel.gameObject.SetActive(lands.Length > 0);
 0432            nftLandsCarousel.ExtractItems();
 0433            nftLandsPagesEntryPool.ReleaseAll();
 0434            emptyLandsText.gameObject.SetActive(lands.Length <= 0);
 435
 0436            for (int i = 0; i < lands.Length; i += PAGE_SIZE)
 437            {
 0438                NftPageView nftPageView = CreateLandPageView(lands, i);
 0439                nftLandsCarousel.AddItem(nftPageView);
 440            }
 441
 0442            nftLandsCarousel.SetManualControlsActive();
 0443            nftLandsCarousel.GenerateDotsSelector();
 0444        }
 445
 446        public void SetHasBlockedOwnUser(bool isBlocked)
 447        {
 0448            hasBlockedPanel.SetActive(isBlocked);
 0449        }
 450
 451        public void OpenCollectiblesTab()
 452        {
 0453            wearablesPanel.SetActive(true);
 0454        }
 455
 456        public void SetInitialPage()
 457        {
 0458            aboutToggle.isOn = true;
 0459        }
 460
 461        public void SetViewAllButtonActive(PassportSection section, bool isActive)
 462        {
 463            switch (section)
 464            {
 465                case PassportSection.Wearables:
 0466                    viewAllWearables.gameObject.SetActive(isActive);
 0467                    break;
 468                case PassportSection.Emotes:
 0469                    viewAllEmotes.gameObject.SetActive(isActive);
 0470                    break;
 471                case PassportSection.Names:
 0472                    viewAllNAMEs.gameObject.SetActive(isActive);
 0473                    break;
 474                case PassportSection.Lands:
 0475                    viewAllLANDs.gameObject.SetActive(isActive);
 476                    break;
 477            }
 0478        }
 479
 480        public void CloseAllNFTItemInfos()
 481        {
 0482            for (int i = 0; i < equippedNftWearableViews.Count; i++)
 0483                equippedNftWearableViews[i].SetNFTItemInfoActive(false);
 484
 0485            for (int i = 0; i < ownedNftWearablePageViews.Count; i++)
 0486                ownedNftWearablePageViews[i].CloseAllNFTItemInfos();
 487
 0488            for (int i = 0; i < ownedNftEmotePageViews.Count; i++)
 0489                ownedNftEmotePageViews[i].CloseAllNFTItemInfos();
 0490        }
 491
 492        private void ClickOnBuyWearable(string wearableId, string wearableType)
 493        {
 0494            OnClickBuyNft?.Invoke(wearableId, wearableType);
 0495        }
 496
 497        private void FocusEquippedNftItem(bool isFocused)
 498        {
 0499            if (!isFocused)
 0500                return;
 501
 0502            FocusAnyNtfItem();
 0503        }
 504
 505        private void FocusAnyNtfItem() =>
 0506            CloseAllNFTItemInfos();
 507
 508        private void ReleaseAllNftIconsPoolObjects()
 509        {
 0510            ReleaseNftIconsPoolObjects(nftIconPoolableQueue);
 0511        }
 512
 513        private void ReleaseNftIconsPoolObjects(List<PoolableObject> nftIconsPoolableQueue)
 514        {
 0515            foreach (var poolObject in nftIconsPoolableQueue)
 0516                poolObject.Release();
 517
 0518            nftIconsPoolableQueue.Clear();
 0519        }
 520
 521        private void ReleaseAllNftPagesPoolObjects()
 522        {
 0523            nftWearablesPagesEntryPool.ReleaseAll();
 0524            nftEmotesPagesEntryPool.ReleaseAll();
 0525            nftNamesPagesEntryPool.ReleaseAll();
 0526            nftLandsPagesEntryPool.ReleaseAll();
 0527        }
 528
 529        private Pool GetNftIconEntryPool() =>
 0530            GetNftEntryPool(NFT_ICON_POOL_NAME_PREFIX + name + GetInstanceID(), wearableUIReferenceObject, MAX_NFT_ICON_
 531
 532        private Pool GetLinkEntryPool()
 533        {
 0534            object poolId = $"LinkEntries_Passport_{name}{GetInstanceID()}";
 0535            var pool = PoolManager.i.GetPool(poolId);
 0536            if (pool != null) return pool;
 537
 0538            pool = PoolManager.i.AddPool(
 539                poolId,
 540                Instantiate(linkPrefabReference),
 541                maxPrewarmCount: 5,
 542                isPersistent: true);
 543
 0544            return pool;
 545        }
 546
 547        private Pool GetAdditionalInfoFieldEntryPool()
 548        {
 0549            object poolId = $"AdditionalInfoEntries_Passport_{name}{GetInstanceID()}";
 0550            var pool = PoolManager.i.GetPool(poolId);
 0551            if (pool != null) return pool;
 552
 0553            pool = PoolManager.i.AddPool(
 554                poolId,
 555                Instantiate(additionalInfoPrefabReference),
 556                maxPrewarmCount: 5,
 557                isPersistent: true);
 558
 0559            return pool;
 560        }
 561
 562        private Pool GetNftPagesEntryPool(string poolId) =>
 0563            GetNftEntryPool(poolId, nftPageUIReferenceObject, MAX_NFT_PAGES_ENTRIES);
 564
 565        private static Pool GetNftEntryPool(string poolId, GameObject referenceObject, int maxPrewarmCount)
 566        {
 0567            var pool = PoolManager.i.GetPool(poolId);
 0568            if (pool != null) return pool;
 569
 0570            pool = PoolManager.i.AddPool(
 571                poolId,
 572                Instantiate(referenceObject).gameObject,
 573                maxPrewarmCount: maxPrewarmCount,
 574                isPersistent: true);
 575
 0576            pool.ForcePrewarm(forceActive: false);
 577
 0578            return pool;
 579        }
 580
 0581        public override void RefreshControl() { }
 582
 583        public void SetCollectibleWearablesLoadingActive(bool isActive) =>
 0584            SetCollectibleSectionLoadingActive(isActive, nftWearablesCarousel, emptyWearablesText.gameObject, nftWearabl
 585
 586        public void SetCollectibleEmotesLoadingActive(bool isActive) =>
 0587            SetCollectibleSectionLoadingActive(isActive, nftEmotesCarousel, emptyEmotesText.gameObject, nftEmotesLoading
 588
 589        public void SetCollectibleNamesLoadingActive(bool isActive) =>
 0590            SetCollectibleSectionLoadingActive(isActive, nftNamesCarousel, emptyNamesText.gameObject, nftNamesLoadingSpi
 591
 592        public void SetCollectibleLandsLoadingActive(bool isActive) =>
 0593            SetCollectibleSectionLoadingActive(isActive, nftLandsCarousel, emptyLandsText.gameObject, nftLandsLoadingSpi
 594
 595        private void SetCollectibleSectionLoadingActive(
 596            bool isActive,
 597            CarouselComponentView carousel,
 598            GameObject emptyText,
 599            GameObject loadingSpinner)
 600        {
 0601            if (isActive)
 602            {
 0603                carousel.gameObject.SetActive(false);
 0604                emptyText.SetActive(false);
 605            }
 606
 0607            loadingSpinner.SetActive(isActive);
 0608        }
 609
 610        private NftPageView CreateNamePageView(NamesResponse.NameEntry[] names, PoolableObject nftPagePoolElement, int i
 611        {
 0612            NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>();
 0613            nftPageView.OnClickBuyNft -= ClickOnBuyWearable;
 0614            nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem;
 0615            NFTIconComponentModel[] pageElements = CreateNamePageElements(names, i);
 0616            nftPageView.SetPageElementsContent(pageElements);
 0617            nftPageView.IsNftInfoActived = false;
 0618            nftPageView.OnClickBuyNft += ClickOnBuyWearable;
 0619            nftPageView.OnFocusAnyNtf += FocusAnyNtfItem;
 0620            return nftPageView;
 621        }
 622
 623        private static NFTIconComponentModel[] CreateNamePageElements(NamesResponse.NameEntry[] names, int i)
 624        {
 0625            NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE];
 626
 0627            for (var j = 0; j < PAGE_SIZE; j++)
 628            {
 0629                if (names.Length > i + j && names[i + j] != null)
 630                {
 0631                    pageElements[j] = new NFTIconComponentModel
 632                    {
 633                        showMarketplaceButton = true,
 634                        showType = true,
 635                        type = NAME_TYPE,
 636                        marketplaceURI = "",
 637                        name = names[i + j].Name,
 638                        rarity = NAME_TYPE,
 639                        imageURI = "",
 640                        nftInfo = names[i + j].GetNftInfo(),
 641                    };
 642                }
 0643                else { pageElements[j] = null; }
 644            }
 645
 0646            return pageElements;
 647        }
 648
 649        private NftPageView CreateWearablePageView(WearableItem[] wearables, int i)
 650        {
 0651            PoolableObject nftPagePoolElement = nftWearablesPagesEntryPool.Get();
 0652            nftWearablesPagesPoolableQueue.Add(nftPagePoolElement);
 0653            nftPagePoolElement.gameObject.transform.SetParent(nftWearablesCarouselContent, false);
 0654            NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>();
 0655            nftPageView.OnClickBuyNft -= ClickOnBuyWearable;
 0656            nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem;
 0657            NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE];
 0658            WearableItem[] wearableItemsForThisPage = new WearableItem[PAGE_SIZE];
 659
 0660            for (int j = 0; j < PAGE_SIZE; j++)
 661            {
 0662                if (wearables.Length > i + j && wearables[i + j] != null)
 663                {
 0664                    pageElements[j] = new ()
 665                    {
 666                        showMarketplaceButton = true,
 667                        showType = true,
 668                        type = wearables[i + j].data.category,
 669                        marketplaceURI = "",
 670                        name = wearables[i + j].GetName(),
 671                        rarity = wearables[i + j].rarity,
 672                        imageURI = wearables[i + j].ComposeThumbnailUrl(),
 673                        nftInfo = wearables[i + j].GetNftInfo(),
 674                    };
 675
 0676                    wearableItemsForThisPage[j] = wearables[i + j];
 677                }
 678                else
 679                {
 0680                    pageElements[j] = null;
 0681                    wearableItemsForThisPage[j] = null;
 682                }
 683            }
 684
 0685            nftPageView.SetPageElementsContent(pageElements);
 0686            nftPageView.IsNftInfoActived = true;
 0687            nftPageView.ConfigureNFTItemInfo(nftItemInfo, wearableItemsForThisPage, true);
 0688            nftPageView.OnClickBuyNft += ClickOnBuyWearable;
 0689            nftPageView.OnFocusAnyNtf += FocusAnyNtfItem;
 0690            return nftPageView;
 691        }
 692
 693        private NftPageView CreateEmotePageView(WearableItem[] wearables, int i)
 694        {
 0695            PoolableObject nftPagePoolElement = nftEmotesPagesEntryPool.Get();
 0696            nftEmotesPagesPoolableQueue.Add(nftPagePoolElement);
 0697            nftPagePoolElement.gameObject.transform.SetParent(nftEmotesCarouselContent, false);
 0698            NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>();
 0699            nftPageView.OnClickBuyNft -= ClickOnBuyWearable;
 0700            nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem;
 0701            NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE];
 0702            WearableItem[] wearableItemsForThisPage = new WearableItem[PAGE_SIZE];
 703
 0704            for (var j = 0; j < PAGE_SIZE; j++)
 705            {
 0706                if (wearables.Length > i + j && wearables[i + j] != null)
 707                {
 0708                    pageElements[j] = new NFTIconComponentModel
 709                    {
 710                        showMarketplaceButton = true,
 711                        showType = true,
 712                        type = EMOTE_TYPE,
 713                        marketplaceURI = "",
 714                        name = wearables[i + j].GetName(),
 715                        rarity = wearables[i + j].rarity,
 716                        imageURI = wearables[i + j].ComposeThumbnailUrl(),
 717                        nftInfo = wearables[i + j].GetNftInfo(),
 718                    };
 719
 0720                    wearableItemsForThisPage[j] = wearables[i + j];
 721                }
 722                else
 723                {
 0724                    pageElements[j] = null;
 0725                    wearableItemsForThisPage[j] = null;
 726                }
 727            }
 728
 0729            nftPageView.SetPageElementsContent(pageElements);
 0730            nftPageView.IsNftInfoActived = true;
 0731            nftPageView.ConfigureNFTItemInfo(nftItemInfo, wearableItemsForThisPage, false);
 0732            nftPageView.OnClickBuyNft += ClickOnBuyWearable;
 0733            nftPageView.OnFocusAnyNtf += FocusAnyNtfItem;
 0734            return nftPageView;
 735        }
 736
 737        private NftPageView CreateLandPageView(LandsResponse.LandEntry[] lands, int i)
 738        {
 0739            PoolableObject nftPagePoolElement = nftLandsPagesEntryPool.Get();
 0740            nftLandsPagesPoolableQueue.Add(nftPagePoolElement);
 0741            nftPagePoolElement.gameObject.transform.SetParent(nftLandsCarouselContent, false);
 0742            NftPageView nftPageView = nftPagePoolElement.gameObject.GetComponent<NftPageView>();
 0743            nftPageView.OnClickBuyNft -= ClickOnBuyWearable;
 0744            nftPageView.OnFocusAnyNtf -= FocusAnyNtfItem;
 0745            NFTIconComponentModel[] pageElements = new NFTIconComponentModel[PAGE_SIZE];
 746
 0747            for (int j = 0; j < PAGE_SIZE; j++)
 748            {
 0749                if (lands.Length > i + j && lands[i + j] != null)
 750                {
 0751                    pageElements[j] = new ()
 752                    {
 753                        showMarketplaceButton = true,
 754                        showType = true,
 755                        type = lands[i + j].Category,
 756                        marketplaceURI = "",
 757                        name = !string.IsNullOrEmpty(lands[i + j].Name) ? lands[i + j].Name : lands[i + j].Category,
 758                        rarity = LAND_RARITY,
 759                        imageURI = lands[i + j].Image,
 760                        nftInfo = lands[i + j].GetNftInfo(),
 761                    };
 762                }
 0763                else { pageElements[j] = null; }
 764            }
 765
 0766            nftPageView.SetPageElementsContent(pageElements);
 0767            nftPageView.IsNftInfoActived = false;
 0768            nftPageView.OnClickBuyNft += ClickOnBuyWearable;
 0769            nftPageView.OnFocusAnyNtf += FocusAnyNtfItem;
 0770            return nftPageView;
 771        }
 772    }
 773}

Methods/Properties

PassportNavigationComponentView()
PassportNavigationComponentView()
Start()
OpenViewAllSection(PassportSection)
CloseAllSections()
EnableAboutSection(System.Boolean)
EnableCollectiblesSection(System.Boolean)
InitializeView()
SetGuestUser(System.Boolean)
SetName(System.String)
SetOwnUserTexts(System.Boolean)
SetDescription(System.String)
Get(DCL.Social.Passports.AdditionalInfoField)
SetAdditionalInfo(System.Collections.Generic.List[ValueTuple`3])
SetLinks(System.Collections.Generic.List[Link])
AddCoordinateLinks(System.String)
OnDescriptionClicked(UnityEngine.EventSystems.PointerEventData)
ClickedLink(System.String)
SetEquippedWearables(WearableItem[], System.String)
SetCollectibleWearables(WearableItem[])
SetCollectibleEmotes(WearableItem[])
SetCollectibleNames(DCLServices.Lambdas.NamesService.NamesResponse/NameEntry[])
SetCollectibleLands(DCLServices.Lambdas.LandsService.LandsResponse/LandEntry[])
SetHasBlockedOwnUser(System.Boolean)
OpenCollectiblesTab()
SetInitialPage()
SetViewAllButtonActive(PassportSection, System.Boolean)
CloseAllNFTItemInfos()
ClickOnBuyWearable(System.String, System.String)
FocusEquippedNftItem(System.Boolean)
FocusAnyNtfItem()
ReleaseAllNftIconsPoolObjects()
ReleaseNftIconsPoolObjects(System.Collections.Generic.List[PoolableObject])
ReleaseAllNftPagesPoolObjects()
GetNftIconEntryPool()
GetLinkEntryPool()
GetAdditionalInfoFieldEntryPool()
GetNftPagesEntryPool(System.String)
GetNftEntryPool(System.String, UnityEngine.GameObject, System.Int32)
RefreshControl()
SetCollectibleWearablesLoadingActive(System.Boolean)
SetCollectibleEmotesLoadingActive(System.Boolean)
SetCollectibleNamesLoadingActive(System.Boolean)
SetCollectibleLandsLoadingActive(System.Boolean)
SetCollectibleSectionLoadingActive(System.Boolean, CarouselComponentView, UnityEngine.GameObject, UnityEngine.GameObject)
CreateNamePageView(DCLServices.Lambdas.NamesService.NamesResponse/NameEntry[], DCL.PoolableObject, System.Int32)
CreateNamePageElements(DCLServices.Lambdas.NamesService.NamesResponse/NameEntry[], System.Int32)
CreateWearablePageView(WearableItem[], System.Int32)
CreateEmotePageView(WearableItem[], System.Int32)
CreateLandPageView(DCLServices.Lambdas.LandsService.LandsResponse/LandEntry[], System.Int32)