local this = {}
local _PrePetFavorableTipPath = "Program/FlyMsg/pre_petFavorable.prefab"
local _PrePetFavorableTipModulePath = "ui.manager.flyMsg.modulePetFavorable"

function this:initPetFavorableTip()
end

function this:showHomePetFavorableTip(popup)
  local priorityShowData = require("ui.manager.priorityShowQueue.flyMsgPriorityShowData").new({
    flyMsgType = L_ShowQueueConst.flyMsgType.petFavorable,
    uuid = self:getNextUniqueId(),
    params = {popup}
  })
  L_PriorityShowQueueManager:addPriorityShowData(priorityShowData)
end

function this:rawShowHomePetFavorableTip(uuid, popup)
  popup._uuid = uuid
  self:doHomePetFavorableTip(popup)
end

function this:doHomePetFavorableTip(popup)
  if popup == nil then
    return
  end
  if not self.homePetFavorableTipModule then
    self.homePetFavorableTipModule = require(_PrePetFavorableTipModulePath).new(G_UIModuleBase.ModuleType.Dynamic)
    self.homePetFavorableTipModule:created()
    local _end = function(go)
      self.homePetFavorableTip = go
      local trans = go.transform
      trans:Reset(self.leftRoot)
      trans.localScale = Unity.Vector3.one
      self.homePetFavorableTipModule:toBind(go:GetComponent(typeof(C_UIBinding)))
      self.homePetFavorableTipModule:setCloseCallBack(handler(self, self.onHomePetFavorableTipClose))
      self:doHomePetFavorableTip(popup)
    end
    self.pool:asyncSpawn(_PrePetFavorableTipPath, _end)
  else
    self.homePetFavorableTipModule:open(popup)
  end
end

function this:onHomePetFavorableTipClose(popup)
  self:sendEvent(self.event.flyMsgPopupEnd, L_ShowQueueConst.flyMsgType.petFavorable, popup._uuid)
end

function this:disposeHomePetFavorableTip()
  if self.homePetFavorableTipModule then
    self.homePetFavorableTipModule:unBind()
    self.homePetFavorableTipModule:disposeUIBinding()
    self.homePetFavorableTipModule = nil
  end
end

return this
