I’m making an attempt to point out a UiKit view in a SwiftUI sheet, nonetheless after I open the sheet, it’s utterly 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 essential view.
My SwiftUI part:
Button("Login") {
isShowingGoogleLogin = true
}.sheet(isPresented: $isShowingGoogleLogin, content material: {
NavigationView {
GoogleSignInViewController()
.edgesIgnoringSafeArea(.all)
.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() {
tremendous.viewDidLoad()
// Do any further 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 under button. "
guard error == nil else { return }
// If check in succeeded, show the app's essential content material View.
guard let signInResult = signInResult else { return }
let consumer = signInResult.consumer
let emailAddress = consumer.profile?.electronic 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) {
GIDSignIn.sharedInstance.signOut()
}
}