From 9f5f2700fff626495e9fe5e68dd7a787347858c1 Mon Sep 17 00:00:00 2001 From: abhat01 Date: Wed, 6 Mar 2024 02:26:26 -0800 Subject: [PATCH 1/4] copy over changes --- Sources/SpeziContact/Models/Contact.swift | 57 +++++++++++++++++++ .../SpeziContact/Models/ContactOption.swift | 22 +++++++ 2 files changed, 79 insertions(+) diff --git a/Sources/SpeziContact/Models/Contact.swift b/Sources/SpeziContact/Models/Contact.swift index 143c972..dbe5e02 100644 --- a/Sources/SpeziContact/Models/Contact.swift +++ b/Sources/SpeziContact/Models/Contact.swift @@ -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 = [ +/// 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@address.com"]), +/// ] +/// ) +/// ] +/// } +/// ``` +/// +/// Here is an additional example of a view (`ContactRow`), that takes a single ``Contact`` and displays their +/// name, image, title, and organization. +/// ``` swift +/// struct ContactRow: View { +/// let contact: Contact +/// var body: some View { +/// VStack(alignment: .leading) { +/// \\ Accessing different properties of the contact +/// 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. diff --git a/Sources/SpeziContact/Models/ContactOption.swift b/Sources/SpeziContact/Models/ContactOption.swift index e0530ab..f25d858 100644 --- a/Sources/SpeziContact/Models/ContactOption.swift +++ b/Sources/SpeziContact/Models/ContactOption.swift @@ -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. +/// ```swift +/// Contact( +/// // other parameters for Contact +/// contactOptions: [ +/// .call("+1 (123) 456-7890"), +/// .text("+1 (123) 456-7890"), +/// .email(addresses: ["email@address.com"]), +/// // 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. From ee7e9923ecb30ff77042adc2070e646afb73bc62 Mon Sep 17 00:00:00 2001 From: abhat01 Date: Wed, 6 Mar 2024 11:51:13 -0800 Subject: [PATCH 2/4] updates --- Sources/SpeziContact/Models/Contact.swift | 7 ++----- Sources/SpeziContact/Models/ContactOption.swift | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Sources/SpeziContact/Models/Contact.swift b/Sources/SpeziContact/Models/Contact.swift index dbe5e02..5e3fdaf 100644 --- a/Sources/SpeziContact/Models/Contact.swift +++ b/Sources/SpeziContact/Models/Contact.swift @@ -14,7 +14,8 @@ import SwiftUI /// /// ### Usage /// -/// The following example demonstrates the usage of the ``Contact`` in a ``ContactsList``. +/// The following examples demonstrates the usage of the ``Contact`` in a ``ContactsList`` (`Contacts`) and an example view +/// (`ContactRow`), that takes a single ``Contact`` and displays the corresopnding name, image, title, and organization. /// ```swift /// struct Contacts: View { /// let contacts = [ @@ -44,11 +45,7 @@ import SwiftUI /// ) /// ] /// } -/// ``` /// -/// Here is an additional example of a view (`ContactRow`), that takes a single ``Contact`` and displays their -/// name, image, title, and organization. -/// ``` swift /// struct ContactRow: View { /// let contact: Contact /// var body: some View { diff --git a/Sources/SpeziContact/Models/ContactOption.swift b/Sources/SpeziContact/Models/ContactOption.swift index f25d858..dda9295 100644 --- a/Sources/SpeziContact/Models/ContactOption.swift +++ b/Sources/SpeziContact/Models/ContactOption.swift @@ -14,7 +14,7 @@ import SwiftUI /// /// ### 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. +/// The following example demonstrates the usage of the ``ContactOption`` within a ``Contact``. For additional details, refer to the ``Contact`` documentation. /// ```swift /// Contact( /// // other parameters for Contact From d64caac408c3a45fb80581c12ffae2673bc8613a Mon Sep 17 00:00:00 2001 From: abhat01 Date: Wed, 6 Mar 2024 12:10:10 -0800 Subject: [PATCH 3/4] combined code examples --- Sources/SpeziContact/Models/Contact.swift | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Sources/SpeziContact/Models/Contact.swift b/Sources/SpeziContact/Models/Contact.swift index 5e3fdaf..e5762bd 100644 --- a/Sources/SpeziContact/Models/Contact.swift +++ b/Sources/SpeziContact/Models/Contact.swift @@ -14,11 +14,11 @@ import SwiftUI /// /// ### Usage /// -/// The following examples demonstrates the usage of the ``Contact`` in a ``ContactsList`` (`Contacts`) and an example view -/// (`ContactRow`), that takes a single ``Contact`` and displays the corresopnding name, image, title, and organization. +/// The following example demonstrates the initialization of a ``Contact`` and an example view +/// that displays its corresopnding name, image, title, and organization. /// ```swift -/// struct Contacts: View { -/// let contacts = [ +/// struct ContactRow: View { +/// let contact = /// Contact( /// name: PersonNameComponents( /// givenName: "First", @@ -43,11 +43,7 @@ import SwiftUI /// .email(addresses: ["email@address.com"]), /// ] /// ) -/// ] -/// } /// -/// struct ContactRow: View { -/// let contact: Contact /// var body: some View { /// VStack(alignment: .leading) { /// \\ Accessing different properties of the contact From a148ae5784a1d86fc59f558c23d2fb2317f242d2 Mon Sep 17 00:00:00 2001 From: abhat01 Date: Wed, 6 Mar 2024 14:20:16 -0800 Subject: [PATCH 4/4] fix typo --- Sources/SpeziContact/Models/Contact.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SpeziContact/Models/Contact.swift b/Sources/SpeziContact/Models/Contact.swift index e5762bd..8e48735 100644 --- a/Sources/SpeziContact/Models/Contact.swift +++ b/Sources/SpeziContact/Models/Contact.swift @@ -15,7 +15,7 @@ import SwiftUI /// ### Usage /// /// The following example demonstrates the initialization of a ``Contact`` and an example view -/// that displays its corresopnding name, image, title, and organization. +/// that displays its corresponding ``Contact`` name, image, title, and organization. /// ```swift /// struct ContactRow: View { /// let contact = @@ -46,7 +46,7 @@ import SwiftUI /// /// var body: some View { /// VStack(alignment: .leading) { -/// \\ Accessing different properties of the contact +/// // Accessing different properties of the contact /// contact.image /// .resizable() /// .frame(width: 50, height: 50)