Files
yattee/Yattee/Views/Video/VideoInfoPlayThumbnailTip.swift
2026-10-02 22:22:13 +02:00

60 lines
1.6 KiB
Swift

//
// VideoInfoPlayThumbnailTip.swift
// Yattee
//
// TipKit hint that the hero thumbnail plays the video. Shown once, only while the
// toolbar action layout is active (the inline layout has an explicit Play button).
// When the thumbnail is a carousel over the video's context, it also mentions swiping.
//
#if !os(tvOS)
import SwiftUI
import TipKit
struct VideoInfoPlayThumbnailTip: Tip {
/// Mirrors `SettingsManager.videoInfoActionsLayout == .toolbar`; updated by VideoInfoView.
@Parameter
static var isToolbarLayout: Bool = false
/// Whether the thumbnail can be swiped to browse other videos in the context.
var canSwipe = false
var title: Text {
Text(String(localized: "videoInfo.playTip.title"))
}
var message: Text? {
Text(canSwipe
? String(localized: "videoInfo.playTip.messageWithSwipe")
: String(localized: "videoInfo.playTip.message"))
}
var image: Image? {
Image(systemName: "play.circle")
}
var rules: [Rule] {
#Rule(Self.$isToolbarLayout) { $0 == true }
}
}
/// Attaches the play-thumbnail tip to the hero thumbnail when enabled.
struct VideoInfoPlayThumbnailTipModifier: ViewModifier {
let enabled: Bool
private let tip: VideoInfoPlayThumbnailTip
init(enabled: Bool, canSwipe: Bool) {
self.enabled = enabled
self.tip = VideoInfoPlayThumbnailTip(canSwipe: canSwipe)
}
func body(content: Content) -> some View {
if enabled {
content.popoverTip(tip, arrowEdge: .top)
} else {
content
}
}
}
#endif