getting some things working with navigation and auth but not updating environment variable yet

This commit is contained in:
talksik
2021-12-14 14:49:17 -08:00
parent f321e983b2
commit 0fb003b556
5 changed files with 43 additions and 106 deletions
+1 -54
View File
@@ -64,49 +64,8 @@ struct SignInView: View {
}
func handleLogin() {
//Google sign in
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
// create google sign in configuration object
let config = GIDConfiguration(clientID: clientID)
GIDSignIn.sharedInstance.signIn(with: config, presenting: getRootViewController())
{[self] user, err in
if err != nil {
print(err!.localizedDescription)
return
}
guard
let authentication = user?.authentication,
let idToken = authentication.idToken
else {
return
}
let credential = GoogleAuthProvider.credential(withIDToken: idToken,
accessToken: authentication.accessToken)
Auth.auth().signIn(with: credential) { result, error in
if error != nil {
print(error!.localizedDescription)
}
guard let user = result?.user else {
return
}
print(user.displayName ?? "Success!")
print(user)
// User is signed in
// ...
}
}
self.authSessionStore.signInOrCreateUser()
}
}
struct SignInView_Previews: PreviewProvider {
@@ -114,15 +73,3 @@ struct SignInView_Previews: PreviewProvider {
SignInView().environmentObject(AuthSessionStore())
}
}
extension View {
func getRootViewController() -> UIViewController {
guard let screen = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return .init() }
guard let root = screen.windows.first?.rootViewController else {
return .init()
}
return root
}
}
@@ -21,7 +21,6 @@ struct HeaderView: View {
.font(Font.system(.largeTitle))
.padding()
.foregroundColor(NirvanaColor.teal)
}
Spacer()
@@ -45,7 +44,6 @@ struct HeaderView: View {
.padding()
.foregroundColor(NirvanaColor.teal)
}
}
.frame(maxWidth: .infinity)
}
+26 -26
View File
@@ -8,37 +8,37 @@
import SwiftUI
struct WelcomeView: View {
let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height
var body: some View {
NavigationView {
OnboardingTemplateView(imgName: "undraw_friendship_mni7", mainLeadingActText: "Your", mainHighlightedActText: "minimalist", mainTrailingActText: "social media.", subActText: "Tired of the rat race on insta, snap, tik-tok, \"meta\"?", bottomActArea: AnyView(
VStack(alignment: .center) {
NavigationLink(destination: SignInView()) {
Text("Start Your Detox")
.bold()
.foregroundColor(NirvanaColor.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 20)
.background(NirvanaColor.teal)
.clipShape(Capsule())
.shadow(radius:10)
}
Button(
action: {
print("link to website learn more clicked")
},
label: {
Text("Learn More")
VStack(alignment: .center) {
NavigationLink(destination: SignInView()) {
Text("Start Your Detox")
.bold()
})
.foregroundColor(NirvanaColor.white)
.frame(maxWidth: .infinity)
.padding(.vertical, 20)
.background(NirvanaColor.teal)
.clipShape(Capsule())
.shadow(radius:10)
}
Button(
action: {
print("link to website learn more clicked")
},
label: {
Text("Learn More")
.bold()
})
//learn more button to usenirvana.com
}
.padding(.top, 20)
)
//learn more button to usenirvana.com
}
.padding(.top, 20)
)
)
.navigationBarHidden(true)
} // navigation view
} // View body
} // View