修复定时器失效问题

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: "标题 + 正文") { section.add(title: "标题 + 正文") {
TestToast(.title(title).message(message)) 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: "一段长文本") { section.add(title: "一段长文本") {
// Toast(.message(message)) // Toast(.message(message))
// //

View File

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

View File

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

View File

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