| | 1 | | using DCLServices.CameraReelService; |
| | 2 | | using DG.Tweening; |
| | 3 | | using System; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.EventSystems; |
| | 6 | | using UnityEngine.UI; |
| | 7 | |
|
| | 8 | | namespace DCLFeatures.CameraReel.Gallery |
| | 9 | | { |
| | 10 | | public class CameraReelThumbnail : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler |
| | 11 | | { |
| | 12 | | [SerializeField] private ImageComponentView image; |
| | 13 | | [SerializeField] private Image flashImage; |
| | 14 | | [SerializeField] private Button interactionButton; |
| | 15 | | [SerializeField] private Button contextMenuButton; |
| | 16 | | [SerializeField] private ThumbnailContextMenuView contextMenu; |
| | 17 | |
|
| | 18 | | private CameraReelResponse picture; |
| | 19 | |
|
| | 20 | | public event Action<CameraReelResponse> OnClicked; |
| | 21 | |
|
| | 22 | | private void Awake() |
| | 23 | | { |
| 0 | 24 | | interactionButton.onClick.AddListener(() => OnClicked?.Invoke(picture)); |
| 0 | 25 | | contextMenuButton.onClick.AddListener(() => contextMenu.Show(picture)); |
| | 26 | |
|
| 0 | 27 | | image.OnLoaded += _ => |
| | 28 | | { |
| 0 | 29 | | flashImage.color = Color.white; |
| 0 | 30 | | flashImage.DOColor(new Color(1, 1, 1, 0), 0.5f); |
| 0 | 31 | | AudioScriptableObjects.listItemAppear.Play(true); |
| 0 | 32 | | }; |
| 0 | 33 | | } |
| | 34 | |
|
| | 35 | | public void Show(CameraReelResponse picture) |
| | 36 | | { |
| 0 | 37 | | this.picture = picture; |
| 0 | 38 | | image.SetImage(picture.thumbnailUrl); |
| 0 | 39 | | gameObject.SetActive(true); |
| 0 | 40 | | } |
| | 41 | |
|
| | 42 | | public int CompareTo(CameraReelThumbnail thumbnail) => |
| 0 | 43 | | picture.metadata.GetLocalizedDateTime().CompareTo(thumbnail.picture.metadata.GetLocalizedDateTime()); |
| | 44 | |
|
| | 45 | | public void OnPointerEnter(PointerEventData eventData) |
| | 46 | | { |
| 0 | 47 | | transform.DOScale(Vector3.one * 1.03f, 0.3f); |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | public void OnPointerExit(PointerEventData eventData) |
| | 51 | | { |
| 0 | 52 | | transform.DOScale(Vector3.one, 0.3f); |
| 0 | 53 | | } |
| | 54 | | } |
| | 55 | | } |