local module = class("moduleButtonSingle", G_UIModuleBase)

function module.bind()
  return {
    txt_name = "",
    txt_nameEn = "",
    activeBg = true,
    txt_alpha = 1,
    btn_interactable = true
  }
end

function module.methods()
  return {
    onClick = function(self)
      if self._callback then
        self._callback()
      end
    end
  }
end

function module:setData(txtName, callback, params)
  params = params or {}
  if params.nameTxtColor then
    txtName = L_GameUtil.fillColor(txtName, params.nameTxtColor)
  end
  self.bind.txt_name = txtName or ""
  self.bind.txt_nameEn = L_DecorateTpl:getDecoEnglish(txtName) or "DEFAULT"
  self._callback = callback
  if params.txtNum then
    local item = L_ItemTplManager:getItemConfig(params.itemType, params.itemId)
    self.bind.image_icon = item.smallIcon or item.icon
    if type(params.txtNum) == "number" and L_ItemTplManager:getItemNum(params.itemType, params.itemId) < params.txtNum then
      self.bind.txt_num = L_GameUtil.fillColor(params.txtNum, "#FFA6A6")
    else
      self.bind.txt_num = tostring(params.txtNum)
    end
  end
  self.bind.activeBg = L_CommonUtil.toBoolean(params.activeBg)
  if self.bind.txt_alpha then
    self.bind.txt_alpha = params.nameTxtAlpha or 1
  end
  if params.btnInteractable == nil then
    self.bind.btn_interactable = true
  else
    self.bind.btn_interactable = params.btnInteractable
  end
end

return module
