LeadKit/TISwiftUICore
Nikita Semenov 2245765b27 Merge branch 'master' into feature/deeplink_api
# Conflicts:
#	CHANGELOG.md
2023-03-30 15:19:27 +03:00
..
Sources feat: rebase preview extensions to new framework TIDeveloperUtils 2023-02-14 17:52:20 +03:00
README.md docs: code review notes 2022-07-27 17:37:34 +03:00
TISwiftUICore.podspec Merge branch 'master' into feature/deeplink_api 2023-03-30 15:19:27 +03:00

README.md

TISwiftUICore

Core UI elements: protocols, views and helpers.

SwiftUI alerts

SwiftUI views should conform to protocol SwiftUIAlertContext to present alerts.

This means that the view must implement the presentingViewController property. This controller is a context from which the alert will be shown.

// View that can present alerts.
struct ContentView: View, SwiftUIAlerContext {
    var presentingViewController: UIViewController

    var body: some View {
        // View realization.
    }
}

Alerts usage example

struct ContentView: View, SwiftUIAlertContext {

    private let factory = AlertFactory()

    @State private var alertDescription: AlertDescriptor
    @State private var isAlertPresented = false
    
    var presentingViewController: UIViewController

    var body: some View {
        Button("Show custom alert with binding property") {
                alertDescription = factory.okAlert(title: "Title", message: "Message")
                isAlertPresented = true
            }
        }
        .alert(isPresented: $isAlertPresented, on: self, alert: alertDescription)
    }
}

Installation via SPM

You can install this framework as a target of LeadKit.