diff --git a/RevenueCatUI/CustomerCenter/Views/CompatibilityContentUnavailableView.swift b/RevenueCatUI/CustomerCenter/Views/CompatibilityContentUnavailableView.swift index afffad2d93..a16869050c 100644 --- a/RevenueCatUI/CustomerCenter/Views/CompatibilityContentUnavailableView.swift +++ b/RevenueCatUI/CustomerCenter/Views/CompatibilityContentUnavailableView.swift @@ -24,19 +24,33 @@ import SwiftUI @available(tvOS, unavailable) @available(watchOS, unavailable) struct CompatibilityContentUnavailableView: View { - @State var title: String - @State var description: String - @State var systemImage: String + let title: String + let systemImage: String + let description: Text? + + init(_ title: String, systemImage: String, description: Text? = nil) { + self.title = title + self.systemImage = systemImage + self.description = description + } var body: some View { if #available(iOS 17.0, *) { #if swift(>=5.9) + if let description { ContentUnavailableView( title, systemImage: systemImage, - description: Text(description) + description: description ) + } else { + ContentUnavailableView( + title, + systemImage: systemImage + ) + } + #else // In Xcode 14, any references to ContentUnavailableView would fail to compile since that entity // was included with Xcode 15 and later. @@ -57,9 +71,11 @@ struct CompatibilityContentUnavailableView: View { .font(.title2) .bold() - Text(description) - .font(.subheadline) - .foregroundStyle(.secondary) + if let description { + description + .font(.subheadline) + .foregroundStyle(.secondary) + } }.frame(maxHeight: .infinity) } diff --git a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift index 793dcfd858..cc51fb417a 100644 --- a/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift +++ b/RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift @@ -59,10 +59,11 @@ struct NoSubscriptionsView: View { } VStack { CompatibilityContentUnavailableView( - title: self.configuration.screens[.noActive]?.title ?? "No subscriptions found", + self.configuration.screens[.noActive]?.title ?? "No subscriptions found", + systemImage: "exclamationmark.triangle.fill", description: - self.configuration.screens[.noActive]?.subtitle ?? fallbackDescription, - systemImage: "exclamationmark.triangle.fill" + Text(self.configuration.screens[.noActive]?.subtitle ?? fallbackDescription) + ) Spacer() diff --git a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift index 0882350697..58ed04dffb 100644 --- a/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift +++ b/RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift @@ -59,9 +59,9 @@ struct WrongPlatformView: View { let platformInstructions = self.humanReadableInstructions(for: store) CompatibilityContentUnavailableView( - title: platformInstructions.0, - description: platformInstructions.1, - systemImage: "exclamationmark.triangle.fill" + platformInstructions.0, + systemImage: "exclamationmark.triangle.fill", + description: Text(platformInstructions.1) ) } .padding(.horizontal)