
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using TMPro;

public class LoginPassWordManager : MonoSingleton<LoginPassWordManager>
{
    public TextMeshProUGUI nameText;
    public GameObject errorGo;
    int MAXINPUT = 8;
    public TMP_InputField tmpField;
    public GameObject passWordGo;
    public GameObject iconGo;
    private void OnEnable()
    {
        errorGo.SetActive(false);
        passWordGo.SetActive(false);
        try
        {
            UserManager.Instance.MoveIcon(Vector3.zero, iconGo.transform, ()=> {
                nameText.text = UserManager.Instance.NowChoose.name;
                passWordGo.SetActive(true);
            });

        }
        catch
        {

        }
    }

    public void toError()
    {
        errorGo.SetActive(true);
        tmpField.transform.DOShakePosition(0.5f,2);
    }

    public void GoBack()
    {
        LoginWindowsManager.Instance.gotologin();
    }

    public void setNum(string num)
    {
        errorGo.SetActive(false);
        if (num!="R"&& num != "")
        {
            if(tmpField.text.Length<= MAXINPUT)
            {
                tmpField.text = tmpField.text + num;
            }
        }else if(num == "R")
        {
            tmpField.text = tmpField.text.Remove(tmpField.text.Length-1);
        }
    }
}
