diff --git a/Sources/SpeziViews/Views/Text/NoInformationText.swift b/Sources/SpeziViews/Views/Text/NoInformationText.swift deleted file mode 100644 index bb34e1f..0000000 --- a/Sources/SpeziViews/Views/Text/NoInformationText.swift +++ /dev/null @@ -1,117 +0,0 @@ -// -// This source file is part of the Stanford Spezi open-source project -// -// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) -// -// SPDX-License-Identifier: MIT -// - -import SwiftUI - - -/// Communicate non-present information. -/// -/// This view provides a unified style to communicate information that is not present yet. -/// You communicate to the user why no information is shown with a short descriptive title and elaborate -/// on the steps necessary to add information in a more descriptive caption text. -/// -/// In the example of the contacts app you could display a "No Contacts" header with a caption "Contacts -/// you've added will appear here." when no contacts were added to the list yet. -/// The below code demonstrates how to do this with the `NoInformationText`. -/// -/// ```swift -/// struct ContactsList: View { -/// private let contacts: [Contact] -/// -/// var body: some View { -/// if contacts.isEmpty { -/// NoInformationText(header: "No Contacts", caption: "Contacts you've added will appear here.") -/// } else { -/// // ... -/// } -/// } -/// -/// init(_ contacts: [Contact]) { -/// self.contacts = contacts -/// } -/// } -/// ``` -public struct NoInformationText: View { - private let header: Header - private let caption: Caption - - public var body: some View { - VStack { - header - .font(.title2) - .bold() - .accessibilityAddTraits(.isHeader) - caption - .padding([.leading, .trailing], 25) - .foregroundColor(.secondary) - } - .multilineTextAlignment(.center) - .frame(maxWidth: .infinity) - } - - - /// Create a new no-information text. - /// - Parameters: - /// - verbatim: The header string. - /// - caption: The descriptive caption view. - public init(verbatim header: String, @ViewBuilder caption: () -> Caption) where Header == Text { - self.init(header, caption: caption) - } - - /// Create a new no-information text. - /// - Parameters: - /// - header: The header string. - /// - caption: The descriptive caption view. - @_disfavoredOverload - public init(_ header: String, @ViewBuilder caption: () -> Caption) where Header == Text { - self.init(header: { Text(verbatim: header) }, caption: caption) - } - - /// Create a new no-information text. - /// - Parameters: - /// - header: The localized header text. - /// - caption: The descriptive caption view. - public init(_ header: LocalizedStringResource, @ViewBuilder caption: () -> Caption) where Header == Text { - self.init(header: { Text(header) }, caption: caption) - } - - /// Create a new no-information text. - /// - Parameters: - /// - header: The header view. - /// - caption: The descriptive caption view. - public init(@ViewBuilder header: () -> Header, @ViewBuilder caption: () -> Caption) { - self.header = header() - self.caption = caption() - } -} - - -#if DEBUG -#Preview { - NoInformationText { - Text(verbatim: "No Information") - } caption: { - Text(verbatim: "Please add information to show some information.") - } -} - -#Preview { - GeometryReader { proxy in - List { - NoInformationText { - Text(verbatim: "No Information") - } caption: { - Text(verbatim: "Please add information to show some information.") - } - .listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0)) - .listRowBackground(Color.clear) - .frame(height: proxy.size.height - 100) - } - } -} -#endif diff --git a/Tests/SpeziViewsTests/SnapshotTests.swift b/Tests/SpeziViewsTests/SnapshotTests.swift index 8edfc75..820b498 100644 --- a/Tests/SpeziViewsTests/SnapshotTests.swift +++ b/Tests/SpeziViewsTests/SnapshotTests.swift @@ -13,14 +13,6 @@ import XCTest final class SnapshotTests: XCTestCase { - func testNoInformationText() { - let view = NoInformationText(verbatim: "No Contacts") { - Text(verbatim: "Newly added contacts will appear here.") - } - - assertSnapshot(of: view, as: .image(layout: .device(config: .iPhone13Pro))) - } - func testListRow() { let row = List { ListRow(verbatim: "San Francisco") { diff --git a/Tests/SpeziViewsTests/__Snapshots__/SnapshotTests/testNoInformationText.1.png b/Tests/SpeziViewsTests/__Snapshots__/SnapshotTests/testNoInformationText.1.png deleted file mode 100644 index aa94259..0000000 Binary files a/Tests/SpeziViewsTests/__Snapshots__/SnapshotTests/testNoInformationText.1.png and /dev/null differ