docs: code review notes
This commit is contained in:
parent
174d472f1b
commit
a917723dcb
|
|
@ -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 }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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?)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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?)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 { }
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Reference in New Issue