B08_TaskListItem.cs 3.8 KB

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