import SwiftUI // MARK: - iOS Press Style struct PlatformPressButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .scaleEffect(configuration.isPressed ? 0.98 : 1.0) .opacity(configuration.isPressed ? 0.92 : 1.0) .animation(.easeOut(duration: 0.16), value: configuration.isPressed) } } // MARK: - tvOS Focus Style #if os(tvOS) struct TVFocusButtonStyle: ButtonStyle { @Environment(\.isFocused) private var isFocused func makeBody(configuration: Configuration) -> some View { configuration.label .scaleEffect(configuration.isPressed ? 0.97 : isFocused ? 1.04 : 1.0) .opacity(configuration.isPressed ? 0.85 : 1.0) .overlay( RoundedRectangle(cornerRadius: 24, style: .continuous) .strokeBorder(.white.opacity(isFocused ? 0.3 : 0), lineWidth: 2) ) .shadow( color: isFocused ? .white.opacity(0.12) : .clear, radius: isFocused ? 20 : 0, y: isFocused ? 8 : 0 ) .animation(.easeInOut(duration: 0.2), value: isFocused) .animation(.easeOut(duration: 0.12), value: configuration.isPressed) } } #endif // MARK: - Platform Extensions extension View { @ViewBuilder func platformCardStyle() -> some View { #if os(tvOS) self.buttonStyle(TVFocusButtonStyle()) #else self.buttonStyle(PlatformPressButtonStyle()) #endif } @ViewBuilder func platformFocusSection() -> some View { #if os(tvOS) self.focusSection() #else self #endif } @ViewBuilder func platformFocusable(_ enabled: Bool = true) -> some View { #if os(tvOS) self.focusable(enabled) #else self #endif } }