docs: SUI alerts

This commit is contained in:
Nikita Semenov 2022-07-26 13:59:25 +03:00
parent ffa66048b0
commit 34c7407ecb
2 changed files with 20 additions and 14 deletions

View File

@ -1,3 +1,21 @@
# TISwiftUICore
Core UI elements: protocols, views and helpers.
Core UI elements: protocols, views and helpers.
## SwiftUI alerts
> SwiftUI views should conform to protocol `SwiftUIAlertContext` to present alert
```swift
var body: some View {
Button("Show custom alert with binding property") {
alertDescription = factory.okAlert(title: "Title", message: "Message")
isPresentedCustomAlert = true
}
}
.alert(isPresented: $isPresentedAlert, on: self, alert: alertDescription)
}
```
# Installation via SPM
You can install this framework as a target of LeadKit.

View File

@ -132,7 +132,7 @@ Use to present alerts in a few lines of code. Can be used for UIKit and SwiftUI
> You can initialize `AlertsFactory` with your own *LocalizationProvider* or use `DefaultAlertLocalizationProvider`
## Your view or view controller must implement PresentationContext protocol
There are `UIKitAlertContext` and `SwiftUIAlertContext` protocols that are designed to make it easier to work with `AlertPresentationContext` protocol. By default, no changes need to be made for UIKit view controllers to make them conform to `UIKitAlertContext`.
There are `UIKitAlertContext` protocol that are designed to make it easier to work with `AlertPresentationContext` protocol. By default, no changes need to be made for UIKit view controllers to make them conform to `UIKitAlertContext`.
## Custom alerts
```swift
@ -189,18 +189,6 @@ func presentDialogueAlert() {
}
```
## SwiftUI alerts
```swift
var body: some View {
Button("Show custom alert with binding property") {
alertDescription = factory.okAlert(title: "Title", message: "Message")
isPresentedCustomAlert = true
}
}
.alert(isPresented: $isPresentedAlert, on: self, alert: alertDescription)
}
```
# Installation via SPM
You can install this framework as a target of LeadKit.