small ui changes and publishing that dict to make sure it updates the ui when possible

This commit is contained in:
talksik
2021-12-22 01:03:05 -08:00
parent ad78dab718
commit c974715d23
2 changed files with 20 additions and 11 deletions
+3 -2
View File
@@ -37,7 +37,7 @@ final class AuthSessionStore: ObservableObject, SessionStore {
var messagesArr: [Message] = [] var messagesArr: [Message] = []
// transformed data for the views // transformed data for the views
var friendMessagesDict: [String: [Message]] = [:] @Published var friendMessagesDict: [String: [Message]] = [:]
// TODO: temporary...should not have this here // TODO: temporary...should not have this here
private var db = Firestore.firestore() private var db = Firestore.firestore()
@@ -50,7 +50,8 @@ final class AuthSessionStore: ObservableObject, SessionStore {
init(isPreview: Bool) { init(isPreview: Bool) {
let fakeUser = User(id: UUID().uuidString, nickname: "arjunya", phoneNumber: "+19302919293") let fakeUser = User(id: UUID().uuidString, nickname: "arjunya", phoneNumber: "+19302919293")
self.user = User() self.user = fakeUser
let clientID = FirebaseApp.app()?.options.clientID let clientID = FirebaseApp.app()?.options.clientID
self.GIDconfig = GIDConfiguration(clientID: clientID!) self.GIDconfig = GIDConfiguration(clientID: clientID!)
} }
@@ -19,17 +19,25 @@ struct FindFriendsView: View {
@State private var searchQuery: String = "" @State private var searchQuery: String = ""
var body: some View { var body: some View {
NavigationView { NavigationView {
// TODO: add search bar + have secondary sort ZStack {
List { WavesGlassBackgroundView()
ForEach(searchItems, id: \.self) { key in
if let currContact = self.contactsVM.contacts[key] { VStack {
ListContactRow(contactsVM: self.contactsVM, contact: currContact) Text("You must have someone in your phone contacts to add them. 🥬")
.font(.subheadline)
.foregroundColor(Color.gray)
List {
ForEach(searchItems, id: \.self) { key in
if let currContact = self.contactsVM.contacts[key] {
ListContactRow(contactsVM: self.contactsVM, contact: currContact)
}
}
} }
.searchable(text: self.$searchQuery)
} }
} }
.searchable(text: self.$searchQuery)
.navigationTitle("Find Friends") .navigationTitle("Find Friends")
.navigationBarItems(trailing: Button(action: { .navigationBarItems(trailing: Button(action: {
dismiss() dismiss()
@@ -57,7 +65,7 @@ struct FindFriendsView: View {
struct FindFriendsView_Previews: PreviewProvider { struct FindFriendsView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
FindFriendsView().environmentObject(AuthSessionStore()) FindFriendsView().environmentObject(AuthSessionStore(isPreview: true))
} }
} }
@@ -71,7 +79,7 @@ struct ListContactRow: View {
@State var showAlert = false @State var showAlert = false
@State var alertText = "🌱Confirm Arjun into Your Circle?" @State var alertText = "🌱Confirm Arjun into Your Circle?"
@State var alertMessage = "Note: You can have a maximium of 12 people in your circle and you have 5 swaps left!" @State var alertMessage = "Note: You can have a maximium of 12 people in your circle!"
var body: some View { var body: some View {
if contact.isExisting { // add to circle if contact.isExisting { // add to circle