local this = class("cellReleaseFilterOption", G_UIModuleBase)
local ActiveColor = C_Color(1, 1, 1, 1)
local NormalColor = C_Color(0, 0, 0, 0.3)
local petReleaseSubtypeTpl = L_GameTpl:getPetReleaseSubtypeTpl()

function this.bind()
  return {
    go_icon = true,
    img_icon = nil,
    color_icon = ActiveColor,
    txt_name = "",
    go_active = false,
    go_sortIndex = false,
    txt_sortIndex = ""
  }
end

function this.methods()
  return {
    onClick_select = function(self)
      self:emit("onClick_select", self.bind.subId)
    end
  }
end

function this:refresh()
  if not self.isBind then
    return
  end
  local tpl = petReleaseSubtypeTpl:getTplById(self.bind.subId)
  self.bind.name = petReleaseSubtypeTpl:getName(tpl)
  self:setActive(self.bind.go_active)
end

function this:setActive(active)
  self.bind.go_active = active
  local txtColor = active and L_Const.colorHtml.white001 or L_Const.colorHtml.grey003
  self.bind.txt_name = L_GameUtil.fillColor(self.bind.name, txtColor)
  self.bind.go_icon = not active
  self.bind.color_icon = active and ActiveColor or NormalColor
end

function this:setSortIndex(active, index)
  self.bind.go_sortIndex = active
  self.bind.txt_sortIndex = tostring(index)
  self.bind.go_icon = not active
end

return this
