KLFriendChatViewItem.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ---@class KLFriendChatViewItem:UIKmlLuaPanelBase
  2. ---@field view KLFriendChatViewItemView
  3. local KLFriendChatViewItem = class(UIKmlLuaPanelBase)
  4. local this =KLFriendChatViewItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.calculationUI = GUI:UIPanel_Open("dev/ui/Chat/Item/KLUIChatItem/KLUIChatItem",self.view.root,self,{})
  8. GUI:setPositionX(self.calculationUI.view.root,2000)
  9. GUI:setPositionY(self.calculationUI.view.root,2000)
  10. GUI:setContentSize(self.calculationUI.view.root, 650, 80)
  11. GUI:DataListInitData(self.view.chat_data_list,function()
  12. return self:ChatDataListItemCountFunc()
  13. end,function(realIndex)
  14. return self:ChatDataListItemGetFunc(realIndex)
  15. end,function(realIndex, kmlcontrol)
  16. return self:ChatDataListItemInitFunc(realIndex, kmlcontrol)
  17. end, function(realIndex, kmlcontrol)
  18. return self:ChatDataListItemUpdateFunc(realIndex, kmlcontrol)
  19. end, function(realIndex, kmlcontrol)
  20. return self:ChatDataItemSizeGetFunc(realIndex, kmlcontrol)
  21. end)
  22. self.chat_all_item = {}
  23. end
  24. ---创建或者刷新界面数据时调用
  25. function this:Refresh()
  26. end
  27. function this:RefreshData(chat_list)
  28. self.chat_list = chat_list
  29. GUI:DataListUpdateData(self.view.chat_data_list)
  30. GUI:SetScrollView_scrollpos(self.view.chat_view,#self.chat_list-1)
  31. end
  32. ---注册UI事件和服务器消息
  33. function this:RegistEvents()
  34. --GUI:AddOnClickEvent(self.view.button_id,self,self.BtnOnClick)
  35. end
  36. function this:ChatDataListItemCountFunc()
  37. return #self.chat_list
  38. end
  39. function this:ChatDataListItemGetFunc(realIndex)
  40. local item = GUI:UIPanel_Open("dev/ui/Chat/Item/KLUIChatItem/KLUIChatItem",self.view.chat_data_list,self,{},true)
  41. self.chat_all_item[item.view.root] = item
  42. return item.view.root
  43. end
  44. function this:ChatDataListItemInitFunc(realIndex, kmlcontrol)
  45. end
  46. function this:ChatDataListItemUpdateFunc(realIndex, kmlcontrol)
  47. local data = self.chat_list[realIndex + 1]
  48. local mess = {message=data,itemIndex=realIndex + 1}
  49. self.chat_all_item[kmlcontrol]:RefreshItem(mess)
  50. end
  51. function this:ChatDataItemSizeGetFunc(realIndex)
  52. local data = self.chat_list[realIndex + 1]
  53. if not data.itemSizeFriend then
  54. local mess = {message=data,itemIndex=realIndex + 1}
  55. self.calculationUI:RefreshItem(mess)
  56. local xx,yy = GUI:getSizeDelta(self.calculationUI.view.root)
  57. data.itemSizeFriend = Vector2(xx, yy)
  58. end
  59. return data.itemSizeFriend
  60. end
  61. function this:Close()
  62. end
  63. return this