using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using Zenject;
using UltraFace;
using DG.Tweening;

public class ImageCanvasHandler : MonoBehaviour
{
    [Inject] private Visualizer _visualizer;
    [SerializeField] private RawImage _rawImage;
    private RectTransform _rectTransform;

    private void Start()
    {
        _rectTransform = GetComponent<RectTransform>();
        _visualizer.OnDetectionStatusChanged += ChangeState;
    }

    private void ChangeState(bool isActive)
    {
        if(isActive)
        {
            _rawImage.DOFade(1, .25f);
        }
        else
        {
            _rawImage.DOFade(0, .25f);
        }

        _rectTransform.DORotate(_rectTransform.eulerAngles + Vector3.up * 360, .5f);
    }

    private void OnDestroy()
    {
        _visualizer.OnDetectionStatusChanged -= ChangeState;
    }
}
