Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding coding examples for Contact and ContactOption - v2 with signed commits #25

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Sources/SpeziContact/Models/Contact.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,63 @@ import SwiftUI


/// Encodes the contact information.
///
/// ### Usage
///
/// The following example demonstrates the usage of the ``Contact`` in a ``ContactsList``.
/// ```swift
/// struct Contacts: View {
/// let contacts = [
akanshyabhat marked this conversation as resolved.
Show resolved Hide resolved
/// Contact(
/// name: PersonNameComponents(
/// givenName: "First",
/// familyName: "Last"
/// ),
/// image: Image(systemName: "figure.wave.circle"),
/// title: "Title",
/// description: "Description",
/// organization: "Organization",
/// address: {
/// let address = CNMutablePostalAddress()
/// address.country = "USA"
/// address.state = "CA"
/// address.postalCode = "94305"
/// address.city = "City"
/// address.street = "123 ABC St"
/// return address
/// }(),
/// contactOptions: [
/// .call("+1 (123) 456-7890"),
/// .text("+1 (123) 456-7890"),
/// .email(addresses: ["[email protected]"]),
/// ]
/// )
/// ]
/// }
/// ```
///
/// Here is an additional example of a view (`ContactRow`), that takes a single ``Contact`` and displays their
akanshyabhat marked this conversation as resolved.
Show resolved Hide resolved
/// name, image, title, and organization.
/// ``` swift
/// struct ContactRow: View {
akanshyabhat marked this conversation as resolved.
Show resolved Hide resolved
/// let contact: Contact
/// var body: some View {
/// VStack(alignment: .leading) {
/// \\ Accessing different properties of the contact
akanshyabhat marked this conversation as resolved.
Show resolved Hide resolved
/// contact.image
/// .resizable()
/// .frame(width: 50, height: 50)
/// .cornerRadius(25)
/// Text("\(contact.name.givenName) \(contact.name.familyName)")
/// .font(.headline)
/// Text(contact.title)
/// .font(.subheadline)
/// Text(contact.organization)
/// .font(.subheadline)
/// }
/// }
/// }
/// ```
public struct Contact {
let id = UUID()
/// The name of the individual. Ideally provide at least a first and given name.
Expand Down
22 changes: 22 additions & 0 deletions Sources/SpeziContact/Models/ContactOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,28 @@ import SwiftUI


/// Customizable way to get in contact with an individual and usually connected to a ``Contact``.
///
/// ### Usage
///
/// The following example demonstrates the usage of the ``ContactOption`` within a ``Contact``. For additional details on the implementation of a ``Contact``, please refer to its page.
akanshyabhat marked this conversation as resolved.
Show resolved Hide resolved
/// ```swift
/// Contact(
/// // other parameters for Contact
/// contactOptions: [
/// .call("+1 (123) 456-7890"),
/// .text("+1 (123) 456-7890"),
/// .email(addresses: ["[email protected]"]),
/// // Here is where the custom ContactOption can be used as a part of the contactOptions list
/// ContactOption(
/// image: Image(systemName: "safari.fill"),
/// title: "More Info",
/// action: {
/// // Action that should be performed on pressing this ContactOption (i.e. opening a link for a website)...
/// }
/// )
/// ]
/// )
/// ```
public struct ContactOption {
let id = UUID()
/// The image representing the ``ContactOption`` in the user interface.
Expand Down
Loading