local this = class("cellCollectionPreview", G_UIModuleBase)
local _productsTpl = L_GameTpl:getProductsCollectionTpl()
local _productsCollectionTypeTpl = L_GameTpl:getProductsCollectionTypeTpl()
local qualityColor = {
  [1] = "#A0AEB7",
  [2] = "#27AE89",
  [3] = "#3AB3FF",
  [4] = "#A264FF",
  [5] = "#FFBF35"
}

function this.bind()
  return {
    img_icon = nil,
    txt_name = nil,
    txt_desc = nil,
    go_lock = false,
    color_lock = C_Color(1, 1, 1, 1),
    go_rare = false,
    img_rare = nil,
    go_line = false,
    go_mask = false,
    canvasGroup = 1
  }
end

function this.methods()
  return {
    onClick_icon = function(self)
      L_ItemTplManager:showInfoTip(self.bind.itemType, self.bind.itemId)
    end,
    onClick_name = function(self)
      L_ItemTplManager:showInfoTip(self.bind.itemType, self.bind.itemId)
    end
  }
end

function this:open()
  if self.isBind and not string.isEmpty(self.bind.name) then
    local txt = self.bind.name
    if string.len(txt) > 15 then
      txt = string.format("%s...", string.sub(txt, 1, 15))
    end
    self.bind.txt_name = txt
  end
end

function this:refresh()
end

function this:setMaskActive(active)
  if self.bind.go_rare and self.bind.go_lock then
    self.bind.go_mask = active
  end
end

return this
