| | 1 | | using System; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.UI; |
| | 5 | |
|
| | 6 | | internal class SectionLandView : MonoBehaviour, IDisposable |
| | 7 | | { |
| | 8 | | public event Action OnOpenMarketplaceRequested; |
| | 9 | |
|
| | 10 | | [SerializeField] internal LandElementView landElementView; |
| | 11 | | [SerializeField] private ScrollRect scrollRect; |
| | 12 | | [SerializeField] internal GameObject contentContainer; |
| | 13 | | [SerializeField] internal GameObject emptyContainer; |
| | 14 | | [SerializeField] internal GameObject loadingAnimationContainer; |
| | 15 | | [SerializeField] internal GameObject noSearchResultContainer; |
| | 16 | | [SerializeField] internal Button buttonNoLandCTA; |
| | 17 | |
|
| | 18 | | private bool isDestroyed = false; |
| | 19 | |
|
| 16 | 20 | | private void Awake() { buttonNoLandCTA.onClick.AddListener(() => OnOpenMarketplaceRequested?.Invoke()); } |
| | 21 | |
|
| 16 | 22 | | private void OnDestroy() { isDestroyed = true; } |
| | 23 | |
|
| | 24 | | public void SetParent(Transform parent) |
| | 25 | | { |
| 0 | 26 | | transform.SetParent(parent); |
| 0 | 27 | | transform.ResetLocalTRS(); |
| 0 | 28 | | } |
| | 29 | |
|
| 6 | 30 | | public void SetActive(bool active) { gameObject.SetActive(active); } |
| | 31 | |
|
| 10 | 32 | | public void ResetScrollRect() { scrollRect.verticalNormalizedPosition = 1; } |
| | 33 | |
|
| 12 | 34 | | public Transform GetLandElementsContainer() { return landElementView.GetParent(); } |
| | 35 | |
|
| 0 | 36 | | public LandElementView GetLandElementeBaseView() { return landElementView; } |
| | 37 | |
|
| | 38 | | public void SetEmpty() |
| | 39 | | { |
| 3 | 40 | | contentContainer.SetActive(false); |
| 3 | 41 | | emptyContainer.SetActive(true); |
| 3 | 42 | | noSearchResultContainer.SetActive(false); |
| 3 | 43 | | loadingAnimationContainer.SetActive(false); |
| 3 | 44 | | } |
| | 45 | |
|
| | 46 | | public void SetLoading() |
| | 47 | | { |
| 1 | 48 | | contentContainer.SetActive(false); |
| 1 | 49 | | emptyContainer.SetActive(false); |
| 1 | 50 | | noSearchResultContainer.SetActive(false); |
| 1 | 51 | | loadingAnimationContainer.SetActive(true); |
| 1 | 52 | | } |
| | 53 | |
|
| | 54 | | public void SetNoSearchResult() |
| | 55 | | { |
| 1 | 56 | | contentContainer.SetActive(false); |
| 1 | 57 | | emptyContainer.SetActive(false); |
| 1 | 58 | | noSearchResultContainer.SetActive(true); |
| 1 | 59 | | loadingAnimationContainer.SetActive(false); |
| 1 | 60 | | } |
| | 61 | |
|
| | 62 | | public void SetFilled() |
| | 63 | | { |
| 5 | 64 | | contentContainer.SetActive(true); |
| 5 | 65 | | emptyContainer.SetActive(false); |
| 5 | 66 | | noSearchResultContainer.SetActive(false); |
| 5 | 67 | | loadingAnimationContainer.SetActive(false); |
| 5 | 68 | | ResetScrollRect(); |
| 5 | 69 | | } |
| | 70 | |
|
| | 71 | | public void Dispose() |
| | 72 | | { |
| 3 | 73 | | if (!isDestroyed) |
| | 74 | | { |
| 3 | 75 | | Destroy(gameObject); |
| | 76 | | } |
| 3 | 77 | | } |
| | 78 | | } |