< Summary

Class:DCLFeatures.CameraReel.Gallery.ThumbnailContextMenuView
Assembly:CameraReel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLFeatures/CameraReel/Gallery/Scripts/ThumbnailContextMenuView.cs
Covered lines:0
Uncovered lines:34
Coverable lines:34
Total lines:94
Line coverage:0% (0 of 34)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:7
Method coverage:0% (0 of 7)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
ThumbnailContextMenuView()0%2100%
Awake()0%2100%
OnDestroy()0%2100%
RefreshControl()0%2100%
Show(...)0%6200%
Hide(...)0%2100%
Dispose()0%6200%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLFeatures/CameraReel/Gallery/Scripts/ThumbnailContextMenuView.cs

#LineLine coverage
 1using DCL.Helpers;
 2using DCLServices.CameraReelService;
 3using System;
 4using UIComponents.ContextMenu;
 5using UnityEngine;
 6using UnityEngine.UI;
 7
 8namespace DCLFeatures.CameraReel.Gallery
 9{
 10    [RequireComponent(typeof(RectTransform))]
 11    public class ThumbnailContextMenuView : ContextMenuComponentView, IThumbnailContextMenuView
 12    {
 013        public static readonly BaseList<ThumbnailContextMenuView> Instances = new ();
 14
 15        [SerializeField] private Button downloadButton;
 16        [SerializeField] private Button deleteButton;
 17        [SerializeField] private Button copyLinkButton;
 18        [SerializeField] private Button shareToTwitterButton;
 19        [SerializeField] private bool selfDestroy;
 20
 21        public event Action OnDownloadRequested;
 22        public event Action OnDeletePictureRequested;
 23        public event Action OnCopyPictureLinkRequested;
 24        public event Action OnShareToTwitterRequested;
 25        public event Action<CameraReelResponse> OnSetup;
 26
 27        public override void Awake()
 28        {
 029            base.Awake();
 30
 031            HidingHierarchyTransforms = new[]
 32            {
 33                transform,
 34                downloadButton.transform,
 35                deleteButton.transform,
 36                copyLinkButton.transform,
 37                shareToTwitterButton.transform,
 38            };
 39
 040            downloadButton.onClick.AddListener(() =>
 41            {
 042                OnDownloadRequested?.Invoke();
 043                Hide();
 044            });
 45
 046            deleteButton.onClick.AddListener(() =>
 47            {
 048                OnDeletePictureRequested?.Invoke();
 049                Hide();
 050            });
 51
 052            copyLinkButton.onClick.AddListener(() =>
 53            {
 054                OnCopyPictureLinkRequested?.Invoke();
 055                Hide();
 056            });
 57
 058            shareToTwitterButton.onClick.AddListener(() =>
 59            {
 060                OnShareToTwitterRequested?.Invoke();
 061                Hide();
 062            });
 63
 064            Instances.Add(this);
 065        }
 66
 67        private void OnDestroy()
 68        {
 069            Instances.Remove(this);
 070        }
 71
 072        public override void RefreshControl() { }
 73
 74        public void Show(CameraReelResponse picture)
 75        {
 076            gameObject.SetActive(true);
 077            ClampPositionToScreenBorders(transform.position);
 078            OnSetup?.Invoke(picture);
 079        }
 80
 81        public override void Hide(bool instant = false)
 82        {
 083            base.Hide(instant);
 84
 085            gameObject.SetActive(false);
 086        }
 87
 88        public override void Dispose()
 89        {
 090            if (selfDestroy)
 091                Utils.SafeDestroy(gameObject);
 092        }
 93    }
 94}