local this = class("cellEmotion", G_UIModuleBase)
local emojiTpl = L_GameTpl:getChatEmojiTpl()

function this:ctor(...)
  this.super.ctor(self, ...)
  self.data = {
    curFrameIndex = 1,
    maxFrame = 1,
    isAni = false
  }
end

function this.bind()
  return {
    txt_name = "",
    img_emotion = "",
    frameCountPerRow = 0,
    frameCountPerCol = 0,
    frameCount = 0,
    frameAniFps = 8,
    frameAnimParamsComplete = false,
    go_selectFrame = false,
    go_selectBg = false,
    go_numBg = false,
    txt_selectId = ""
  }
end

function this:refresh()
  if self.bind.isInPageEdit == true then
    return
  end
  local iconRectTrans = self.bindComponents.iconRectTrans
  if self.bind.isEditButton == true then
    iconRectTrans.anchorMin = C_Vector2(0.5, 0.5)
    iconRectTrans.anchorMax = C_Vector2(0.5, 0.5)
    iconRectTrans.sizeDelta = C_Vector2(137, 152)
    iconRectTrans.anchoredPosition = C_Vector2(0, 0)
    iconRectTrans.pivot = C_Vector2(0.5, 0.5)
  else
    iconRectTrans.anchorMin = C_Vector2(0.5, 1)
    iconRectTrans.anchorMax = C_Vector2(0.5, 1)
    iconRectTrans.sizeDelta = C_Vector2(154, 154)
    iconRectTrans.anchoredPosition = C_Vector2(0, 0)
    iconRectTrans.pivot = C_Vector2(0.5, 1)
  end
end

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

return this
