nicer ui for the list
This commit is contained in:
@@ -69,10 +69,7 @@ class ContactsViewModel : ObservableObject {
|
|||||||
let contactNumber = String(formattedNumber!)
|
let contactNumber = String(formattedNumber!)
|
||||||
var contactVm = ContactsViewModelContact(cnName: contactDisplayName, cnPhoneNumber: contactNumber)
|
var contactVm = ContactsViewModelContact(cnName: contactDisplayName, cnPhoneNumber: contactNumber)
|
||||||
|
|
||||||
print(contactVm)
|
|
||||||
// check if the contact is an existing user by phone number
|
// check if the contact is an existing user by phone number
|
||||||
|
|
||||||
|
|
||||||
self.firestoreService.getUserByPhoneNumber(phoneNumber: contactNumber) {[weak self] returnedUser in
|
self.firestoreService.getUserByPhoneNumber(phoneNumber: contactNumber) {[weak self] returnedUser in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if returnedUser == nil {
|
if returnedUser == nil {
|
||||||
|
|||||||
@@ -23,11 +23,9 @@ struct FindFriendsView: View {
|
|||||||
// list with search bar
|
// list with search bar
|
||||||
List {
|
List {
|
||||||
ForEach(contactsVM.contacts.sorted { $0.isExisting && !$1.isExisting }) { contact in
|
ForEach(contactsVM.contacts.sorted { $0.isExisting && !$1.isExisting }) { contact in
|
||||||
|
ListContactRow(contact: contact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.searchable(text: $searchQuery)
|
|
||||||
.listStyle(GroupedListStyle())
|
|
||||||
.navigationTitle("Find Friends")
|
.navigationTitle("Find Friends")
|
||||||
.navigationBarItems(trailing: Button(action: {
|
.navigationBarItems(trailing: Button(action: {
|
||||||
dismiss()
|
dismiss()
|
||||||
@@ -50,30 +48,63 @@ struct FindFriendsView_Previews: PreviewProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ListContactRow: View {
|
struct ListContactRow: View {
|
||||||
var contact: CNContact
|
var contact: ContactsViewModelContact
|
||||||
|
|
||||||
@State var showAlert = false
|
@State var showAlert = false
|
||||||
@State var alertText = ""
|
@State var alertText = ""
|
||||||
@State var alertMessage = ""
|
@State var alertMessage = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: {
|
if contact.isExisting { // add to circle
|
||||||
|
HStack(alignment: .center, spacing: 0) {
|
||||||
}) {
|
Image(contact.user?.avatar ?? "")
|
||||||
HStack {
|
.resizable()
|
||||||
Text("\(contact.familyName)").fontWeight(.bold)
|
.scaledToFit()
|
||||||
Text("\(contact.givenName) \(contact.middleName)")
|
.clipShape(Circle())
|
||||||
|
.frame(width: 40, height: 40)
|
||||||
|
.padding(.trailing, 10)
|
||||||
|
|
||||||
|
Text(contact.cnName)
|
||||||
|
.font(.headline)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
// if the user is already an existing user
|
Button {
|
||||||
|
print("adding contact to circle")
|
||||||
|
|
||||||
|
//show alert if circle is full
|
||||||
|
|
||||||
|
} label: {
|
||||||
|
Label("Add", systemImage: "plus.circle")
|
||||||
|
.font(.title2)
|
||||||
|
.foregroundColor(NirvanaColor.solidTeal)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.foregroundColor(.black)
|
|
||||||
}
|
}
|
||||||
.alert(self.alertText, isPresented: self.$showAlert) {
|
else { // invite button to text the person
|
||||||
Button("OK", role: ButtonRole.cancel) { }
|
HStack(alignment: .center, spacing: 0) {
|
||||||
} message: {
|
Image(Avatars.avatarSystemNames[1])
|
||||||
Text(self.alertMessage)
|
.resizable()
|
||||||
|
.scaledToFit()
|
||||||
|
.clipShape(Circle())
|
||||||
|
.frame(width: 40, height: 40)
|
||||||
|
.blur(radius: 8)
|
||||||
|
.padding(.trailing, 10)
|
||||||
|
|
||||||
|
Text(contact.cnName)
|
||||||
|
.font(.headline)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
Button {
|
||||||
|
print("inviting user now")
|
||||||
|
// text message to him/her
|
||||||
|
} label: {
|
||||||
|
Label("Invite", systemImage: "paperplane")
|
||||||
|
.font(.title2)
|
||||||
|
.foregroundColor(Color.orange)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user