修复定时器失效问题

This commit is contained in:
xaoxuu 2023-09-19 19:51:46 +08:00
parent 17b46e7ed9
commit a77f1a4356
4 changed files with 15 additions and 0 deletions

View File

@ -118,6 +118,12 @@ class DemoToastVC: ListVC {
section.add(title: "标题 + 正文") {
TestToast(.title(title).message(message))
}
section.add(title: "防止重复") {
TestToast(.identifier("toast").title(title).message(message).duration(2))
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
TestToast(.identifier("toast").title(title).message(message).duration(2))
}
}
section.add(title: "一段长文本") {
// Toast(.message(message))
//

View File

@ -73,8 +73,12 @@ open class AlertTarget: BaseController, HUDTargetType {
///
@objc public var vm: AlertViewModel? {
willSet {
vm?.cancelTimer()
}
didSet {
vm?.vc = self
vm?.restartTimer()
}
}

View File

@ -48,6 +48,7 @@ open class CapsuleTarget: BaseController, HUDTargetType {
}
didSet {
vm?.vc = self
vm?.restartTimer()
}
}

View File

@ -83,8 +83,12 @@ open class ToastTarget: BaseController, HUDTargetType {
///
@objc public var vm: ToastViewModel? {
willSet {
vm?.cancelTimer()
}
didSet {
vm?.vc = self
vm?.restartTimer()
}
}