local this = class("pageMountRidingInfo", G_UIPageBase)
local _petTpl = L_GameTpl:getPetTpl()
local _mountTpl = L_GameTpl:getMountTpl()

function this.bind()
  return {
    txt_name = nil,
    module_pixelPet = {
      moduleName = "pages/pet/modulePetPixelIcon"
    },
    module_moveType = {
      moduleName = "pages/mount/moduleMountMoveType"
    },
    list_condition = {
      moduleName = "pages/mount/cellMountRidingCondition"
    }
  }
end

function this.methods()
  return {
    onClick_close = function(self)
      L_UI:close(self.pageName)
    end,
    onClick_viewDetail = function(self)
      local pet = L_PetStore:getPetItem(self._petId)
      local tpl_mount = _mountTpl:getTplById(pet.id)
      L_UI:open("pageHomeLevelInfo", {
        defaultSelectItemType = L_HomeConst.HomeLevelUnlockModuleType.MountSaddle,
        defaultSelectItemId = _mountTpl:getUnlock(tpl_mount)
      })
    end
  }
end

function this:preOpen(options)
  self._petId = options.petId
  self:initPage()
end

function this:close()
end

function this:initPage()
  local pet = L_PetStore:getPetItem(self._petId)
  self.bind.txt_name = pet.pet_name
  local moduleMoveType = self.modules.module_moveType
  moduleMoveType:setData(self._petId)
  local modulePixelIcon = self.modules.module_pixelPet
  modulePixelIcon:setGuid(self._petId, true)
  local tpl_mount = _mountTpl:getTplById(pet.id)
  local unlockCondition = _mountTpl:getUnlockCondition(tpl_mount)
  local isConCompleted = L_ConditionManager:singleIsComplete(unlockCondition)
  local isItemGet, itemId = L_MountManager:getIsMountUnlock(self._petId)
  local tplData = L_ItemTplManager:getMountSaddleItem(itemId)
  local tmp = {
    {
      txt_desc = L_GameUtil.fillColor(L_ConditionManager:getSingleDesc(unlockCondition), isConCompleted and L_Const.colorHtml.green001 or L_Const.colorHtml.grey006),
      go_completed = isConCompleted
    },
    {
      txt_desc = L_GameUtil.fillColor(L_WordsTpl:getValue("petsaddle_make", {
        name = tplData.name
      }), isItemGet and L_Const.colorHtml.green001 or L_Const.colorHtml.grey006),
      go_completed = isItemGet
    }
  }
  self.bind.list_condition:clear()
  self.bind.list_condition:insert_array(tmp)
end

return this
