How to add textfield to an alert

hi, I have this alert in SwiftUI in my some view. how do I add a textfield to the alert, return the string. All the places I have tried to find an answer, they uses a func. Do I need to do that as well?


            .alert(isPresented: $showAlert) {

                Alert(title: Text("Login"), message: Text("Type in your password"), primaryButton: .destructive(Text("Cancel")), secondaryButton: .default(Text("Login")))

You should to do it in UIKit, then use UIViewControllerRepresentable:

https://swiftuirecipes.com/blog/swiftui-alert-with-textfield

How to add textfield to an alert
 
 
Q