TaptapAntiAddictionHealthPaymentController.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using TapSDK.UI;
  2. using TapTap.AntiAddiction.Model;
  3. using UnityEngine.UI;
  4. using System;
  5. namespace TapTap.AntiAddiction.Internal
  6. {
  7. public class TaptapAntiAddictionHealthPaymentController : BasePanelController
  8. {
  9. public Text titleText;
  10. public Text contentText;
  11. public Text buttonText;
  12. public Button okButton;
  13. private Action _onOk;
  14. /// <summary>
  15. /// bind ugui components for every panel
  16. /// </summary>
  17. protected override void BindComponents()
  18. {
  19. titleText = transform.Find("Root/TitleText").GetComponent<Text>();
  20. contentText = transform.Find("Root/ContentText").GetComponent<Text>();
  21. okButton = transform.Find("Root/OKButton").GetComponent<Button>();
  22. buttonText = okButton.transform.Find("Text").GetComponent<Text>();
  23. }
  24. protected override void OnLoadSuccess()
  25. {
  26. base.OnLoadSuccess();
  27. okButton.onClick.AddListener(OnOKButtonClicked);
  28. }
  29. internal void Show(PayableResult payable)
  30. {
  31. titleText.text = payable.Title;
  32. contentText.text = ProcessContent(payable.Content);
  33. var buttonText = Config.healthPayTipButtonText;
  34. if (!string.IsNullOrEmpty(buttonText))
  35. this.buttonText.text = buttonText;
  36. }
  37. internal void Show(string title, string content, string buttonText, Action onOk = null)
  38. {
  39. titleText.text = title;
  40. contentText.text = ProcessContent(content);
  41. if (!string.IsNullOrEmpty(buttonText))
  42. this.buttonText.text = buttonText;
  43. _onOk = onOk;
  44. }
  45. private string ProcessContent(string content)
  46. {
  47. return content
  48. ?.Replace("<font color=", "<color=")
  49. .Replace("<span color=", "<color=")
  50. .Replace("</font>", "</color>")
  51. .Replace("</span>", "</color>")
  52. .Replace("<br>", "\n");
  53. }
  54. private void OnOKButtonClicked()
  55. {
  56. _onOk?.Invoke();
  57. Close();
  58. }
  59. }
  60. }