making some fixes little things especially for the updating of user and setting right id for document in users collection

This commit is contained in:
talksik
2021-12-18 18:13:23 -08:00
parent afe8cc4ad9
commit f0e6e7ca63
11 changed files with 65 additions and 6 deletions
+1
View File
@@ -11,6 +11,7 @@ import NavigationStack
struct ContentView: View {
@EnvironmentObject var authSessionStore: AuthSessionStore
// welcome -> phone verification -> phone code verification -> onboarding trio -> first, last, avatar picker -> add contacts -> hub
var body: some View {
NavigationStackView {
PhoneVerificationView()
@@ -36,7 +36,7 @@ class FirestoreService {
func createUser(user: User) {
do {
let _ = try db.collection(Collection.users.rawValue).addDocument(from: user)
let _ = try db.collection(Collection.users.rawValue).document(user.id!).setData(from: user)
} catch {
print("error in creating user \(error.localizedDescription)")
}
@@ -8,8 +8,11 @@
import SwiftUI
import Contacts
import ContactsUI
import NavigationStack
struct ContactsView: View {
@EnvironmentObject var navigationStack : NavigationStack
var testUsers:[TestUser] = [
TestUser(_profilePic: "liam", _firstN: "Liam", _lastN: "Digregorio"),
TestUser(_profilePic: "heran", _firstN: "Heran", _lastN: "Patel"),
@@ -41,6 +44,12 @@ struct ContactsView: View {
Text(selectedContact != nil ? "Selected: \((selectedContact?.familyName)!) \((selectedContact?.givenName)!)" : "Nothing selected".localized)
Button {
self.navigationStack.push(InnerCircleView())
} label: {
Text("go to hub")
}
Spacer()
}
.sheet(isPresented: self.$showPicker) {
@@ -6,10 +6,17 @@
//
import SwiftUI
import NavigationStack
struct EditProfileView: View {
@EnvironmentObject var navigationStack: NavigationStack
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
Button {
self.navigationStack.push(ContactsView())
} label: {
}
}
}
@@ -55,7 +55,7 @@ struct PhoneCodeVerificationView: View {
print("started verification process of code")
//disable focused textfield
self.focusedInputField.toggle()
self.focusedInputField = false
// show loading screen
self.isLoading.toggle()
@@ -79,7 +79,7 @@ struct PhoneVerificationView: View {
let concatPhoneNumber = "+"+self.ccode+self.phoneNumber
//disable focused textfield...important: draw the focus field out first and then the loading screen
self.focusedInputField.toggle()
self.focusedInputField = false
//show loading screen
self.isLoading.toggle()
@@ -29,6 +29,7 @@ final class PhoneVerificationViewModel : ObservableObject {
if user == nil {// if empty, create user - 1 result set cost..prolly higher cost
print("creating new user with id: \(userId)")
let newUser = User(id: userId, phoneNumber: phoneNumber)
print("verify the id stayed the same: \(newUser.id)")
firestoreService.createUser(user: newUser)
} else { // if not, change last logged in value
// assign to nil so that server can fill it in
+26
View File
@@ -0,0 +1,26 @@
//
// RouterView.swift
// nirvana-ios
//
// Created by Arjun Patel on 12/18/21.
//
import SwiftUI
// show the loading screen while we figure out where to send the user through the nav stack
struct RouterView: View {
// if not authenticated -> push to welcome
// if authenticated
// if no profile pic and name and all -> go through onboarding again
// if has everythign in place -> homeview and get talking/chatting
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct RouterView_Previews: PreviewProvider {
static var previews: some View {
RouterView()
}
}
@@ -19,14 +19,17 @@ struct SplashView: View {
.foregroundColor(Color.white)
.scaleEffect(self.scale)
.animation(.easeIn(duration: 2).repeatForever(autoreverses: true))
.ignoresSafeArea(.keyboard)
}
.ignoresSafeArea(.keyboard)
}
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
.background(NirvanaColor.teal)
.onAppear {
self.scale = 1.3
}
.ignoresSafeArea(.all)
.ignoresSafeArea(.keyboard)
.edgesIgnoringSafeArea(.all)
}
}
@@ -40,7 +40,7 @@ struct OnboardingTemplateView: View {
var body: some View {
ZStack {
// TODO: CAREFUL...this needs to be on top if any view is using this subview...otherwise elements will be dimmed and placed beneath this background
// CAREFUL...this needs to be on top if any view is using this subview...otherwise elements will be dimmed and placed beneath this background
WavesGlassBackgroundView()
VStack(spacing: 0) {