local GoldSellCell = class("GoldSellCell", BaseCell)

function GoldSellCell:init()
	local uiMap = self.baseObject:genAllChildren()
	local titleTx = uiMap["gold_sell_cell.title_bg.text"]
	titleTx:setText(ModuleManager.ItemManager:getItemName(GConst.ItemConst.ITEM_ID_GOLD))

	self.cells = {}
	self.cellHeight = 0
	local cellHeight = nil
	local cfg = DataManager.ShopData:getMallGoldConfig()
	for i = 1, 3 do
		local cell = uiMap["gold_sell_cell.cell_" .. i]
		if cellHeight == nil then
			local w, h = cell:fastGetSizeDelta()
			cellHeight = h
		end
		if cfg[i] then
			local cellComp = cell:addLuaComponent("app/ui/shop/cell/gold_cell")
			cell:setVisible(true)
			table.insert(self.cells, cellComp)
		else
			cell:setVisible(false)
		end
	end
	local totalCount = #self.cells
	if totalCount > 0 then
		self.cellHeight = self.cellHeight + (20 + cellHeight) * math.ceil(totalCount / 3) + 80
	end
end

function GoldSellCell:refresh()
	local cfg = DataManager.ShopData:getMallGoldConfig()
	for k, v in ipairs(self.cells) do
		v:refresh(k, cfg[k])
	end
end

function GoldSellCell:getCellHeight()
	return self.cellHeight
end

function GoldSellCell:getIsOpen()
	return true
end

function GoldSellCell:setVisible(visible)
	self.baseObject:setVisible(visible)
end

return GoldSellCell