local AttrTipsCell = class("AttrTipsCell", BaseCell)

function AttrTipsCell:init()
	local uiMap = self:getUIMap()

	self.nameTxs = {}
	self.descTxs = {}
	self.lines = {}
	for i = 1, 8 do
		self.nameTxs[i] = uiMap['cell.name_tx_' .. i]
		self.descTxs[i] = uiMap['cell.desc_tx_' .. i]
		self.lines[i] = uiMap['cell.line_' .. i]
	end
end

function AttrTipsCell:refresh()
	if self.height then
		return
	end
	local offsetY = -12 - 10
	for i = 1, 8 do
		self.nameTxs[i]:setText(I18N:getGlobalText(I18N.GlobalConst["ATTR_NAME_" .. i]))
		self.descTxs[i]:setText(I18N:getGlobalText(I18N.GlobalConst["ATTR_DESC_" .. i]))

		self.nameTxs[i]:setAnchoredPositionY(offsetY)
		local meshProComp = self.nameTxs[i]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
		offsetY = offsetY - meshProComp.preferredHeight

		offsetY = offsetY - 11
		self.lines[i]:setAnchoredPositionY(offsetY)
		offsetY = offsetY - 11

		self.descTxs[i]:setAnchoredPositionY(offsetY)
		local meshProComp = self.descTxs[i]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO)
		offsetY = offsetY - meshProComp.preferredHeight
		offsetY = offsetY - 28
	end

	self.baseObject:setSizeDeltaY(-offsetY)

	self.height = -offsetY
end

function AttrTipsCell:getMaxHeight()
	return self.height
end

return AttrTipsCell