Skip to content

Commit

Permalink
Update documentation (#21)
Browse files Browse the repository at this point in the history
# Update documentation

## ♻️ Current situation & Problem
This PR updates some of the documentation. Most importantly it adds
updated screenshots of the `ContactsList` view.


## ⚙️ Release Notes 
* Update screenshots and documentation


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
Supereg authored Jan 9, 2024
1 parent 0751541 commit 494b776
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let package = Package(
.library(name: "SpeziContact", targets: ["SpeziContact"])
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/SpeziViews", .upToNextMinor(from: "0.6.0"))
.package(url: "https://github.com/StanfordSpezi/SpeziViews", from: "1.0.0")
],
targets: [
.target(
Expand Down
41 changes: 38 additions & 3 deletions Sources/SpeziContact/Contact Views/ContactView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import Contacts
import MessageUI
@_implementationOnly import MessageUI
import SpeziPersonalInfo
import SpeziViews
import SwiftUI
Expand Down Expand Up @@ -238,9 +238,44 @@ struct ContactView_Previews: PreviewProvider {
]
)
}



static let leland = Contact(
name: PersonNameComponents(
givenName: "Leland",
familyName: "Stanford"
),
image: Image(systemName: "figure.wave.circle"),
title: "University Founder",
description: """
Amasa Leland Stanford (March 9, 1824 – June 21, 1893) was an American industrialist and politician. [...] \
He and his wife Jane were also the founders of Stanford University, which they named after their late son.
[https://en.wikipedia.org/wiki/Leland_Stanford]
""",
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) 723-2300"),
.text("+1 (650) 723-2300"),
.email(addresses: ["[email protected]"]),
ContactOption(
image: Image(systemName: "safari.fill"),
title: "Website",
action: {}
)
]
)


static var previews: some View {
ContactView(contact: Self.leland)
ContactView(contact: Self.mock)
}
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/SpeziContact/Contact Views/ContactsList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ struct ContactsList_Previews: PreviewProvider {
NavigationStack {
ContactsList(
contacts: [
ContactView_Previews.mock,
ContactView_Previews.mock,
ContactView_Previews.leland,
ContactView_Previews.mock
]
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SpeziContact/Models/Contact.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SPDX-License-Identifier: MIT
//

@_exported import Contacts
@_exported import Contacts.CNPostalAddress
import SwiftUI


Expand Down
2 changes: 1 addition & 1 deletion Sources/SpeziContact/Models/ContactOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// SPDX-License-Identifier: MIT
//

import MessageUI
@_implementationOnly import MessageUI
import SwiftUI


Expand Down
Binary file modified Sources/SpeziContact/SpeziContact.docc/Resources/Overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 41 additions & 3 deletions Tests/UITests/TestApp/ContactsTestsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,44 @@ import SwiftUI


struct ContactsTestsView: View {
@MainActor static let leland = Contact(
name: PersonNameComponents(
givenName: "Leland",
familyName: "Stanford"
),
image: Image(systemName: "figure.wave.circle"), // swiftlint:disable:this accessibility_label_for_image
title: "University Founder",
description: """
Amasa Leland Stanford (March 9, 1824 – June 21, 1893) was an American industrialist and politician. [...] \
He and his wife Jane were also the founders of Stanford University, which they named after their late son.
[https://en.wikipedia.org/wiki/Leland_Stanford]
""",
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) 723-2300"),
.text("+1 (650) 723-2300"),
.email(addresses: ["[email protected]"]),
ContactOption(
image: Image(systemName: "safari.fill"), // swiftlint:disable:this accessibility_label_for_image
title: "Website",
action: {
if let url = URL(string: "https://stanford.edu") {
UIApplication.shared.open(url)
}
}
)
]
)

static let mock = Contact(
name: PersonNameComponents(givenName: "Paul", familyName: "Schmiedmayer"),
image: Image(systemName: "figure.wave.circle"), // swiftlint:disable:this accessibility_label_for_image
Expand Down Expand Up @@ -38,10 +76,10 @@ struct ContactsTestsView: View {
ContactOption(image: Image(systemName: "icloud.fill"), title: "Cloud", action: { })
]
)


var body: some View {
ContactsList(contacts: [ContactsTestsView.mock, ContactsTestsView.mock])
ContactsList(contacts: [ContactsTestsView.mock, ContactsTestsView.leland])
.navigationTitle("Contacts")
.background(Color(.systemGroupedBackground))
}
Expand Down
9 changes: 5 additions & 4 deletions Tests/UITests/TestAppUITests/SpeziContactsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ final class ContactsTests: XCTestCase {
let app = XCUIApplication()
app.launch()

XCTAssertEqual(app.staticTexts.matching(identifier: "Contact: Paul Schmiedmayer").count, 2)
XCTAssertEqual(app.staticTexts.matching(identifier: "A Title at Stanford University").count, 2)

XCTAssertTrue(app.staticTexts["Contact: Paul Schmiedmayer"].waitForExistence(timeout: 2.0))
XCTAssertTrue(app.staticTexts["A Title at Stanford University"].exists)

let labelPredicate = NSPredicate(format: "label CONTAINS[c] %@", "This is a description")
XCTAssert(app.staticTexts.element(matching: labelPredicate).exists)

XCTAssertEqual(app.buttons.matching(identifier: "Call").count, 4)
XCTAssertEqual(app.buttons.matching(identifier: "Call").count, 3)
app.buttons.matching(identifier: "Call").element(boundBy: 0).tap()
app.alerts["Call"].scrollViews.otherElements.buttons["Ok"].tap()

Expand All @@ -42,7 +43,7 @@ final class ContactsTests: XCTestCase {
app.buttons.matching(identifier: "Email").element(boundBy: 0).tap()
app.alerts["Email"].scrollViews.otherElements.buttons["Ok"].tap()

XCTAssertEqual(app.buttons.matching(identifier: "Cloud").count, 2)
XCTAssertEqual(app.buttons.matching(identifier: "Cloud").count, 1)
app.buttons.matching(identifier: "Cloud").element(boundBy: 0).tap()

let predicate = NSPredicate(format: "label BEGINSWITH 'Address: 450 Serra Mall'")
Expand Down

0 comments on commit 494b776

Please sign in to comment.