File size: 1,425 Bytes
17afd55 2c44d83 17afd55 2c44d83 17afd55 2c44d83 17afd55 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import SwiftUI
class Contact : Codable {
var contactId: String
var displayName: String
var phoneNumbers: [String]
init(contactId: String, displayName: String, phoneNumbers: [String]) {
self.contactId = contactId
self.displayName = displayName
self.phoneNumbers = phoneNumbers
}
}
struct ContactBubble: Shape {
func path(in rect: CGRect) -> Path {
let path = UIBezierPath(roundedRect: rect,
byRoundingCorners: [.allCorners],
cornerRadii: CGSize(width: 9, height: 9))
return Path(path.cgPath)
}
}
struct ContactRow: View {
let contact: Contact
var body: some View {
HStack {
Text(contact.displayName)
.italic()
.font(.system(size: 15))
.foregroundColor(.white)
.padding(5)
Spacer()
Image(systemName: "phone.fill")
.resizable()
.frame(width: 17, height: 17)
.foregroundColor(.white)
}
.background(Color.clear)
.clipShape(ContactBubble())
}
}
struct Contact_Previews: PreviewProvider {
static var previews: some View {
ContactRow(contact: Contact(
contactId: "5",
displayName: "Peter Luo",
phoneNumbers: ["123-234-345"])
)
}
}
|