Add iOS/iPad target with platform-adaptive UI
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
39
mlbTVOS/Views/Components/PlatformUI.swift
Normal file
39
mlbTVOS/Views/Components/PlatformUI.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user