diff --git a/TISwiftUICore/Sources/Alerts/Protocols/SwiftUIAlertContext.swift b/TISwiftUICore/Sources/Alerts/Protocols/SwiftUIAlertContext.swift index d490bef4..b9585f52 100644 --- a/TISwiftUICore/Sources/Alerts/Protocols/SwiftUIAlertContext.swift +++ b/TISwiftUICore/Sources/Alerts/Protocols/SwiftUIAlertContext.swift @@ -24,7 +24,20 @@ import TISwiftUtils import TIUIKitCore import UIKit +/// A SwiftUI context from where the alert can be presented. +/// +/// ``` +/// // View that can present alerts. +/// struct ContentView: View, SwiftUIAlerContext { +/// var presentingViewController: UIViewController +/// +/// var body: some View { +/// // View realization. +/// } +/// } +/// ``` public protocol SwiftUIAlertContext: AlertPresentationContext { + /// A view controller that represents a context from which the alert will be shown. var presentingViewController: UIViewController { get set } } diff --git a/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentable.swift b/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentable.swift index 163177a5..e042b953 100644 --- a/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentable.swift +++ b/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentable.swift @@ -22,7 +22,29 @@ import TISwiftUtils -/// A protocol represents an alert which can be presented on the given context +/// A protocol represents an alert which can be presented on the given context. +/// +/// ```import PopupDialog +/// +/// extension PopupDialog: AlertPresentable { +/// @discardableResult +/// public func configured(with configuration: AlertDescriptor) -> Self { +/// title = configuration.title +/// +/// for action in configuration.actions { +/// addButton(DefaultButton(title: action.title, action: action.action)) +/// } +/// +/// return self +/// } +/// +/// public func present(on context: AlertPresentationContext, completion: VoidClosure?) { +/// context.present(self, animated: true, completion: completion) +/// } +/// } +/// ``` +/// +/// The implementation of this protocol says that an alert can be shown from the context. By default, the standard `UIAlertController` conforms to the protocol. Accordingly, when using a custom alert, it must also conform to the protocol. public protocol AlertPresentable { func present(on context: AlertPresentationContext, completion: VoidClosure?) } diff --git a/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentationContext.swift b/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentationContext.swift index 72dd720d..377a4086 100644 --- a/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentationContext.swift +++ b/TIUIKitCore/Sources/Alerts/Protocols/AlertPresentationContext.swift @@ -23,7 +23,7 @@ import TISwiftUtils import UIKit -/// A context from where the alert can be presented +/// A context from where the alert can be presented. public protocol AlertPresentationContext { func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: VoidClosure?) } diff --git a/TIUIKitCore/Sources/Alerts/Protocols/UIKitAlertContext.swift b/TIUIKitCore/Sources/Alerts/Protocols/UIKitAlertContext.swift index 3652242b..342f9a32 100644 --- a/TIUIKitCore/Sources/Alerts/Protocols/UIKitAlertContext.swift +++ b/TIUIKitCore/Sources/Alerts/Protocols/UIKitAlertContext.swift @@ -20,4 +20,12 @@ // THE SOFTWARE. // +/// An UIKit context from where the alert can be presented. +/// +/// ``` +/// // View controller that can present alerts. +/// class ViewController: UIViewController, UIKitAlerContext { +/// // Realization of the view controller +/// } +/// ``` public protocol UIKitAlertContext: AlertPresentationContext { } diff --git a/TIUIKitCore/Sources/Localization/AlertsLocalization/AlertLocalizationProvider.swift b/TIUIKitCore/Sources/Localization/AlertsLocalization/AlertLocalizationProvider.swift index 98795b27..85fb451a 100644 --- a/TIUIKitCore/Sources/Localization/AlertsLocalization/AlertLocalizationProvider.swift +++ b/TIUIKitCore/Sources/Localization/AlertsLocalization/AlertLocalizationProvider.swift @@ -20,6 +20,7 @@ // THE SOFTWARE. // +/// A provider of localization for common buttons' titles of the alerts. public protocol AlertLocalizationProvider { var okTitle: String { get } var cancelTitle: String { get }