title: Add google Sign-In with SwiftUI
body: <p>I am trying to add google sign-in with swiftUI whith UIKitViewController, and for some reason I have difficulties showing the button does not appear in style</p>
  
  <p>The signIn and the button works perfect but at some point the style of the button stopped appearing</p>
  
  <p>I'm adding the button in a uikit viewcontroller, because I couldn't think of another way to handle the Google delegate </p>
  
  <p>Here's the preview <a href="https://ibb.co/tYhx62b" rel="noreferrer">https://ibb.co/tYhx62b</a></p>
  
  <pre><code>//
  //  GoogleSignInButtonView.swift
  //
  //  Created by Ivan Schaab on 11/09/2019.
  //  Copyright © 2019 Ivan Schaab. All rights reserved.
  //
  import GoogleSignIn
  import SwiftUI
  
  struct GoogleSignInButtonView: View {
  
      @EnvironmentObject var lvm: LoginViewModel
  
      var body: some View {
          HStack {
              Spacer()
              GoogleButtonViewControllerRepresentable { (token, user) in
                  // Google Login Success
                  // Now do Backend Validations
                  self.lvm.loginOauth(token: token, user: user)
              }
              Spacer()
          }.frame(alignment: .center)
      }
  }
  
  class GoogleButtonUIKitViewController: UIViewController {
  
      var signInButton = GIDSignInButton()
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          GIDSignIn.sharedInstance().clientID = Constants.GOOGLE_CLIENT_ID
          self.view.addSubview(signInButton)
  
          GIDSignIn.sharedInstance()?.presentingViewController = self
  
          // Automatically sign in the user.
          GIDSignIn.sharedInstance()?.restorePreviousSignIn()
      }
  }
  
  struct GoogleButtonViewControllerRepresentable: UIViewControllerRepresentable
  {
      let vc = GoogleButtonUIKitViewController()
      var googleResponse: (String, User) -&gt; Void
  
      func makeUIViewController(context: Context) -&gt; GoogleButtonUIKitViewController {
          return vc
      }
      func updateUIViewController(_ uiViewController: GoogleButtonUIKitViewController, context: Context) {}
      func makeCoordinator() -&gt; Coordinator {
          Coordinator(vc: vc, googleResponse: googleResponse)
      }
  
      static func dismantleUIViewController(_ uiViewController: GoogleButtonUIKitViewController, coordinator: GoogleButtonViewControllerRepresentable.Coordinator) {
          print("DISMANTLE")
      }
  
      class Coordinator: NSObject, GIDSignInDelegate  {
          var foo: (String, User) -&gt; Void
          init(vc: GoogleButtonUIKitViewController, googleResponse: @escaping (String, User) -&gt; Void) {
              self.foo = googleResponse
              super.init()
              GIDSignIn.sharedInstance()?.delegate = self
          }
  
          func sign(_ signIn: GIDSignIn!, didSignInFor googleUser: GIDGoogleUser!, withError error: Error!) {
              if let error = error {
                  if (error as NSError).code == GIDSignInErrorCode.hasNoAuthInKeychain.rawValue {
                      print("The user has not signed in before or they have since signed out.")
                  } else {
                      print("\(error.localizedDescription)")
                  }
                  return
              }
  //            let userId = googleUser.userID                  // For client-side use only!
              let idToken = googleUser.authentication.idToken // Safe to send to the server
              let email = googleUser.profile.email
  
              if googleUser.profile.hasImage{
                  let imageUrl = googleUser.profile.imageURL(withDimension: 120)
                  print(" image url: ", imageUrl?.absoluteString ?? "NO URL")
              }
  
              let user : User = User(id: 1, name: googleUser.profile.givenName, surname: googleUser.profile.familyName, imgName: ""  , email: googleUser.profile.email)
  
              print("email: ",email ?? "NO EMAIL")
  
              foo(idToken! , user)
          }
      }
  }
  
  
  
  #if DEBUG
  struct SomeRepView_Previews: PreviewProvider {
      static var previews: some View {
          GoogleSignInButtonView().environmentObject(LoginViewModel())
      }
  }
  #endif
  </code></pre>