stanfordspezi/spezicontact
This source file is part of the Stanford Spezi open-source project.
Overview
The Spezi Contact Swift Package provides views and infrastructure to display contact information in an application.
| [Screenshot showing a ContactsList rendered within the Spezi Template Application.] [Screenshot showing a ContactsList rendered within the Spezi Template Application.] | |:---:| | A ContactsList rendered in the Spezi Template Application. |
Setup
Add Spezi Contact as a Dependency
You need to add the Spezi Contact Swift package to your app in Xcode or Swift package.
Example
The Contact module enables displaying contact information in an application. Information can be encoded in Contact and ContactOption to configure the contact views. The ContactView and ContactsList can display the contact information in a card-like layout and list.
The following example shows how Contacts can be created to encode an individual's contact information and displayed in a ContactsList within a SwiftUI View.
import SpeziContact
import SwiftUI
struct ContactsExample: View {
let contact = Contact(
name: PersonNameComponents(givenName: "Leland", familyName: "Stanford"),
image: Image(systemName: "figure.wave.circle"),
title: "Founder",
description: """
Leland Stanford is the founder of Stanford University.
""",
organization: "Stanford University",
address: {
let address = CNMutablePostalAddress()
address.country = "USA"
address.state = "CA"
address.postalCode = "94305"
address.city = "Stanford"
address.street = "450 Serra Mall"
return address
}(),
contactOptions: [
.call("+1 (650) 123-4567"),
.text("+1 (650) 123-4567"),
.email(addresses: ["example@stanford.edu"], subject: "Hi!")
]
)
var body: some View {
ContactsList(contacts: [contact])
}
}For more information, please refer to the API documentation.
The Spezi Template Application
The Spezi Template Application provides a great starting point and example using the SpeziContact module.
Contributing
Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first.
License
This project is licensed under the MIT License. See Licenses for more information.
[Spezi Footer] [Spezi Footer]
Package Metadata
Repository: stanfordspezi/spezicontact
Default branch: main
README: README.md