local this = {}
local _PreTaskTipPath = "Program/FlyMsg/pre_taskTip.prefab"
local _TaskTipModulePath = "ui.manager.flyMsg.moduleTaskTip"

function this:showTaskTip(taskId, isOver, callBack)
  local priorityShowData = require("ui.manager.priorityShowQueue.flyMsgPriorityShowData").new({
    flyMsgType = L_ShowQueueConst.flyMsgType.taskTip,
    uuid = self:getNextUniqueId(),
    params = {
      {
        taskId = taskId,
        callBack = callBack,
        isOver = isOver
      }
    }
  })
  L_PriorityShowQueueManager:addPriorityShowData(priorityShowData)
end

function this:rawShowTaskTip(uuid, popup)
  popup._uuid = uuid
  self:doShowTaskTip(popup)
end

function this:doShowTaskTip(popup)
  if popup == nil then
    return
  end
  if not self.taskTipModule then
    self.goHandle = C_LuaUtility.InstantiateSync(_PreTaskTipPath, self.root)
    self.taskTipModule = require(_TaskTipModulePath).new(G_UIModuleBase.ModuleType.Static)
    self.taskTipModule:created()
    local go = self.goHandle.gameObject
    local trans = go.transform
    L_Vector3.setAnchored(trans, {x = 0, y = 0})
    self.taskTipModule:toBind(go:GetComponent(typeof(C_UIBinding)))
    self.taskTipModule:setCloseCB(handler(self, self.onTaskTipClose))
  end
  self.taskTipModule:open(popup)
end

function this:onTaskTipClose(popup)
  if popup.callBack then
    popup.callBack()
  end
  self:sendEvent(self.event.flyMsgPopupEnd, L_ShowQueueConst.flyMsgType.taskTip, popup._uuid)
end

function this:disposeTaskTip()
  if self.taskTipModule then
    self.taskTipModule:unBind()
    self.taskTipModule = nil
  end
  if self.goHandle then
    C_LuaUtility.DestroyObject(self.goHandle)
  end
end

return this
