diff --git a/Package.swift b/Package.swift index a9c5f4d..5941d00 100644 --- a/Package.swift +++ b/Package.swift @@ -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( diff --git a/Sources/SpeziContact/Contact Views/ContactView.swift b/Sources/SpeziContact/Contact Views/ContactView.swift index cb8dfdf..b557bd3 100644 --- a/Sources/SpeziContact/Contact Views/ContactView.swift +++ b/Sources/SpeziContact/Contact Views/ContactView.swift @@ -7,7 +7,7 @@ // import Contacts -import MessageUI +@_implementationOnly import MessageUI import SpeziPersonalInfo import SpeziViews import SwiftUI @@ -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: ["contact@stanford.edu"]), + ContactOption( + image: Image(systemName: "safari.fill"), + title: "Website", + action: {} + ) + ] + ) + + static var previews: some View { + ContactView(contact: Self.leland) ContactView(contact: Self.mock) } } diff --git a/Sources/SpeziContact/Contact Views/ContactsList.swift b/Sources/SpeziContact/Contact Views/ContactsList.swift index b079964..b8b7f7e 100644 --- a/Sources/SpeziContact/Contact Views/ContactsList.swift +++ b/Sources/SpeziContact/Contact Views/ContactsList.swift @@ -47,8 +47,7 @@ struct ContactsList_Previews: PreviewProvider { NavigationStack { ContactsList( contacts: [ - ContactView_Previews.mock, - ContactView_Previews.mock, + ContactView_Previews.leland, ContactView_Previews.mock ] ) diff --git a/Sources/SpeziContact/Models/Contact.swift b/Sources/SpeziContact/Models/Contact.swift index 71763d0..143c972 100644 --- a/Sources/SpeziContact/Models/Contact.swift +++ b/Sources/SpeziContact/Models/Contact.swift @@ -6,7 +6,7 @@ // SPDX-License-Identifier: MIT // -@_exported import Contacts +@_exported import Contacts.CNPostalAddress import SwiftUI diff --git a/Sources/SpeziContact/Models/ContactOption.swift b/Sources/SpeziContact/Models/ContactOption.swift index 6f61322..e0530ab 100644 --- a/Sources/SpeziContact/Models/ContactOption.swift +++ b/Sources/SpeziContact/Models/ContactOption.swift @@ -6,7 +6,7 @@ // SPDX-License-Identifier: MIT // -import MessageUI +@_implementationOnly import MessageUI import SwiftUI diff --git a/Sources/SpeziContact/SpeziContact.docc/Resources/Overview.png b/Sources/SpeziContact/SpeziContact.docc/Resources/Overview.png index be56bbf..2c37ee4 100644 Binary files a/Sources/SpeziContact/SpeziContact.docc/Resources/Overview.png and b/Sources/SpeziContact/SpeziContact.docc/Resources/Overview.png differ diff --git a/Sources/SpeziContact/SpeziContact.docc/Resources/Overview~dark.png b/Sources/SpeziContact/SpeziContact.docc/Resources/Overview~dark.png index abfc36b..7dc14a2 100644 Binary files a/Sources/SpeziContact/SpeziContact.docc/Resources/Overview~dark.png and b/Sources/SpeziContact/SpeziContact.docc/Resources/Overview~dark.png differ diff --git a/Tests/UITests/TestApp/ContactsTestsView.swift b/Tests/UITests/TestApp/ContactsTestsView.swift index a2839e8..d0f651b 100644 --- a/Tests/UITests/TestApp/ContactsTestsView.swift +++ b/Tests/UITests/TestApp/ContactsTestsView.swift @@ -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: ["contact@stanford.edu"]), + 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 @@ -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)) } diff --git a/Tests/UITests/TestAppUITests/SpeziContactsTests.swift b/Tests/UITests/TestAppUITests/SpeziContactsTests.swift index 277efd2..1402c54 100644 --- a/Tests/UITests/TestAppUITests/SpeziContactsTests.swift +++ b/Tests/UITests/TestAppUITests/SpeziContactsTests.swift @@ -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() @@ -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'")