Visual_Novel_iOS/crush/Crush/Src/Components/UI/Dialog/DialogPopUpManager.swift

43 lines
1.3 KiB
Swift
Raw Normal View History

2025-10-09 10:29:35 +00:00
//
// DialogPopUpManager.swift
// Crush
//
// Created by Leon on 2025/7/14.
//
import Foundation
class DialogPopUpManager{
public static let shared = DialogPopUpManager()
lazy var toBeHandleMaskPopControllers: [BaseMaskPopDialogController] = []
public func disableSubsequentPopDialogs(){
toBeHandleMaskPopControllers.removeAll()
}
func continueDialogIfHave() {
if !toBeHandleMaskPopControllers.isEmpty {
var popVc = toBeHandleMaskPopControllers.first!
// Find the dialog with the highest priority, optionally restricted to a specific class
for vc in toBeHandleMaskPopControllers {
if vc.priority > popVc.priority {
if let onlyShowInClass = vc.onlyshowInClass, !UIWindow.getTopViewController()!.isKind(of: onlyShowInClass) {
// Skip if the current VC is not of the required class
} else {
popVc = vc
}
}
}
popVc.resetPopController()
popVc.show()
}
}
func delayToContinueDialog() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
self.continueDialogIfHave()
}
}
}