local this = class("modulePetFeed", G_UIModuleBase)

function this.bind()
  return {
    active_modulePetAttributeFruit = true,
    modulePetAttributeFruit = {
      moduleName = "pages/pet/modulePetAttributeFruit"
    },
    modulePetLevelAttributeInfo = {
      moduleName = "pages/pet/modulePetLevelAttributeInfo"
    },
    list_cellPetCultivateTab = {moduleName = ""},
    active_rootToggleModule = false,
    active_btnCultivate = true
  }
end

function this.methods()
  return {
    onClick_btnCultivate = function(self)
      self.isBeforeClickBtnCultivate = false
      self.bind.active_btnCultivate = self.isBeforeClickBtnCultivate == true
      self.bind.active_rootToggleModule = self.isBeforeClickBtnCultivate == false
    end
  }
end

function this:open()
  this.super.open(self)
  self.isBeforeClickBtnCultivate = true
  L_PetStore:listenCallFunc(L_PetStore.event.petComprehensionLvUp, self.onPetComprehensionLvUp, self)
end

function this:setShowPetGuid(petGuid)
  self.petGuid = petGuid
  local modulePetLevelAttributeInfo = self.modules.modulePetLevelAttributeInfo
  modulePetLevelAttributeInfo:setShowPetGuid(petGuid)
  local modulePetAttributeFruit = self.modules.modulePetAttributeFruit
  modulePetAttributeFruit:setInfos({petGuid = petGuid, parent = self})
end

function this:refreshUI()
  self.bind.active_btnCultivate = self.isBeforeClickBtnCultivate == true
  self.bind.active_rootToggleModule = self.isBeforeClickBtnCultivate == false
  local modulePetAttributeFruit = self.modules.modulePetAttributeFruit
  modulePetAttributeFruit:refreshUI()
  local modulePetLevelAttributeInfo = self.modules.modulePetLevelAttributeInfo
  modulePetLevelAttributeInfo:refreshUI()
end

function this:onPetExpItemSelectNumChange(selectInfo, preUseFruitInfoList)
  local modulePetLevelAttributeInfo = self.modules.modulePetLevelAttributeInfo
  modulePetLevelAttributeInfo:onPetExpItemSelectNumChange(selectInfo, preUseFruitInfoList)
end

function this:onPetAttrFruitSelectNumChange(preUseFruitInfoList)
  local modulePetLevelAttributeInfo = self.modules.modulePetLevelAttributeInfo
  modulePetLevelAttributeInfo:onPetAttrFruitSelectNumChange(preUseFruitInfoList)
end

function this:getPetGuid()
  return self.petGuid
end

function this:resetBtnCultivateClickHistory()
  self.isBeforeClickBtnCultivate = true
end

function this:close()
  L_PetStore:unListenCallFunc(L_PetStore.event.petComprehensionLvUp, self.onPetComprehensionLvUp)
end

function this:onPetComprehensionLvUp()
  self:refreshUI()
  local modulePetAttributeFruit = self.modules.modulePetAttributeFruit
  modulePetAttributeFruit:resetSelectNum()
end

function this:playPetFeedItemEffect(params)
  local modulePetLevelAttributeInfo = self.modules.modulePetLevelAttributeInfo
  modulePetLevelAttributeInfo:playPetFeedItemEffect(params)
end

return this
