< Summary

Class:DCLFeatures.CameraReel.ScreenshotViewer.ScreenshotViewerInfoSidePanelView
Assembly:CameraReel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLFeatures/CameraReel/ScreenshotViewer/Scripts/ScreenshotViewerInfoSidePanelView.cs
Covered lines:0
Uncovered lines:35
Coverable lines:35
Total lines:108
Line coverage:0% (0 of 35)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:10
Method coverage:0% (0 of 10)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ScreenshotViewerInfoSidePanelView()0%2100%
Awake()0%2100%
OnEnable()0%2100%
OnDisable()0%2100%
SetSceneInfoText(...)0%2100%
SetDateText(...)0%2100%
ShowVisiblePersons(...)0%30500%
SetPictureOwner(...)0%2100%
ClearCurrentProfiles()0%6200%
GetProfileEntryPool()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLFeatures/CameraReel/ScreenshotViewer/Scripts/ScreenshotViewerInfoSidePanelView.cs

#LineLine coverage
 1using DCL;
 2using DCLServices.CameraReelService;
 3using System;
 4using System.Collections.Generic;
 5using System.Globalization;
 6using System.Linq;
 7using TMPro;
 8using UnityEngine;
 9using UnityEngine.UI;
 10
 11namespace DCLFeatures.CameraReel.ScreenshotViewer
 12{
 13    public class ScreenshotViewerInfoSidePanelView : MonoBehaviour, IScreenshotViewerInfoSidePanelView
 14    {
 015        private readonly Dictionary<ScreenshotVisiblePersonView, PoolableObject> profiles = new ();
 16
 17        [Header("INFORMATION PANEL")]
 18        [SerializeField] private Button infoPanelTextButton;
 19        [SerializeField] private TMP_Text dataTime;
 20        [SerializeField] private TMP_Text sceneInfo;
 21        [SerializeField] private Button sceneInfoButton;
 22        [SerializeField] private TMP_Text photoOwnerNameLabel;
 23        [SerializeField] private ImageComponentView photoOwnerAvatarPicture;
 24        [SerializeField] private Button pictureOwnerProfileButton;
 25
 26        [Header("VISIBLE PEOPLE PANEL")]
 27        [SerializeField] private ScreenshotVisiblePersonView profileEntryTemplate;
 28        [SerializeField] private Transform profileGridContainer;
 29
 30        private MetadataSidePanelAnimator metadataSidePanelAnimator;
 31
 32        public event Action SceneButtonClicked;
 33        public event Action SidePanelButtonClicked;
 34        public event Action OnOpenPictureOwnerProfile;
 35
 36        private void Awake()
 37        {
 038            profileEntryTemplate.gameObject.SetActive(false);
 039        }
 40
 41        private void OnEnable()
 42        {
 043            infoPanelTextButton.onClick.AddListener(() => SidePanelButtonClicked?.Invoke());
 044            sceneInfoButton.onClick.AddListener(() => SceneButtonClicked?.Invoke());
 045            pictureOwnerProfileButton.onClick.AddListener(() => OnOpenPictureOwnerProfile?.Invoke());
 046        }
 47
 48        private void OnDisable()
 49        {
 050            infoPanelTextButton.onClick.RemoveAllListeners();
 051            sceneInfoButton.onClick.RemoveAllListeners();
 052            pictureOwnerProfileButton.onClick.RemoveAllListeners();
 053        }
 54
 55        public void SetSceneInfoText(Scene scene) =>
 056            sceneInfo.text = $"{scene.name}, {scene.location.x}, {scene.location.y}";
 57
 58        public void SetDateText(DateTime dateTime) =>
 059            dataTime.text = dateTime.ToString("MMMM dd, yyyy", CultureInfo.InvariantCulture);
 60
 61        public void ShowVisiblePersons(VisiblePerson[] visiblePeople)
 62        {
 063            ClearCurrentProfiles();
 64
 065            Pool profilePool = GetProfileEntryPool();
 66
 067            foreach (VisiblePerson visiblePerson in visiblePeople.OrderBy(person => person.isGuest)
 068                                                                 .ThenByDescending(person => person.wearables.Length))
 69            {
 070                PoolableObject poolObj = profilePool.Get();
 071                ScreenshotVisiblePersonView profileEntry = poolObj.gameObject.GetComponent<ScreenshotVisiblePersonView>(
 072                profileEntry.transform.SetParent(profileGridContainer, false);
 073                profiles[profileEntry] = poolObj;
 074                profileEntry.Configure(visiblePerson);
 075                profileEntry.gameObject.SetActive(true);
 76            }
 077        }
 78
 79        public void SetPictureOwner(string userName, string avatarPictureUrl)
 80        {
 081            photoOwnerNameLabel.text = userName;
 082            photoOwnerAvatarPicture.SetImage(avatarPictureUrl);
 083        }
 84
 85        private void ClearCurrentProfiles()
 86        {
 087            foreach ((_, PoolableObject poolObj) in profiles)
 088                poolObj.Release();
 89
 090            profiles.Clear();
 091        }
 92
 93        private Pool GetProfileEntryPool()
 94        {
 95            const string POOL_ID = "PictureDetailProfile";
 096            var entryPool = PoolManager.i.GetPool(POOL_ID);
 097            if (entryPool != null) return entryPool;
 98
 099            entryPool = PoolManager.i.AddPool(
 100                POOL_ID,
 101                Instantiate(profileEntryTemplate).gameObject,
 102                maxPrewarmCount: 10,
 103                isPersistent: true);
 104
 0105            return entryPool;
 106        }
 107    }
 108}