local NoticeView = {} local M = NoticeView function NoticeView.new(blur_view) setmetatable(M, {__index = BaseWindow}) local self = setmetatable({}, {__index = M}) self.class = "NoticeView" -- self._blur_view = blur_view self:init("ui://Lobby/pop_notice") return self end function M:init(url) BaseWindow.init(self,url) self._close_destroy = true self._close_zone = true end function M:FillData(data) if not data then return end self._notices = data local list = self._view:GetChild("list") for i = 1, #data do local info = data[i] local item = list:AddItemFromPool() item:GetChild("title").text = info.name if info.type == "NEW" then item:GetChild("icon").url = "ui://27vd145bildu7e" elseif info.type == "ACTIVITY" then item:GetChild("icon").url = "ui://27vd145bildu74" else item:GetChild("icon").url = "" end item.onClick:Add(function() self:ShowIndex(i) end) end list.selectedIndex = 0 self:ShowIndex(1) end function M:ShowIndex(index) local title = self._view:GetChild("tex_title") local pic = self._view:GetChild("img") local content = self._view:GetChild("com_content"):GetChild("tex_content") local notices = self._notices if index <= #notices then title.text = notices[index].title content.text = notices[index].content end -- pic.text = "" -- pic.text = "" -- print(pic.text) end function M:Destroy(flag) -- ImageLoad.Clear(self.class) BaseWindow.Destroy(self, flag) end return M