mirror of
https://github.com/yattee/yattee.git
synced 2026-05-12 18:35:05 +00:00
Remove tvOS close button from MPV debug stats overlay
Menu remote already dismisses the overlay via TVPlayerView's exit command handler, so the in-overlay close button is redundant.
This commit is contained in:
@@ -54,21 +54,14 @@ struct MPVDebugOverlay: View {
|
|||||||
let stats: MPVDebugStats
|
let stats: MPVDebugStats
|
||||||
@Binding var isVisible: Bool
|
@Binding var isVisible: Bool
|
||||||
var isLandscape: Bool = false
|
var isLandscape: Bool = false
|
||||||
/// Callback for tvOS close button (tvOS can't tap outside to dismiss)
|
|
||||||
var onClose: (() -> Void)?
|
|
||||||
|
|
||||||
@Environment(\.colorScheme) private var colorScheme
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
|
|
||||||
#if os(tvOS)
|
|
||||||
@FocusState private var isCloseButtonFocused: Bool
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Font sizes - platform-specific (tvOS needs larger sizes for TV viewing distance)
|
// Font sizes - platform-specific (tvOS needs larger sizes for TV viewing distance)
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
private var headerSize: CGFloat { 32 }
|
private var headerSize: CGFloat { 32 }
|
||||||
private var sectionSize: CGFloat { 26 }
|
private var sectionSize: CGFloat { 26 }
|
||||||
private var rowSize: CGFloat { 24 }
|
private var rowSize: CGFloat { 24 }
|
||||||
private var closeButtonSize: CGFloat { 28 }
|
|
||||||
private var columnSpacing: CGFloat { 40 }
|
private var columnSpacing: CGFloat { 40 }
|
||||||
private var columnMinWidth: CGFloat { 280 }
|
private var columnMinWidth: CGFloat { 280 }
|
||||||
private var maxOverlayWidth: CGFloat { 1450 } // Extra width for Frame Sync column
|
private var maxOverlayWidth: CGFloat { 1450 } // Extra width for Frame Sync column
|
||||||
@@ -139,54 +132,13 @@ struct MPVDebugOverlay: View {
|
|||||||
portraitLayout
|
portraitLayout
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// tvOS close button at bottom
|
|
||||||
#if os(tvOS)
|
|
||||||
tvOSCloseButton
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
.padding(padding)
|
.padding(padding)
|
||||||
.glassBackground(.regular, in: .rect(cornerRadius: cornerRadius))
|
.glassBackground(.regular, in: .rect(cornerRadius: cornerRadius))
|
||||||
.shadow(radius: isLandscape ? 8 : 6)
|
.shadow(radius: isLandscape ? 8 : 6)
|
||||||
.frame(maxWidth: maxOverlayWidth)
|
.frame(maxWidth: maxOverlayWidth)
|
||||||
#if os(tvOS)
|
|
||||||
.onAppear {
|
|
||||||
isCloseButtonFocused = true
|
|
||||||
}
|
|
||||||
.onExitCommand {
|
|
||||||
onClose?()
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(tvOS)
|
|
||||||
@ViewBuilder
|
|
||||||
private var tvOSCloseButton: some View {
|
|
||||||
Button {
|
|
||||||
onClose?()
|
|
||||||
} label: {
|
|
||||||
HStack(spacing: 12) {
|
|
||||||
Image(systemName: "xmark.circle")
|
|
||||||
.font(.system(size: closeButtonSize))
|
|
||||||
Text(String(localized: "common.close"))
|
|
||||||
.font(.system(size: rowSize, weight: .medium))
|
|
||||||
}
|
|
||||||
.foregroundStyle(.white)
|
|
||||||
.frame(width: 180, height: 70)
|
|
||||||
.background(
|
|
||||||
RoundedRectangle(cornerRadius: 12)
|
|
||||||
.fill(isCloseButtonFocused ? .white.opacity(0.3) : .white.opacity(0.15))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.buttonStyle(.plain)
|
|
||||||
.scaleEffect(isCloseButtonFocused ? 1.05 : 1.0)
|
|
||||||
.animation(.easeInOut(duration: 0.15), value: isCloseButtonFocused)
|
|
||||||
.focused($isCloseButtonFocused)
|
|
||||||
.padding(.top, 20)
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// MARK: - Portrait Layout (Compact)
|
// MARK: - Portrait Layout (Compact)
|
||||||
|
|
||||||
private var portraitLayout: some View {
|
private var portraitLayout: some View {
|
||||||
|
|||||||
@@ -286,8 +286,7 @@ struct TVPlayerView: View {
|
|||||||
MPVDebugOverlay(
|
MPVDebugOverlay(
|
||||||
stats: debugStats,
|
stats: debugStats,
|
||||||
isVisible: $isDebugOverlayVisible,
|
isVisible: $isDebugOverlayVisible,
|
||||||
isLandscape: true,
|
isLandscape: true
|
||||||
onClose: { hideDebugOverlay() }
|
|
||||||
)
|
)
|
||||||
.transition(.opacity.combined(with: .scale(scale: 0.95)))
|
.transition(.opacity.combined(with: .scale(scale: 0.95)))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user