Revision control
Copy as Markdown
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
import SwiftUI
public struct CompatibilityBridge<Content> {
let content: Content
}
public extension CompatibilityBridge where Content: View {
@MainActor
@ViewBuilder
func glassButtonStyle() -> some View {
if #available(iOS 26, *) {
content.buttonStyle(.glass)
} else {
content.buttonStyle(.plain)
}
}
@MainActor
@ViewBuilder
func cardBackground(_ color: Color, cornerRadius: CGFloat) -> some View {
if #available(iOS 26, *) {
content.glassEffect(.regular.tint(color), in: .rect(cornerRadius: cornerRadius))
} else {
content.background(
RoundedRectangle(cornerRadius: cornerRadius)
.fill(color)
.accessibilityHidden(true)
)
}
}
}