Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility content unavailable improvements #4197

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}

Expand Down
7 changes: 4 additions & 3 deletions RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down