Skip to content

Commit

Permalink
fix: Use custom label for CompatibilityContentUnavailableView (#4647)
Browse files Browse the repository at this point in the history
  • Loading branch information
facumenzella authored Jan 13, 2025
1 parent c100009 commit 70b0791
Showing 1 changed file with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,11 @@ struct CompatibilityContentUnavailableView: View {

if #available(iOS 17.0, *) {
#if swift(>=5.9)
if let description {
ContentUnavailableView(
title,
systemImage: systemImage,
description: description
)
} else {
ContentUnavailableView(
title,
systemImage: systemImage
)
ContentUnavailableView {
Label { titleView }
icon: { iconView }
}
description: { description }

#else
// In Xcode 14, any references to ContentUnavailableView would fail to compile since that entity
Expand All @@ -60,16 +53,8 @@ struct CompatibilityContentUnavailableView: View {
#endif
} else {
VStack {
Image(systemName: systemImage)
.resizable()
.scaledToFill()
.frame(width: 48, height: 48)
.foregroundStyle(.secondary)
.padding()

Text(title)
.font(.title2)
.bold()
iconView
titleView

if let description {
description
Expand All @@ -80,6 +65,22 @@ struct CompatibilityContentUnavailableView: View {
}

}

private var titleView: some View {
Text(title)
.font(.title2)
.bold()
.fixedSize(horizontal: false, vertical: true)
}

private var iconView: some View {
Image(systemName: systemImage)
.resizable()
.scaledToFill()
.frame(width: 48, height: 48)
.foregroundStyle(.secondary)
.padding()
}
}

#endif

0 comments on commit 70b0791

Please sign in to comment.