using Snxxz.UI;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz
|
{
|
public class PushSwitchBtn : MonoBehaviour
|
{
|
[SerializeField] Image switchBG;
|
[SerializeField] RectTransform switchIcon;
|
[SerializeField] public GameObject onObj;
|
[SerializeField] GameObject offObj;
|
[SerializeField] public Button switchBtn;
|
|
[Header("ON时图标位置")]
|
[SerializeField]
|
Vector3 OnPos = new Vector3(18, 1, 0);
|
[Header("OFF时图标位置")]
|
[SerializeField]
|
Vector3 OffPos = new Vector3(-18, 1, 0);
|
|
public int switchIndex;
|
SetPrivateModel privateModel { get { return ModelCenter.Instance.GetModel<SetPrivateModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
|
public void SetInit(int index,bool isOpen)
|
{
|
this.switchIndex = index;
|
RefreshSwitchUI(isOpen);
|
if(switchIndex < privateModel.hangUpPushlist.Count)
|
{
|
switchBtn.RemoveAllListeners();
|
switchBtn.AddListener(() =>
|
{
|
if (onObj.activeInHierarchy)
|
{
|
RefreshSwitchUI(false);
|
privateModel.RefreshPushSet(switchIndex, false);
|
}
|
else
|
{
|
if (vipModel.IsVipActive() || vipModel.IsVipExperience())
|
{
|
RefreshSwitchUI(true);
|
privateModel.RefreshPushSet(switchIndex, true);
|
}
|
else
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("SetUpPrivate101"));
|
}
|
|
}
|
});
|
}
|
}
|
|
public void RefreshSwitchUI(bool isOpen)
|
{
|
if (isOpen)
|
{
|
switchIcon.anchoredPosition3D = OnPos;
|
onObj.SetActive(true);
|
offObj.SetActive(false);
|
switchBG.SetSprite("SettingUpWin_NO");
|
}
|
else
|
{
|
switchIcon.anchoredPosition3D = OffPos;
|
onObj.SetActive(false);
|
offObj.SetActive(true);
|
switchBG.SetSprite("SettingUpWin_OFF");
|
}
|
|
}
|
|
}
|
}
|