Fix glassEffect API availability for macOS and tvOS

- Make glassEffect iOS-only as it's not available on other platforms
- Use ultraThinMaterial fallback for macOS and tvOS
- Fixes build error in GitHub Actions with Xcode 16.4
This commit is contained in:
Arkadiusz Fal
2025-11-10 12:47:11 +01:00
parent 86b74d53ca
commit bec29668a0

View File

@@ -354,7 +354,8 @@ extension View {
@ViewBuilder
func applyControlsBackground(enabled: Bool, cornerRadius: Double) -> some View {
if enabled {
if #available(iOS 26.0, macOS 26.0, tvOS 26.0, *) {
#if os(iOS)
if #available(iOS 26.0, *) {
// Use Liquid Glass on iOS 26+
self.glassEffect(
.regular.interactive(),
@@ -363,7 +364,7 @@ extension View {
} else {
// Fallback to ultraThinMaterial
// swiftlint:disable:next deployment_target
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
if #available(iOS 15.0, *) {
self
.background(
RoundedRectangle(cornerRadius: cornerRadius)
@@ -385,6 +386,31 @@ extension View {
)
}
}
#else
// Fallback to ultraThinMaterial for macOS and tvOS
// swiftlint:disable:next deployment_target
if #available(macOS 12.0, tvOS 15.0, *) {
self
.background(
RoundedRectangle(cornerRadius: cornerRadius)
.fill(.ultraThinMaterial)
)
.overlay(
RoundedRectangle(cornerRadius: cornerRadius)
.stroke(Color("ControlsBorderColor"), lineWidth: 0.5)
)
} else {
self
.background(
RoundedRectangle(cornerRadius: cornerRadius)
.fill(Color.gray.opacity(0.3))
)
.overlay(
RoundedRectangle(cornerRadius: cornerRadius)
.stroke(Color("ControlsBorderColor"), lineWidth: 0.5)
)
}
#endif
} else {
self.background(Color.clear)
}