40 lines
934 B
Swift
40 lines
934 B
Swift
import SwiftUI
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
@ViewBuilder
|
|
func platformCardStyle() -> some View {
|
|
#if os(tvOS)
|
|
self.buttonStyle(.card)
|
|
#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
|
|
}
|
|
}
|