Skip to content

Commit

Permalink
FIX: Added loading page
Browse files Browse the repository at this point in the history
Signed-off-by: ParsaKargari <[email protected]>
  • Loading branch information
ParsaKargari committed Feb 12, 2024
1 parent 9c4ead2 commit 91a6608
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions Rethread/Rethread/Core/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import SwiftUI
struct ContentView: View {
@EnvironmentObject var viewModel: AuthViewModel


var body: some View {
Group {
if viewModel.currentUser?.onboardingComplete == false{
WelcomeView()
} else if viewModel.userSession != nil {
HomeView()
if viewModel.isLoading {
ProgressView("Loading...")
} else {
MainView()
if viewModel.currentUser?.onboardingComplete == false {
WelcomeView()
} else if viewModel.userSession != nil {
HomeView()
} else {
MainView()
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Rethread/Rethread/UserAuthentication/AuthViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ class AuthViewModel: ObservableObject {
@Published var currentUser: User?
@Published var CLIENT_CODE: String = ""
private var verificationId: String?
@Published var isLoading: Bool = true

init(){
self.userSession = Auth.auth().currentUser

self.isLoading = true
Task {
await fetchUser()
self.isLoading = false
}
}

Expand Down
2 changes: 1 addition & 1 deletion Rethread/Rethread/Views/WelcomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct WelcomeView: View {

VStack(alignment: .center, spacing: 40) {
VStack (alignment: .leading, spacing: 20) {
Text("Hi, " + ("there") + "!")
Text("Hi, " + (viewModel.currentUser?.firstname ?? "there") + "!")
.font(.system(size: 32))
.fontWeight(.bold)
.foregroundColor(Color.primaryDark.opacity(0.5))
Expand Down

0 comments on commit 91a6608

Please sign in to comment.