如何从class.swift文件中的函数调用swiftui视图

如何从class.swift文件中的函数调用swiftui视图,swift,swiftui,google-signin,appdelegate,swiftui-navigationlink,Swift,Swiftui,Google Signin,Appdelegate,Swiftui Navigationlink,我在构建社交媒体应用程序时遇到了一个问题 我在我的LoginView上集成了一个“Google登录按钮”(使用客户端ID,无firebase,GoogleSignIn框架),登录gmail帐户后,它会将我带回同一个LoginView。 我想导航到SignUpView,如果用户第一次输入并且用户已注册,我想导航到HomeView 我正在从AppDelegate中的函数获取用户数据 func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogl

我在构建社交媒体应用程序时遇到了一个问题

我在我的LoginView上集成了一个“Google登录按钮”(使用客户端ID,无firebase,GoogleSignIn框架),登录gmail帐户后,它会将我带回同一个LoginView。

我想导航到SignUpView,如果用户第一次输入并且用户已注册,我想导航到HomeView

我正在从AppDelegate中的函数获取用户数据

func sign(_ signIn: GIDSignIn!, didSignInFor user: 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
}
getGoogleUserData(with: user)
现在,使用用户的idToken,我将数据发布到Graphql中的后端服务器,如果用户是否注册,我将返回信息

fileprivate func getAuth(with idToken : String) {
let params = ["id_token":"\((idToken))"]
print(params)
var request = URLRequest(url: URL(string: "confidential_URL_here")!)
request.httpMethod = "POST"
request.httpBody = try? JSONSerialization.data(withJSONObject: params, options: [])
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
let session = URLSession.shared
let task = session.dataTask(with: request, completionHandler: { data, response, error -> Void in
if let safeData = data {
ParsingUserJSON().parseJSON(with: safeData)
}
})
task.resume()
} 
这是我的parseJSON函数。在此,我需要有关此函数之后如何执行此操作的帮助:-

class ParsingUserJSON: ObservableObject {

func parseJSON(with loginJSON : Data) {

let decoder = JSONDecoder()

do{
let decodedUser = try decoder.decode(LoginData.self, from: loginJSON)

guard let shouldSignUp = decodedUser.user?.signin //This tells me whether the user is entering the app for first time or not

 else {
fatalError("could not achieve signIn boolean data from loginJSON")
}

guard let accessToken = decodedUser.accessToken 

else {
fatalError("could not get accessToken from the loginJSON")
}


//I am checking if the user has created not created his username and is entering for first time

if decodedUser.user?.username == nil || shouldSignUp == true 
{


//**THIS IS THE PART I AM NEED HELP. WHAT TO DO AFTER THIS? HOW TO GO FROM HERE>**


}

else {
guard let userName = decodedUser.user?.username else { return }
}

}catch{
     fatalError("could not decode loginJSON")
      }
  }
}

现在有人能帮我把数据发送回LoginView并使用NavigationLink导航到SignUpView吗?或者是否有其他方法可以做到这一点。

使用一些环境对象来检测用户是否登录