iOS Development

ios – Displaying a UIKit View in a SwiftUI sheet

Spread the love

I’m attempting to indicate a UiKit view in a SwiftUI sheet, nevertheless after I open the sheet, it’s fully empty, not one of the UIKit parts present up. All I can see is the navigation view bar title. I’ve positioned the UIKit part right into a UIViewController in order that I can show it in my predominant view.

My SwiftUI part:

Button("Login") {
    isShowingGoogleLogin = true
}.sheet(isPresented: $isShowingGoogleLogin, content material: {
    NavigationView {
            .navigationBarTitle("Google Signal In")

And my UIKit view:

import Basis
import UIKit
import GoogleSignIn
import SwiftUI

struct GoogleSignInViewController: UIViewControllerRepresentable {
    func makeUIViewController(context: Context) -> ViewController {
        return ViewController()
    func updateUIViewController(_ uiViewController: ViewController, context: Context) {}

class ViewController: UIViewController {
    //MARK:  @IBOutlet
    @IBOutlet weak var btnGoogleSignIn: UIButton!
    @IBOutlet weak var btnGoogleSignOut: UIButton!
    @IBOutlet weak var lblSignInStatus: UILabel!
    //MARK: viewDidLoad
    override func viewDidLoad() {
        // Do any extra setup after loading the view.

//MARK: @IBAction
extension ViewController {
    @IBAction func btnGoogleSingInDidTap(_ sender: Any) {
        GIDSignIn.sharedInstance.signIn(withPresenting: self) { signInResult, error in
            self.btnGoogleSignIn.isHidden = false
            self.btnGoogleSignOut.isHidden = true
            self.lblSignInStatus.textual content = "Welcome To GoogleSignIn! To proceed with GoogleSignIn please hit beneath button. "
            guard error == nil else { return }

          // If sign up succeeded, show the app's predominant content material View.
            guard let signInResult = signInResult else { return }
            let consumer = signInResult.consumer

            let emailAddress = consumer.profile?.e-mail
            let fullName = consumer.profile?.identify
            let familyName = consumer.profile?.familyName
            let profilePicUrl = consumer.profile?.imageURL(withDimension: 320)
            self.lblSignInStatus.textual content = "Hi (fullName ?? "")"
            self.btnGoogleSignIn.isHidden = true
            self.btnGoogleSignOut.isHidden = false
    @IBAction func btnGoogleSignOutDidTap(_ sender: Any) {

2 thoughts on “ios – Displaying a UIKit View in a SwiftUI sheet

Leave a Reply

Your email address will not be published. Required fields are marked *