local UIDyeAppearanceGain = UIViewClass() local Const_Duration = 8 function UIDyeAppearanceGain:OnOpened(context) self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) self.duration = Const_Duration CTL.DyeAppearance.SetColorItemTemplate(self.item, context.colorCfg, false, false, false, false) UIUtils.SetActive(self.labLocal_Timer, true) UIUtils.SetLabel(self.labLocal_Timer, string.FormatByIdsId(Const_IDS.IDS_Item_GetUI_TimeOut, math.ceil(self.duration))) self:StartRepeatFunc(self.OnUpdateFun, 1) CTL.Sound.PlayGameSound("UI_congratulation") end function UIDyeAppearanceGain:OnUpdateFun(deltaTime, timeSinceUpdate) if timeSinceUpdate > self.duration then self:CloseView() else UIUtils.SetLabel(self.labLocal_Timer, string.FormatByIdsId(Const_IDS.IDS_Item_GetUI_TimeOut, math.ceil(self.duration - timeSinceUpdate))) end end function UIDyeAppearanceGain:OnButtonClicked(obj) if obj == self.event_Bottom then self:CloseView() end end return UIDyeAppearanceGain