| | 1 | | using DG.Tweening; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | namespace DCLFeatures.CameraReel.ScreenshotViewer |
| | 6 | | { |
| | 7 | | public class MetadataSidePanelAnimator |
| | 8 | | { |
| | 9 | | private readonly RectTransform panelRectTransform; |
| | 10 | | private readonly Image infoButtonImage; |
| | 11 | | private readonly float initOffset; |
| | 12 | |
|
| | 13 | | private float rightOffset; |
| | 14 | | private Tweener currentTween; |
| | 15 | |
|
| 0 | 16 | | public MetadataSidePanelAnimator(RectTransform panelRectTransform, Image infoButtonImage) |
| | 17 | | { |
| 0 | 18 | | this.infoButtonImage = infoButtonImage; |
| 0 | 19 | | this.panelRectTransform = panelRectTransform; |
| | 20 | |
|
| 0 | 21 | | initOffset = panelRectTransform.offsetMax.x; |
| 0 | 22 | | rightOffset = -initOffset; |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | public void ToggleSizeMode(bool toFullScreen, float duration) |
| | 26 | | { |
| 0 | 27 | | currentTween.Kill(); |
| | 28 | |
|
| 0 | 29 | | if (toFullScreen) |
| | 30 | | { |
| 0 | 31 | | currentTween = DOVirtual.Float(rightOffset, 0, duration, UpdateSizeMode); |
| 0 | 32 | | infoButtonImage.DOFade(0f, duration); |
| | 33 | | } |
| | 34 | | else |
| | 35 | | { |
| 0 | 36 | | currentTween = DOVirtual.Float(rightOffset, -initOffset, duration, UpdateSizeMode); |
| 0 | 37 | | infoButtonImage.DOFade(1f, duration); |
| | 38 | | } |
| 0 | 39 | | } |
| | 40 | |
|
| | 41 | | private void UpdateSizeMode(float value) |
| | 42 | | { |
| 0 | 43 | | rightOffset = value; |
| 0 | 44 | | panelRectTransform.offsetMax = new Vector2(-rightOffset, panelRectTransform.offsetMax.y); |
| 0 | 45 | | } |
| | 46 | | } |
| | 47 | | } |