UIFashionTotalView.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. local UIFashionTotalView = require("UIFashion/UIFashionTotalView_Generate")
  2. function UIFashionTotalView:OnAwake(data)
  3. self.controller = require("UIFashion/UIFashionTotalCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIFashionTotalView:AddEventListener()
  8. -- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.FASHION_LIST_CHANGE, self, self.RefreshAllAttr)
  9. end
  10. function UIFashionTotalView:FillContent(data, uiBase)
  11. self.uiBase = uiBase
  12. local gameObject = self.uiBase:GetRoot()
  13. if gameObject ~= nil then
  14. self.gameObject = gameObject
  15. self.transform = gameObject.transform
  16. end
  17. self:InitGenerate(self.transform, data)
  18. self:Init()
  19. end
  20. function UIFashionTotalView:Init()
  21. self.attrTitle.uILocalizeScript:SetContent(self.controller:GetTile())
  22. self.attr1Title.uILocalizeScript:SetContent(self.controller:GetTile1())
  23. local attr = self.controller:GetAttrs()
  24. local attr1 = self.controller:GetAttrs1()
  25. self.propertySuit:SetActive(attr ~= nil)
  26. self.property:SetActive(attr1 ~= nil)
  27. self.propertySuit.noPro:SetActive(attr == nil or #attr == 0)
  28. self.property.noPro:SetActive(attr1 == nil or #attr1 == 0)
  29. end
  30. function UIFashionTotalView:OnPageInEnd()
  31. self.super:OnPageInEnd()
  32. self:RefreshAttrs()
  33. self:RefreshAttrs1()
  34. end
  35. function UIFashionTotalView:RemoveEventListener()
  36. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  37. end
  38. function UIFashionTotalView:AddUIEventListener()
  39. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  40. self.uiBase:AddButtonEventListener(self.AnyBtn.button, self, self.CloseUI)
  41. self.uiBase:AddButtonEventListener(self.btnClose.button, self, self.CloseUI)
  42. end
  43. function UIFashionTotalView:OnHide()
  44. end
  45. function UIFashionTotalView:OnShow(data)
  46. self.controller:SetData(data)
  47. self:Init()
  48. end
  49. function UIFashionTotalView:OnClose()
  50. self.propertySuit.loopVerticalScrollRect:ClearCells()
  51. self.property.loopVerticalScrollRect:ClearCells()
  52. end
  53. function UIFashionTotalView:OnDispose()
  54. end
  55. function UIFashionTotalView:CloseUI()
  56. self:UIClose()
  57. end
  58. function UIFashionTotalView:RefreshAttrs()
  59. local attrs = self.controller:GetAttrs()
  60. if not attrs then return end
  61. CommonUtil.LoopGridViewEleCreateNew(self, self.propertySuit.loopVerticalScrollRect, nil, attrs, 0, nil, function (itemLua, idx)
  62. CommonUtil.UpdateItemPrefab(self, itemLua, attrs[idx + 1])
  63. end)
  64. end
  65. function UIFashionTotalView:RefreshAttrs1()
  66. local attrs1 = self.controller:GetAttrs1()
  67. if not attrs1 then return end
  68. CommonUtil.LoopGridViewEleCreateNew(self, self.property.loopVerticalScrollRect, nil, attrs1, 0, nil, function (itemLua, idx)
  69. CommonUtil.UpdateItemPrefab(self, itemLua, attrs1[idx + 1])
  70. end)
  71. end
  72. return UIFashionTotalView