How can I present a UIKit PopUp ViewController in SWiftUI
in UIKit we do it like under
let controller = PopupVC(title: "Alert", description: "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim advert minim veniam", icon: nil, buttonTitle: "Shut")
controller.modalPresentationStyle = .overFullScreen
controller.modalTransitionStyle = .crossDissolve
self.current(controller, animated: true)
how can we do the identical in SwiftUI? I’m making an attempt it like under
struct ContentView: View {
@State personal var isShowingPopup = false
var physique: some View {
ZStack {
Colour.yellow.opacity(0.5)
.ignoresSafeArea()
Button(motion: {
isShowingPopup.toggle()
}) {
Textual content("Click on Me")
.font(.system(dimension: 15))
.foregroundColor(.white)
.body(minWidth: 0, maxWidth: .infinity)
.padding()
.background(Colour(hex: "1775FF"))
.cornerRadius(8)
}
.padding()
}
.fullScreenCover(isPresented: $isShowingPopup) {
PopupVC(title: "Alert", description: "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim advert minim veniam", icon: nil, buttonTitle: "Shut").preview()
}
}
}
The place preview is UIViewController extension
//MARK: UIViewController
extension UIViewController {
func preview() -> some View {
struct Wrapper: UIViewControllerRepresentable {
typealias UIViewControllerType = UIViewController
let viewController: UIViewController
func makeUIViewController(context: Context) -> UIViewController {
viewController
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
return Wrapper(viewController: self)
.edgesIgnoringSafeArea(.all)
}
}
However it doesn’t apply modalPresentationStyle
and modalTransitionStyle
to .overFullScreen
and .crossDissolve
respectively.
obtain this?
listed here are the top outcomes I get.