|
|
|
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class EmailOpenPanel : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public TextMeshProUGUI senderName;
|
|
|
|
|
public TextMeshProUGUI senderEmail;
|
|
|
|
|
public TextMeshProUGUI subject;
|
|
|
|
|
public TextMeshProUGUI bodyText;
|
|
|
|
|
public TextMeshProUGUI linkPreview;
|
|
|
|
|
public GameObject phishingIcon;
|
|
|
|
|
|
|
|
|
|
public TextMeshProUGUI senderInitial;
|
|
|
|
|
public Image senderBg;
|
|
|
|
|
|
|
|
|
|
public Button reportBtn;
|
|
|
|
|
public Button ignoreBtn;
|
|
|
|
|
|
|
|
|
|
private EmailData emailData;
|
|
|
|
|
|
|
|
|
|
public void Setup(EmailData data, string initial, Sprite iconSprite)
|
|
|
|
|
{
|
|
|
|
|
emailData = data;
|
|
|
|
|
|
|
|
|
|
senderName?.SetText(data.senderName);
|
|
|
|
|
senderEmail?.SetText(data.senderEmail);
|
|
|
|
|
subject?.SetText(data.subject);
|
|
|
|
|
bodyText?.SetText(data.fullBodyText);
|
|
|
|
|
linkPreview?.SetText(data.linkPreview);
|
|
|
|
|
if (phishingIcon != null)
|
|
|
|
|
phishingIcon.SetActive(data.isPhishing);
|
|
|
|
|
senderInitial?.SetText(initial);
|
|
|
|
|
if (senderBg != null)
|
|
|
|
|
senderBg.sprite = iconSprite; // ✅ can't use ?. here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reportBtn?.onClick.RemoveAllListeners();
|
|
|
|
|
reportBtn?.onClick.AddListener(() => OnAction("report"));
|
|
|
|
|
|
|
|
|
|
ignoreBtn?.onClick.RemoveAllListeners();
|
|
|
|
|
ignoreBtn?.onClick.AddListener(() => OnAction("ignore"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnAction(string action)
|
|
|
|
|
{
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case "report":
|
|
|
|
|
SceneOutcomeManager.Instance.Reported(emailData);
|
|
|
|
|
break;
|
|
|
|
|
case "ignore":
|
|
|
|
|
SceneOutcomeManager.Instance.Ignored(emailData);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|