feat: merge #282 as an unstable feature

This commit is contained in:
naturecodevoid
2023-05-20 09:51:45 -07:00
parent b6c9797104
commit 7f39d010b2
4 changed files with 57 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
//
// UIApplication+Alert.swift
// SideStore
//
// Created by naturecodevoid on 5/20/23.
// Copyright © 2023 SideStore. All rights reserved.
//
extension UIApplication {
static func alertOk(title: String?, message: String?) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("Ok", comment: ""), style: .default))
DispatchQueue.main.async {
let keyWindow = UIApplication.shared.windows.filter { $0.isKeyWindow }.first
if var topController = keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
topController.present(alert, animated: true)
} else {
print("No key window!")
}
}
}
}