docs: code review notes

This commit is contained in:
Nikita Semenov 2022-07-27 16:08:13 +03:00
parent 174d472f1b
commit a917723dcb
5 changed files with 46 additions and 2 deletions

View File

@ -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 }
}

View File

@ -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?)
}

View File

@ -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?)
}

View File

@ -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 { }

View File

@ -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 }