using System;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.ErrorDialog;

public class NtDataTranslateManager
{
	private static NtDataTranslateManager instance;

	public NtDataTranslateInfo TranslateInfo;

	public string curBindEmail = "";

	public const string FIRST_LOOK = "FIRST_LOOK";

	private NtDataTranslateManager()
	{
		TranslateInfo = NtDataTranslateInfo.Init();
	}

	public static NtDataTranslateManager GetInstance()
	{
		if (instance == null)
		{
			instance = new NtDataTranslateManager();
		}
		return instance;
	}

	public string GetSetTranslateInfoUrl()
	{
		return string.Format("{0}{1}", TranslateInfo.serverUrl, "netease_data_transaction/set_email_address");
	}

	public void ShowStatement()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(TranslateInfo.titleStatement);
		dialogBase.SetText(TranslateInfo.containStatement);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id1, TranslateInfo.button_id2);
		dialogBase.onPushButton1 = delegate
		{
			ShowAddress();
		};
	}

	public void ShowAddress()
	{
		NtDataTranslateInput dataInput = UnityEngine.Object.Instantiate(NtDataTranslate.Instance.InputObj);
		DialogBase dialog = UIManager.GetInstance().CreateDialogClose();
		dialog.SetTitleLabel(TranslateInfo.titleEmail);
		dialog.SetText(string.Empty);
		dialog.SetButtonLayout(DialogBase.ButtonLayout.DecisionBtn);
		dialog.isNotCloseWindowButton1 = true;
		dialog.SetSize(DialogBase.Size.XL);
		dialog.SetButtonText(TranslateInfo.button_id3);
		dialog.onPushButton1 = delegate
		{
			dataInput.UpLoadEmail(delegate
			{
				SetDataTranslateTask setDataTranslateTask = new SetDataTranslateTask();
				setDataTranslateTask.SetParameter(dataInput.EmailAddress);
				Toolbox.NetworkManager.StartCoroutine(Toolbox.NetworkManager.Connect(setDataTranslateTask, delegate
				{
					ShowSuccess();
					dialog.Close();
				}));
			});
		};
		dialog.SetObj(dataInput.gameObject);
	}

	public void ShowSuccess()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(TranslateInfo.titleSuccess);
		dialogBase.SetText(TranslateInfo.containSuccess);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id4);
	}

	public void ShowRejectLogin(Action callback = null)
	{
		DialogBase dialogBase = Dialog.Create(330);
		dialogBase.SetTitleLabel(TranslateInfo.titleTip);
		dialogBase.SetText(string.Format(TranslateInfo.containTip, curBindEmail));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id7);
		dialogBase.SetVisibleContactButton(isVisible: false, 330.ToString());
		dialogBase.onPushButton1 = delegate
		{
			callback.Call();
		};
	}
}
