diff --git a/enzevalos_iphone/SwiftUI/Contact/ContactView.swift b/enzevalos_iphone/SwiftUI/Contact/ContactView.swift index 310dbf7430ddb30a5ca1cb0d9d3b9c00cd375298..3d56ff55a2db22984632d912d52de4b03502d0fa 100644 --- a/enzevalos_iphone/SwiftUI/Contact/ContactView.swift +++ b/enzevalos_iphone/SwiftUI/Contact/ContactView.swift @@ -30,7 +30,6 @@ struct ContactView <C: DisplayContact>: View { VStack { HStack { avatar - VStack (alignment: .leading) { contactName.padding(.bottom) knownSince @@ -144,7 +143,7 @@ struct ContactView <C: DisplayContact>: View { } label: { Text("\(eachAddress)") .fontWeight(.light) - .font(.title2) + .font(.body) .foregroundColor(.blue) .truncationMode(.middle) .frame(maxWidth: .infinity, @@ -157,32 +156,11 @@ struct ContactView <C: DisplayContact>: View { // This row shows the security rating and a button do display the keys HStack{ rating - Button { - withAnimation{ - properties.emailAddress = eachAddress - properties.showKeysPopup.toggle() - } - - } label: { - ZStack { - Capsule() - .frame(height: 25, alignment: .center) - .shadow(color:.gray, radius:2) - .foregroundColor(contact.addressRating(contact).color) - - HStack{ - Text(Image(systemName: "key.fill")) - .rotationEffect(Angle(degrees: 30)) - - Text(NSLocalizedString("Contact.Key.Description", comment: "Contact.Key.Description")) - .fontWeight(.medium) - - }.foregroundColor(.white) - .font(.body) - } - } + if contact.primaryKey != nil { + showKeyBotton(addr: eachAddress) + } }.padding(.vertical,3) - + if eachAddress != contact.emails.last{ Divider().padding(.top,1) } @@ -193,6 +171,32 @@ struct ContactView <C: DisplayContact>: View { }.padding(.horizontal,5) } + + private func showKeyBotton (addr: String) -> some View { + Button { + withAnimation{ + properties.emailAddress = addr + properties.showKeysPopup.toggle() + } + + } label: { + ZStack { + Capsule() + .frame(height: 25, alignment: .center) + .shadow(color:.gray, radius:2) + .foregroundColor(contact.addressRating(contact).color) + HStack{ + Text(Image(systemName: "key.fill")) + .rotationEffect(Angle(degrees: 30)) + + Text(NSLocalizedString("Contact.Key.Description", comment: "Contact.Key.Description")) + .fontWeight(.medium) + + }.foregroundColor(.white) + .font(.footnote) + } + } + } /// Creates a frame for the address label. /// TODO: Add an addressLabel property to the DisplayContact. @@ -250,11 +254,11 @@ struct ContactView <C: DisplayContact>: View { private var rating: some View { HStack{ Text(Image(systemName: contact.addressRating(contact).shield)) - .font(.title3) + .font(.footnote) Text(contact.addressRating(contact).name) .fontWeight(.medium) - .font(.body) + .font(.footnote) } .foregroundColor(contact.addressRating(contact).color)