B08_TaskListItem.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class B08_TaskListItem : MonoBehaviour
  6. {
  7. public Text typeText;
  8. public Text titleText;
  9. public Text stateText;
  10. public Text dateText;
  11. public Text ctrlText;
  12. public GameObject more;
  13. public Button moreButton;
  14. public bool moreMessage = false;
  15. public RectTransform rect;
  16. public GameObject pointItemPrefab;
  17. public List<B08_TaskPointItem> PointItems = new List<B08_TaskPointItem>();
  18. public Transform itemContent;
  19. public B08_TaskInfoData InfoData;
  20. public GCYWLayer gcywLayer;
  21. public static B08_TaskListItem currentTaskListItem;
  22. public void Init()
  23. {
  24. rect = this.GetComponent<RectTransform>();
  25. typeText = this.transform.Find("typeText").GetComponent<Text>();
  26. titleText = this.transform.Find("titleText").GetComponent<Text>();
  27. stateText = this.transform.Find("stateText").GetComponent<Text>();
  28. dateText = this.transform.Find("dateText").GetComponent<Text>();
  29. ctrlText = this.transform.Find("ctrlText").GetComponent<Text>();
  30. more = this.transform.Find("more").gameObject;
  31. more.SetActive(false);
  32. moreButton = ctrlText.GetComponent<Button>();
  33. moreButton.onClick.AddListener(() => {
  34. ChangeMoreMessage(!moreMessage);
  35. });
  36. moreMessage = false;
  37. ctrlText.text = "<color=#00EFFF>详情</color>";
  38. rect.sizeDelta = new Vector2(360,38);
  39. more.SetActive(false);
  40. }
  41. public void ChangeMoreMessage(bool moreMes = false)
  42. {
  43. moreMessage = moreMes;
  44. if (moreMessage)
  45. {
  46. if (currentTaskListItem != null)
  47. {
  48. if (currentTaskListItem.moreMessage) {
  49. currentTaskListItem.ChangeMoreMessage(false);
  50. }
  51. }
  52. ctrlText.text = "<color=#00FF3F>收起</color>";
  53. rect.sizeDelta = new Vector2(360, 354);
  54. more.SetActive(true);
  55. gcywLayer.SetTaskImgPanelData(InfoData.items, InfoData.startTime);
  56. currentTaskListItem = this;
  57. }
  58. else
  59. {
  60. ctrlText.text = "<color=#00EFFF>详情</color>";
  61. rect.sizeDelta = new Vector2(360, 38);
  62. more.SetActive(false);
  63. }
  64. }
  65. public void SetData(GCYWLayer baseLayer,B08_TaskInfoData data,int typeIndex)
  66. {
  67. gcywLayer = baseLayer;
  68. InfoData = data;
  69. string typeStr = "";
  70. switch (typeIndex)
  71. {
  72. case 0:
  73. typeStr = "电气";
  74. break;
  75. case 1:
  76. typeStr = "闸站";
  77. break;
  78. case 2:
  79. typeStr = "堤防";
  80. break;
  81. case 3:
  82. typeStr = "交叉建筑";
  83. break;
  84. case 4:
  85. typeStr = "定期专项";
  86. break;
  87. }
  88. typeText.text = typeStr;
  89. titleText.text = data.fanganName;
  90. stateText.text = data.status;
  91. dateText.text = data.startTime;
  92. for (int i = 0; i < PointItems.Count; i++)
  93. {
  94. Destroy(PointItems[i].gameObject);
  95. }
  96. PointItems.Clear();
  97. for (int i = 0; i < data.items.Length; i++)
  98. {
  99. B08_TaskPointItem tempItem = Instantiate(pointItemPrefab,itemContent).GetComponent<B08_TaskPointItem>();
  100. tempItem.SetData(baseLayer,data.items[i],i,data.startTime);
  101. var button = tempItem.GetComponent<ExtendedButton_PointItem>();
  102. button.index = i;
  103. button.onPointerEnter += baseLayer.SetTaskPointIconHeightLight;
  104. PointItems.Add(tempItem);
  105. }
  106. }
  107. }