local UIMessageBoxView = UIViewClass() local midlePosX = 0 local rightPosX = 260 local CloseAnimPath = ConstAssetPathConfig.CloseAnimPath function UIMessageBoxView:OnOpened(context) UTL.String.SetLabelContent(self.UICommonPopView.refer_Bg.txt_Title,context.title) UTL.String.SetLabelContent(self.Text_Local,context.content) self.UICommonPopView.btn_1:SetText(context.okBtnText) self.UICommonPopView.btn_2:SetText(context.cancelBtnText) self.UICommonPopView.toggle_Skip.isOn = false UIUtils.SetActive(self.UICommonPopView.refer_Bg.img_Info, false) UIUtils.SetActive(self.UICommonPopView.toggle_Skip, false) self.okCB = context.okCB self.cancelCB = context.cancelCB self.toggleCB = context.toggleCB UIUtils.SetActive(self.UICommonPopView.refer_Bg.btn_Close, true) local contentPosX, contentPosY = self.UICommonPopView.btn_1.transform:GetAnchoredPosition() if context.type == UTL.MessageBox.BoxType.OnlyOk then self.UICommonPopView.btn_2.gameObject:SetActive(false) UIUtils.SetRectPosition(self.UICommonPopView.btn_1.gameObject,midlePosX,contentPosY) elseif context.type == UTL.MessageBox.BoxType.OnlyOkNoClose then self.UICommonPopView.btn_2.gameObject:SetActive(false) UIUtils.SetRectPosition(self.UICommonPopView.btn_1.gameObject,midlePosX,contentPosY) UIUtils.SetActive(self.UICommonPopView.refer_Bg.btn_Close, false) elseif context.type == UTL.MessageBox.BoxType.OKCancel then self.UICommonPopView.btn_2.gameObject:SetActive(true) UIUtils.SetRectPosition(self.UICommonPopView.btn_1.gameObject,rightPosX,contentPosY) elseif context.type == UTL.MessageBox.BoxType.OKCancelNoClose then UIUtils.SetActive(self.UICommonPopView.btn_2, true) UIUtils.SetActive(self.UICommonPopView.refer_Bg.btn_Close, false) UIUtils.SetRectPosition(self.UICommonPopView.btn_1.gameObject,rightPosX,contentPosY) elseif context.type == UTL.MessageBox.BoxType.WithToggle then UIUtils.SetActive(self.UICommonPopView.toggle_Skip, true) UIUtils.SetRectPosition(self.UICommonPopView.btn_1.gameObject,rightPosX,contentPosY) self.UICommonPopView.toggle_Skip:SetToggleText("txt_Skip", context.toggleContent) end self.displayType = context.displayType; self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) end function UIMessageBoxView:OnBackButtonPressed() if self.context.type ~= UTL.MessageBox.BoxType.OnlyOkNoClose and self.context.type ~= UTL.MessageBox.BoxType.OKCancelNoClose then self:OnButtonClicked(self.UICommonPopView.refer_Bg.btn_Close) end end function UIMessageBoxView:OnButtonClicked(obj) if obj == self.UICommonPopView.btn_1 then if self.okCB then if self.UICommonPopView.toggle_Skip.isOn and self.toggleCB then self.toggleCB(self.UICommonPopView.toggle_Skip.isOn) end self.okCB() end self:CloseView() elseif obj == self.UICommonPopView.btn_2 then if self.cancelCB then self.cancelCB() end self:CloseView() elseif obj == self.UICommonPopView.refer_Bg.btn_Close then self:CloseView() end end function UIMessageBoxView:OnValueChanged(comp, value) if comp == self.UICommonPopView.toggle_Skip then if self.toggleCB then self.toggleCB(value) end end end function UIMessageBoxView:OnClosed() UIUtils.SetActive(self.UICommonPopView.btn_1, true) UIUtils.SetActive(self.UICommonPopView.btn_2, true) UIUtils.SetActive(self.UICommonPopView.refer_Bg.btn_Close, true) -- 在关闭界面时 将toggle 设置为false的状态 if self.toggleCB then self.toggleCB = nil end self.UICommonPopView.toggle_Skip.isOn = false UIUtils.SetActive(self.UICommonPopView.toggle_Skip, false) UTL.MessageBox.OnCloseBoxView(self.displayType) UTL.MessageBox.RecoverPostion(self.UICommonPopView) end return UIMessageBoxView