Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Jan 9, 2024
1 parent 0751541 commit 57e9358
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 12 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
40 changes: 38 additions & 2 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,45 @@ struct ContactView_Previews: PreviewProvider {
]
)
}


static let leland = Contact(
name: PersonNameComponents(
givenName: "Leland",
familyName: "Stanford"
),
image: Image(systemName: "figure.wave.circle"), // swiftlint:disable:this accessibility_label_for_image

Check failure on line 247 in Sources/SpeziContact/Contact Views/ContactView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Superfluous Disable Command Violation: SwiftLint rule 'accessibility_label_for_image' did not trigger a violation in the disabled region; remove the disable command (superfluous_disable_command)
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
}(),

Check warning on line 263 in Sources/SpeziContact/Contact Views/ContactView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SpeziContact/Contact Views/ContactView.swift#L255-L263

Added lines #L255 - L263 were not covered by tests
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

Check failure on line 269 in Sources/SpeziContact/Contact Views/ContactView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Superfluous Disable Command Violation: SwiftLint rule 'accessibility_label_for_image' did not trigger a violation in the disabled region; remove the disable command (superfluous_disable_command)
title: "Website",
action: {}

Check warning on line 271 in Sources/SpeziContact/Contact Views/ContactView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SpeziContact/Contact Views/ContactView.swift#L271

Added line #L271 was not covered by tests
)
]
)



Check failure on line 277 in Sources/SpeziContact/Contact Views/ContactView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Vertical Whitespace Violation: Limit vertical whitespace to maximum 2 empty lines; currently 3 (vertical_whitespace)
static var previews: some View {
ContactView(contact: Self.leland)

Check warning on line 279 in Sources/SpeziContact/Contact Views/ContactView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SpeziContact/Contact Views/ContactView.swift#L279

Added line #L279 was not covered by tests
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,

Check warning on line 50 in Sources/SpeziContact/Contact Views/ContactsList.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SpeziContact/Contact Views/ContactsList.swift#L50

Added line #L50 was not covered by tests
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.
41 changes: 40 additions & 1 deletion Tests/UITests/TestApp/ContactsTestsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,45 @@ import SwiftUI


struct ContactsTestsView: View {
@MainActor
static let leland = Contact(

Check failure on line 15 in Tests/UITests/TestApp/ContactsTestsView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint / SwiftLint

Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports (attributes)
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 @@ -41,7 +80,7 @@ struct ContactsTestsView: View {


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 57e9358

Please sign in to comment.