local this = class("cellGameActivityItem", G_UIModuleBase)

function this:created(...)
  this.super.created(self, ...)
  self.data = {
    txtColor = {
      [1] = C_LuaUtility.ParseHtmlStringColor("#446FAB"),
      [2] = C_LuaUtility.ParseHtmlStringColor("#FF1C00")
    }
  }
end

function this.bind()
  return {
    act_name = "",
    act_name_selected = "",
    show_received_icon = false
  }
end

function this.methods()
  return {
    onClick = function(self)
      if not string.isEmpty(self.bind.reddotName) then
        L_ReddotManager:clearNew(L_ReddotManager.DotDef.GameAct_New, self.bind.id)
      end
      if self.bind.show_received_icon == true then
        return
      end
      self:emit("onClick", self.bind)
    end
  }
end

function this:open()
  self.bind.act_name_selected = self.bind.act_name
  self.bindComponents.groupColor.color = math.isEmpty(self.bind.colorIndex) and self.data.txtColor[1] or self.data.txtColor[self.bind.colorIndex]
  self.bindComponents.groupColor_select.color = self.bindComponents.groupColor.color
  local reddotName = ""
  if self.bind and self.bind.reddotName then
    reddotName = self.bind.reddotName
  end
  if self.bindComponents.reddotNew then
    if string.isEmpty(reddotName) then
      self.bindComponents.reddotNew.gameObject:SetActive(false)
    else
      L_ReddotManager:registerReddot(self.bindComponents.reddotNew, reddotName)
    end
  end
end

function this:refresh()
  if self.bind.show_received_icon and not string.isEmpty(self.bind.reddotName) then
    L_ReddotManager:clearNew(L_ReddotManager.DotDef.GameAct_New, self.bind.id)
  end
end

return this
