用于显示联系方式的视图。
Spezi Contact Swift 包提供了在应用程序中显示联系方式的视图和基础设施。
![]() ![]() |
---|
在 Spezi 模板应用程序中渲染的 ContactsList 。 |
您需要在 Xcode 中将 Spezi Contact Swift 包添加到 您的应用程序 或 Swift 包。
Contact 模块允许在应用程序中显示联系方式。信息可以编码在 Contact
和 ContactOption
中,以配置联系人视图。ContactView
和 ContactsList
可以在类似卡片的布局和列表中显示联系方式。
以下示例展示了如何创建 Contact
来编码个人的联系方式,并在 SwiftUI View
中的 ContactsList
中显示。
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])
}
}
有关更多信息,请参阅 API 文档。
Spezi 模板应用程序 提供了一个很好的起点和使用 SpeziContact
模块的例子。
欢迎对本项目做出贡献。请务必先阅读 贡献指南 和 贡献者公约行为准则。
本项目采用 MIT 许可证。有关更多信息,请参见 许可证。