// // Swiftfin is subject to the terms of the Mozilla Public // License, v2.0. If a copy of the MPL was not distributed with this // file, you can obtain one at https://mozilla.org/MPL/2.0/. // // Copyright (c) 2026 Jellyfin & Jellyfin Contributors // // Adapted for Tunavelo from Swiftfin 8a515c580e8b96eaeffcecdfeb14a1c97ef9264e Shared/Components/PosterButton.swift // import SwiftUI /// A poster that acts as a button. Apple's `.borderless` style gives the focus lift on tvOS and the highlight under a pointer; /// `.plain` elsewhere. Upstream's context-menu preview (`.backport.glassEffect`) draws with `tunaveloGlass`. public struct PosterButton: View { private let item: Item private let action: (Item) -> Void private let label: (Item) -> Label public init(item: Item, action: @escaping (Item) -> Void, @ViewBuilder label: @escaping (Item) -> Label) { self.item = item self.action = action self.label = label } public var body: some View { Button { action(item) } label: { label(item) } #if os(tvOS) .buttonStyle(.borderless) #else .buttonStyle(.plain) #endif #if os(iOS) .hoverEffect(.highlight) #endif .buttonBorderShape(.roundedRectangle) } /// The preview a context menu shows for [item]: the label on glass, as upstream's `contextMenuPreview`. public func contextMenuPreview(width: CGFloat) -> some View { label(item).frame(width: width).padding(Theme.Spacing.m).tunaveloGlass(.contextMenu, radius: 10) } }