From c2758b0d0cb8766817fe6192db3009af9be33ec3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 7 May 2026 18:36:47 +0200 Subject: [PATCH] Use light glass background for tvOS player control buttons --- Yattee/Views/Components/GlassBackground.swift | 16 ++++++++-- .../Player/tvOS/TVPlayerControlsView.swift | 31 ++++++++++++------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Yattee/Views/Components/GlassBackground.swift b/Yattee/Views/Components/GlassBackground.swift index cd2512ee..5e37c30f 100644 --- a/Yattee/Views/Components/GlassBackground.swift +++ b/Yattee/Views/Components/GlassBackground.swift @@ -68,11 +68,11 @@ struct GlassBackgroundModifier: ViewModifier { if #available(iOS 26.0, *) { content.modifier(LiquidGlassModifier(style: style, shape: shape, colorScheme: colorScheme)) } else { - content.modifier(FallbackGlassModifier(shape: shape, material: fallbackMaterial)) + content.modifier(FallbackGlassModifier(shape: shape, material: fallbackMaterial, colorScheme: colorScheme)) } #else - // macOS doesn't have glassEffect, always use fallback material - content.modifier(FallbackGlassModifier(shape: shape, material: fallbackMaterial)) + // macOS / tvOS don't have glassEffect, always use fallback material + content.modifier(FallbackGlassModifier(shape: shape, material: fallbackMaterial, colorScheme: colorScheme)) #endif } } @@ -127,6 +127,7 @@ private struct LiquidGlassModifier: ViewModifier { private struct FallbackGlassModifier: ViewModifier { let shape: GlassShape let material: GlassFallbackMaterial + let colorScheme: ColorScheme? func body(content: Content) -> some View { switch shape { @@ -147,6 +148,15 @@ private struct FallbackGlassModifier: ViewModifier { @ViewBuilder private var materialBackground: some View { + if let colorScheme { + rawMaterialBackground.environment(\.colorScheme, colorScheme) + } else { + rawMaterialBackground + } + } + + @ViewBuilder + private var rawMaterialBackground: some View { switch material { case .ultraThinMaterial: Rectangle().fill(.ultraThinMaterial) diff --git a/Yattee/Views/Player/tvOS/TVPlayerControlsView.swift b/Yattee/Views/Player/tvOS/TVPlayerControlsView.swift index 5a9ea092..80d9b985 100644 --- a/Yattee/Views/Player/tvOS/TVPlayerControlsView.swift +++ b/Yattee/Views/Player/tvOS/TVPlayerControlsView.swift @@ -353,9 +353,11 @@ struct TVActionButtonStyle: ButtonStyle { .minimumScaleFactor(0.8) .padding(.horizontal, 20) .frame(minWidth: 100, minHeight: 80) - .background( - RoundedRectangle(cornerRadius: 12) - .fill(isFocused ? .white.opacity(0.3) : .white.opacity(0.1)) + .glassBackground( + isFocused ? .tinted(.white.opacity(0.35)) : .regular, + in: .rect(cornerRadius: 12), + fallback: isFocused ? .ultraThickMaterial : .ultraThinMaterial, + colorScheme: .light ) .scaleEffect(configuration.isPressed ? 0.95 : (isFocused ? 1.05 : 1.0)) .animation(.easeInOut(duration: 0.15), value: isFocused) @@ -371,14 +373,17 @@ struct TVTransportButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { let size: CGFloat = isPrimary ? 88 : 72 + let style: GlassStyle = { + if isPrimary { + return isFocused ? .tinted(.white.opacity(0.85)) : .tinted(.white.opacity(0.35)) + } else { + return isFocused ? .tinted(.white.opacity(0.35)) : .regular + } + }() + let fallback: GlassFallbackMaterial = (isFocused || isPrimary) ? .ultraThickMaterial : .ultraThinMaterial return configuration.label .frame(width: size, height: size) - .background( - Circle() - .fill(isFocused - ? (isPrimary ? .white.opacity(0.95) : .white.opacity(0.3)) - : (isPrimary ? .white.opacity(0.25) : .white.opacity(0.12))) - ) + .glassBackground(style, in: .circle, fallback: fallback, colorScheme: .light) .foregroundStyle(isFocused && isPrimary ? Color.black : .white) .scaleEffect(configuration.isPressed ? 0.92 : (isFocused ? 1.08 : 1.0)) .animation(.easeInOut(duration: 0.15), value: isFocused) @@ -394,9 +399,11 @@ struct TVCloseButtonStyle: ButtonStyle { configuration.label .foregroundStyle(.white) .frame(width: 64, height: 64) - .background( - Circle() - .fill(isFocused ? .white.opacity(0.3) : .white.opacity(0.12)) + .glassBackground( + isFocused ? .tinted(.white.opacity(0.35)) : .regular, + in: .circle, + fallback: isFocused ? .ultraThickMaterial : .ultraThinMaterial, + colorScheme: .light ) .scaleEffect(configuration.isPressed ? 0.92 : (isFocused ? 1.08 : 1.0)) .animation(.easeInOut(duration: 0.15), value: isFocused)