80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
|
|
using Core;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using UnityEngine.EventSystems;
|
|||
|
|
|
|||
|
|
namespace Minigames.StatueDressup.Controllers
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Individual photo thumbnail in the gallery grid.
|
|||
|
|
/// Handles click to show enlarged view.
|
|||
|
|
/// </summary>
|
|||
|
|
public class PhotoGridItem : MonoBehaviour, IPointerClickHandler
|
|||
|
|
{
|
|||
|
|
[Header("References")]
|
|||
|
|
[SerializeField] private Image thumbnailImage;
|
|||
|
|
[SerializeField] private GameObject loadingIndicator;
|
|||
|
|
|
|||
|
|
private string _photoId;
|
|||
|
|
private StatuePhotoGalleryController _galleryController;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Initialize grid item with photo ID
|
|||
|
|
/// </summary>
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set the thumbnail texture
|
|||
|
|
/// </summary>
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Handle click to show enlarged view
|
|||
|
|
/// </summary>
|
|||
|
|
public void OnPointerClick(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
if (_galleryController != null && !string.IsNullOrEmpty(_photoId))
|
|||
|
|
{
|
|||
|
|
Logging.Debug($"[PhotoGridItem] Clicked: {_photoId}");
|
|||
|
|
_galleryController.ShowEnlargedView(_photoId);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|