| | 1 | | using DCL.Helpers; |
| | 2 | | using System; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | namespace DCLFeatures.CameraReel.ScreenshotViewer |
| | 7 | | { |
| | 8 | | public class ScreenshotViewerView : MonoBehaviour, IScreenshotViewerView |
| | 9 | | { |
| | 10 | | private const float SIDE_PANEL_ANIM_DURATION = 0.5f; |
| | 11 | |
|
| | 12 | | [SerializeField] private ImageComponentView screenshotImage; |
| | 13 | | [SerializeField] private RectTransform rootContainer; |
| | 14 | |
|
| | 15 | | [Header("NAVIGATION BUTTONS")] |
| | 16 | | [SerializeField] private Button closeView; |
| | 17 | | [SerializeField] private Button prevScreenshotButton; |
| | 18 | | [SerializeField] private Button nextScreenshotButton; |
| | 19 | |
|
| | 20 | | private MetadataSidePanelAnimator metadataSidePanelAnimator; |
| | 21 | |
|
| 0 | 22 | | private bool metadataPanelIsOpen = true; |
| | 23 | |
|
| 0 | 24 | | [field: SerializeField] public ScreenshotViewerActionsPanelView ActionPanel { get; private set; } |
| 0 | 25 | | [field: SerializeField] public ScreenshotViewerInfoSidePanelView InfoSidePanel { get; private set; } |
| | 26 | |
|
| | 27 | | public event Action CloseButtonClicked; |
| | 28 | | public event Action PrevScreenshotClicked; |
| | 29 | | public event Action NextScreenshotClicked; |
| | 30 | |
|
| | 31 | | private void Awake() |
| | 32 | | { |
| 0 | 33 | | metadataSidePanelAnimator = new MetadataSidePanelAnimator(rootContainer, ActionPanel.InfoButtonBackground); |
| 0 | 34 | | } |
| | 35 | |
|
| | 36 | | private void OnEnable() |
| | 37 | | { |
| 0 | 38 | | closeView.onClick.AddListener(() => CloseButtonClicked?.Invoke()); |
| 0 | 39 | | prevScreenshotButton.onClick.AddListener(() => PrevScreenshotClicked?.Invoke()); |
| 0 | 40 | | nextScreenshotButton.onClick.AddListener(() => NextScreenshotClicked?.Invoke()); |
| 0 | 41 | | } |
| | 42 | |
|
| | 43 | | private void OnDisable() |
| | 44 | | { |
| 0 | 45 | | closeView.onClick.RemoveAllListeners(); |
| 0 | 46 | | prevScreenshotButton.onClick.RemoveAllListeners(); |
| 0 | 47 | | nextScreenshotButton.onClick.RemoveAllListeners(); |
| 0 | 48 | | } |
| | 49 | |
|
| | 50 | | public void Dispose() |
| | 51 | | { |
| 0 | 52 | | Utils.SafeDestroy(gameObject); |
| 0 | 53 | | } |
| | 54 | |
|
| | 55 | | public void Hide() |
| | 56 | | { |
| 0 | 57 | | gameObject.SetActive(false); |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | public void Show() |
| | 61 | | { |
| 0 | 62 | | gameObject.SetActive(true); |
| 0 | 63 | | } |
| | 64 | |
|
| | 65 | | public void SetScreenshotImage(string url) |
| | 66 | | { |
| 0 | 67 | | screenshotImage.SetImage(url); |
| 0 | 68 | | } |
| | 69 | |
|
| | 70 | | public void ToggleInfoSidePanel() |
| | 71 | | { |
| 0 | 72 | | metadataSidePanelAnimator.ToggleSizeMode(toFullScreen: metadataPanelIsOpen, SIDE_PANEL_ANIM_DURATION); |
| 0 | 73 | | metadataPanelIsOpen = !metadataPanelIsOpen; |
| 0 | 74 | | } |
| | 75 | | } |
| | 76 | | } |