11import SwiftUI
22import UIKit
33
4- @MainActor
54public final class SWAlert {
65 public static let shared = SWAlert ( )
76 private var currentAlert : UIViewController ?
@@ -13,25 +12,27 @@ public final class SWAlert {
1312 /// - message: Текст сообщения
1413 /// - closeButtonTitle: Заголовок кнопки для закрытия алерта
1514 /// - closeButtonStyle: Стиль кнопки для закрытия алерта
16- public func presentDefaultUIKit(
15+ public nonisolated func presentDefaultUIKit(
1716 title: String ? = " " ,
1817 message: String ,
1918 closeButtonTitle: String = " Ok " ,
2019 closeButtonStyle: UIAlertAction . Style = . default
2120 ) {
22- guard currentAlert == nil , let topMostViewController else { return }
23- let alert = UIAlertController ( title: title, message: message, preferredStyle: . alert)
24- alert. addAction (
25- . init(
26- title: closeButtonTitle,
27- style: closeButtonStyle,
28- handler: { [ weak self] _ in
29- self ? . dismiss ( )
30- }
21+ Task { @MainActor in
22+ guard currentAlert == nil , let topMostViewController else { return }
23+ let alert = UIAlertController ( title: title, message: message, preferredStyle: . alert)
24+ alert. addAction (
25+ . init(
26+ title: closeButtonTitle,
27+ style: closeButtonStyle,
28+ handler: { [ weak self] _ in
29+ self ? . dismiss ( )
30+ }
31+ )
3132 )
32- )
33- currentAlert = alert
34- topMostViewController . present ( alert , animated : true )
33+ currentAlert = alert
34+ topMostViewController . present ( alert, animated : true )
35+ }
3536 }
3637
3738 /// Показывает стандартный алерт с сообщение об ошибке
@@ -52,7 +53,7 @@ public final class SWAlert {
5253 /// - Parameter isConnected: Состояние подключения к сети
5354 /// - Returns: `true` - нужно показать алерт (нет сети), `false` - алерт не нужен (сеть есть)
5455 @discardableResult
55- public func presentNoConnection( _ isConnected: Bool ) -> Bool {
56+ public nonisolated func presentNoConnection( _ isConnected: Bool ) -> Bool {
5657 let showAlert = !isConnected
5758 if showAlert {
5859 presentDefaultUIKit (
0 commit comments