Using signin with apple button without view (in .sheet(isPresented))

Hi everyone!
I’m trying to make sign in with apple by guide on this official instructions
But in my app all sign in methods looks like this & works perfect! Working code below.

import SwiftUI
import GoogleSignIn
import Firebase

struct GoogleAuthView: UIViewRepresentable {
    
    @Binding var showAnimation: Bool
    @Binding var showSheet: Bool
    
    
    init(showAnimation: Binding<Bool>, showSheet: Binding<Bool>) {
        self._showAnimation = showAnimation
        self._showSheet = showSheet
    }
    
    func makeCoordinator() -> GoogleAuthView.Coordinator {
        return GoogleAuthView.Coordinator(showAnimation: self.$showAnimation, showSheet: self.$showSheet)
    }
    
    class Coordinator: NSObject, GIDSignInDelegate {
        
        @Binding var showAnimation: Bool
        @Binding var showSheet: Bool
        
        init(showAnimation: Binding<Bool>, showSheet: Binding<Bool>) {
            self._showAnimation = showAnimation
            self._showSheet = showSheet
        }
        
        
        
        func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
            if let error = error {
                print(error.localizedDescription)
                return
            }
            
            guard let authentication = user.authentication else {
                return
                
            }
            self.showAnimation = true
            self.showSheet = false
            let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
                                                           accessToken: authentication.accessToken)
            Auth.auth().signIn(with: credential) { (authResult, error) in
                if let error = error, (error as NSError).code == AuthErrorCode.credentialAlreadyInUse.rawValue {
                    Auth.auth().signIn(with: credential) { result, error in
                        // continue
                        print("signIn result: " + authResult!.user.email!)
                        if let token = firebaseRegistrationPushToken {
                            checkUserAuthSettings(pushToken: token)
                        }
                    }
                } else {
                    // continue
                    print("Facebook Sign In")
                    if let token = firebaseRegistrationPushToken {
                        checkUserAuthSettings(pushToken: token)
                    }
                }

            }
            
        }
    }
    
    func makeUIView(context: UIViewRepresentableContext<GoogleAuthView>) -> GIDSignInButton {
        let view = GIDSignInButton()
        GIDSignIn.sharedInstance().delegate = context.coordinator
        GIDSignIn.sharedInstance()?.presentingViewController = UIApplication.shared.windows.last?.rootViewController
        return view
    }
    
    func updateUIView(_ uiView: GIDSignInButton, context: UIViewRepresentableContext<GoogleAuthView>) { }
}
Please! Help me co convert below code (sign in with apple) like demo code upper. Because now a have switch all 3td part methods off( 
import Foundation
import SwiftUI
import AuthenticationServices
import CryptoKit
import Firebase

struct SignInWithAppleButton: UIViewRepresentable {
    
    func makeUIView(context: Context) -> ASAuthorizationAppleIDButton {
        return ASAuthorizationAppleIDButton(type: .signIn, style: .black)
    }
    
    func updateUIView(_ uiView: ASAuthorizationAppleIDButton, context: Context) {
    }
}


class signInWithAppleCoordinator:NSObject, ASAuthorizationControllerPresentationContextProviding {
    
    private var onSignedIn: (() -> Void)?
    
    func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
        return UIApplication.shared.windows.first!
    }
    

    // Unhashed nonce.
    fileprivate var currentNonce: String?

    @available(iOS 13, *)
    func startSignInWithAppleFlow(onSignedIn:@escaping() ->Void ) {
        self.onSignedIn = onSignedIn
      let nonce = randomNonceString()
      currentNonce = nonce
      let appleIDProvider = ASAuthorizationAppleIDProvider()
      let request = appleIDProvider.createRequest()
      request.requestedScopes = [.fullName, .email]
      request.nonce = sha256(nonce)

      let authorizationController = ASAuthorizationController(authorizationRequests: [request])
      authorizationController.delegate = self
      authorizationController.presentationContextProvider = self
      authorizationController.performRequests()
    }

    @available(iOS 13, *)
    private func sha256(_ input: String) -> String {
      let inputData = Data(input.utf8)
      let hashedData = SHA256.hash(data: inputData)
      let hashString = hashedData.compactMap {
        return String(format: "%02x", $0)
      }.joined()

      return hashString
    }
}

@available(iOS 13.0, *)
extension signInWithAppleCoordinator: ASAuthorizationControllerDelegate {

  func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
    if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
      guard let nonce = currentNonce else {
        fatalError("Invalid state: A login callback was received, but no login request was sent.")
      }
      guard let appleIDToken = appleIDCredential.identityToken else {
        print("Unable to fetch identity token")
        return
      }
      guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else {
        print("Unable to serialize token string from data: \(appleIDToken.debugDescription)")
        return
      }
      // Initialize a Firebase credential.
        
      let credential = OAuthProvider.credential(withProviderID: "apple.com",
                                                idToken: idTokenString,
                                                rawNonce: nonce)
        Auth.auth().currentUser?.link(with: credential, completion: { (authresult, error) in
            //фиксируем ошибку при заходе с разных поставщиков на тот же ящик
            if let error = error, (error as NSError).code == AuthErrorCode.credentialAlreadyInUse.rawValue {
                print("The user you're trying to sign in with has already been linked")
                if let updatedCredential = (error as NSError).userInfo[AuthErrorUserInfoUpdatedCredentialKey] as? OAuthCredential {
                    print("Signing in with using updating credentials")
                    Auth.auth().signIn(with: updatedCredential) { (authResult, error) in
                        if let user = authResult?.user {
                            if let callback = self.onSignedIn {
                                callback()
                            }
                            
                        }
                    }
                }
            }
            else {
                if let callback = self.onSignedIn {
                    callback()
                }
            }
        })
    }
  }

  func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
    // Handle error.
    print("Sign in with Apple errored: \(error)")
  }

}

// Adapted from https://auth0.com/docs/api-auth/tutorials/nonce#generate-a-cryptographically-random-nonce
private func randomNonceString(length: Int = 32) -> String {
  precondition(length > 0)
  let charset: Array<Character> =
      Array("0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._")
  var result = ""
  var remainingLength = length

  while remainingLength > 0 {
    let randoms: [UInt8] = (0 ..< 16).map { _ in
      var random: UInt8 = 0
      let errorCode = SecRandomCopyBytes(kSecRandomDefault, 1, &random)
      if errorCode != errSecSuccess {
        fatalError("Unable to generate nonce. SecRandomCopyBytes failed with OSStatus \(errorCode)")
      }
      return random
    }

    randoms.forEach { random in
      if remainingLength == 0 {
        return
      }

      if random < charset.count {
        result.append(charset[Int(random)])
        remainingLength -= 1
      }
    }
  }

  return result
}

struct SignInWithAppleView: View {
    @EnvironmentObject var session: SessionStore
    
    @Environment (\.presentationMode) var presentationMode
    @State var coordinator: signInWithAppleCoordinator?
    var body: some View {
        VStack {
            SignInWithAppleButton()
                .frame(height: 45)
                .padding(.horizontal)
                .onTapGesture {
                    self.coordinator = signInWithAppleCoordinator()
                    if let coordinator = self.coordinator {
                        coordinator.startSignInWithAppleFlow {
                            print("You successfuly signed in with apple")
                            self.presentationMode.wrappedValue.dismiss()
                        }
                    }
                }
        }
    }
}

and what is the problem/question?

i mean without view, with coordinator only
to use same variables like my working code

Question is how to make same like GoogleAuthView.
I’m confusing at all.
If you can - please help me to make SignInWithAppleButton like GoogleAuthView.
I am desperate and cannot solve this problem for a week…

i need to add variables & functions like on demo
I need this variables and functions on signinwith apple
so as you can see - there is no View in facebook, only Coordinator.
So i need the same.

@Binding var showAnimation: Bool
@Binding var showSheet: Bool


init(showAnimation: Binding<Bool>, showSheet: Binding<Bool>) {
    self._showAnimation = showAnimation
    self._showSheet = showSheet
}

are you part of the CWC+ program? on the ios Bento section theres a small tutorial on how to do a simple “sign in with apple” solution, i think what you are making for the coordinator is a bit complicated

not yet, Francis, but i cab purchase it ,if it can help. Simple way will not can help me, i can do this by my self, i need exactly coordinator…

you made sure to enable “sign in with apple” capability to your project right?

on that note its locked behind the apple developer paywall (the $99 apple developer membership thing)

if you are a free developer i guess thats why you are having problems

offcourse i have made it)))