using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GCGame.Table;

public class ChatReportPanelCtr : MonoBehaviour {
    public static ChatReportPanelCtr Instance;
    private void OnEnable()
    {
        Instance = this;
    }

    private void OnDisable()
    {
        Instance = null;
    }

    //默认选择第一个举报类型
    void ShowFirstType()
    {
        OnTypeItemClick(0);
    }

    public List<GameObject> _markIconList;
    public Text _descText;
    public InputField _inputText;

    private string _bReportContent;  //被举报内容
    private ulong _bReportGuid; //被举报者GUID
    private string _bReportPlayerName; //被举报者名称 
    public void InitReport(string _name, string _reportContent, ulong _guid)
    {
        _bReportPlayerName = _name;
        _bReportContent = _reportContent;
        _bReportGuid = _guid;
        _descText.text = StrDictionary.GetClientDictionaryString("#{68009}", _name);
        ShowFirstType();
    }

    private int _curSelectIndex = -1;
    public void OnTypeItemClick(int _Index)
    {
        if (_Index == _curSelectIndex)
            return;

        _curSelectIndex = _Index;

        for (int index = 0; index < _markIconList.Count; index++)
        {
            _markIconList[index].SetActive(index == _Index);
        }
    }
    
    public void OnReportBtnClick()
    {
        if(LimitChatInfoCtr.Instance)
        {
            LimitChatInfoCtr.Instance.ReqReport(_curSelectIndex, _inputText.text,
                GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid,
                _bReportGuid,
                GameManager.gameManager.PlayerDataPool.WorldId,
                _bReportContent,
                _bReportPlayerName);
        }

        OnCancelBtnClick();
    }

    public void OnCancelBtnClick()
    {
        UIManager.CloseUI(UIInfo.ChatReportPanel);
    }
}