using Core; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; namespace Minigames.StatueDressup.Controllers { /// /// Individual photo thumbnail in the gallery grid. /// Handles click to show enlarged view. /// public class PhotoGridItem : MonoBehaviour, IPointerClickHandler { [Header("References")] [SerializeField] private Image thumbnailImage; [SerializeField] private GameObject loadingIndicator; private string _photoId; private StatuePhotoGalleryController _galleryController; /// /// Initialize grid item with photo ID /// public void Initialize(string photoId, StatuePhotoGalleryController controller) { _photoId = photoId; _galleryController = controller; // Show loading state if (loadingIndicator != null) loadingIndicator.SetActive(true); if (thumbnailImage != null) thumbnailImage.enabled = false; } /// /// Set the thumbnail texture /// public void SetThumbnail(Texture2D thumbnail) { if (thumbnail == null) { Logging.Warning($"[PhotoGridItem] Null thumbnail for photo: {_photoId}"); return; } // Create sprite from thumbnail Sprite thumbnailSprite = Sprite.Create( thumbnail, new Rect(0, 0, thumbnail.width, thumbnail.height), new Vector2(0.5f, 0.5f) ); if (thumbnailImage != null) { thumbnailImage.sprite = thumbnailSprite; thumbnailImage.enabled = true; } // Hide loading indicator if (loadingIndicator != null) loadingIndicator.SetActive(false); } /// /// Handle click to show enlarged view /// public void OnPointerClick(PointerEventData eventData) { if (_galleryController != null && !string.IsNullOrEmpty(_photoId)) { Logging.Debug($"[PhotoGridItem] Clicked: {_photoId}"); _galleryController.ShowEnlargedView(_photoId); } } } }