slight problem with navigation...have to choose one or the other as I have too many controls everywhere

This commit is contained in:
talksik
2021-12-18 02:25:00 -08:00
parent 5ce958501a
commit 332be96743
7 changed files with 82 additions and 20 deletions
+6 -9
View File
@@ -13,16 +13,13 @@ struct ContentView: View {
var body: some View {
NavigationStackView {
// MARK: temporary
PhoneVerificationView()
// TODO: remove this commenting to enable natural user flow
// switch self.authSessionStore.sessionState {
// case SessionState.isAuthenticated:
// InnerCircleView()
// case SessionState.isLoggedOut:
// WelcomeView()
// }
switch self.authSessionStore.sessionState {
case SessionState.isAuthenticated:
InnerCircleView()
case SessionState.isLoggedOut:
WelcomeView()
}
}
}
}
@@ -6,9 +6,12 @@
//
import SwiftUI
import NavigationStack
struct InnerCircleView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore
@EnvironmentObject var navigationStack: NavigationStack
let universalSize = UIScreen.main.bounds
@@ -344,7 +347,11 @@ struct InnerCircleView: View {
Button("Log out") {
print("log out button clicked")
authSessionStore.logOut()
// have this send it
self.authSessionStore.logOut()
// once logged out, then the listener will listen and change the page but we will go there first
self.navigationStack.push(ContentView())
}
Button("Friends") {
print("manage friends page")
@@ -0,0 +1,20 @@
//
// LogoHeaderView.swift
// nirvana-ios
//
// Created by Arjun Patel on 12/18/21.
//
import SwiftUI
struct LogoHeaderView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct LogoHeaderView_Previews: PreviewProvider {
static var previews: some View {
LogoHeaderView()
}
}
@@ -102,7 +102,7 @@ struct PhoneCodeVerificationView: View {
// then sending to next page
self.navigationStack.push(PhoneVerificationView()) // verify code page
self.navigationStack.push(OnboardingTrioView()) // verify code page
}
} label: {
@@ -6,10 +6,37 @@
//
import Foundation
import FirebaseAuth
final class PhoneVerificationViewModel : ObservableObject {
public func verifyPhoneAndSendSMS(phoneNumber: String) {
// TODO: do some string validation here
// do auth stuff from firebase
PhoneAuthProvider.provider()
.verifyPhoneNumber(phoneNumber, uiDelegate: nil) { verificationID, error in
print("firebase auth done, now running my callback")
// got a response...done loading... either error to show or next page
// self.isLoading.toggle()
// problem verifying number showing alert...maybe fake number or something from user
if error != nil {
// self.toastText = " Please try again."
// self.toastSubMessage = "There was an issue validating your phone number"
// self.showToast.toggle()
print((error?.localizedDescription)!)
return
}
// use this in the next screen to verify with the code provided
UserDefaults.standard.set(verificationID, forKey: "authVerificationID")
// self.navigationStack.push(PhoneCodeVerificationView()) // verify code page
}
}
}
@@ -6,8 +6,11 @@
//
import SwiftUI
import NavigationStack
struct OnboardingTrioView: View {
@EnvironmentObject var navigationStack: NavigationStack
var body: some View {
TabView {
OnboardingTemplateView(imgName: "undraw_through_the_park_lxnl", mainLeadingActText: "The path to living in the ", mainHighlightedActText: "present moment.", mainTrailingActText: "", subActText: "No more dopamine inducing news feeds. No profiles so no anxiety about the past or what others think.")
@@ -16,7 +19,9 @@ struct OnboardingTrioView: View {
OnboardingTemplateView(imgName: "undraw_connection_b-38-q", mainLeadingActText: "Be picky about your ", mainHighlightedActText: "inner circle.", mainTrailingActText: "", subActText: "You are who you hang out with. Maximum 8 people in your inner circle.", bottomActArea: AnyView(
VStack {
NavigationLink(destination: SignInView()) {
Button {
self.navigationStack.push(ContactsView())
} label: {
Text("Start Your Detox")
.bold()
.foregroundColor(NirvanaColor.white)
@@ -25,13 +30,7 @@ struct OnboardingTrioView: View {
.background(NirvanaColor.teal)
.clipShape(Capsule())
.shadow(radius:10)
}
NavigationLink(destination: WelcomeView()) {
Text("Go Back")
.bold()
.foregroundColor(NirvanaColor.teal)
}
}
}.padding(.bottom, 20)
)
)