SpeziContact

1.0.0

Spezi module to display contact information
StanfordSpezi/SpeziContact

What's New

1.0.0

2024-01-09T22:01:00Z

What's Changed

Full Changelog: 0.5.1...1.0.0

Spezi Contact

Build and Test codecov DOI

Views to display contact information.

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(
        image: Image(systemName: "figure.wave.circle"),
        name: PersonNameComponents(givenName: "Leland", familyName: "Stanford"),
        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

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Wed Nov 20 2024 06:27:26 GMT-1000 (Hawaii-Aleutian Standard Time)