2022-11-13 22:36:46 +00:00
|
|
|
import Defaults
|
2022-11-13 17:52:15 +00:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct VideoDetailsTool: Identifiable {
|
2022-11-18 21:22:57 +00:00
|
|
|
static let all = [
|
|
|
|
Self(icon: "info.circle", name: "Info", page: .info),
|
|
|
|
Self(icon: "wand.and.stars", name: "Inspector", page: .inspector),
|
|
|
|
Self(icon: "bookmark", name: "Chapters", page: .chapters),
|
|
|
|
Self(icon: "text.bubble", name: "Comments", page: .comments),
|
|
|
|
Self(icon: "rectangle.stack.fill", name: "Related", page: .related),
|
|
|
|
Self(icon: "list.number", name: "Queue", page: .queue)
|
|
|
|
]
|
|
|
|
|
|
|
|
static func find(for page: VideoDetails.DetailsPage) -> Self? {
|
|
|
|
all.first { $0.page == page }
|
|
|
|
}
|
|
|
|
|
2022-11-13 17:52:15 +00:00
|
|
|
var id: String {
|
|
|
|
page.rawValue
|
|
|
|
}
|
|
|
|
|
|
|
|
var icon: String
|
|
|
|
var name: String
|
|
|
|
var toolPostion: CGRect = .zero
|
|
|
|
var page = VideoDetails.DetailsPage.info
|
|
|
|
|
|
|
|
func isAvailable(for video: Video?, sidebarQueue: Bool) -> Bool {
|
|
|
|
guard !YatteeApp.isForPreviews else {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
switch page {
|
|
|
|
case .info:
|
|
|
|
return video != nil && !video!.isLocal
|
|
|
|
case .inspector:
|
2022-11-13 22:36:46 +00:00
|
|
|
return video == nil || Defaults[.showInspector] == .always || video!.isLocal
|
2022-11-13 17:52:15 +00:00
|
|
|
case .chapters:
|
|
|
|
return video != nil && !video!.chapters.isEmpty
|
|
|
|
case .comments:
|
|
|
|
return video != nil && !video!.isLocal
|
|
|
|
case .related:
|
|
|
|
return !sidebarQueue && video != nil && !video!.isLocal
|
|
|
|
case .queue:
|
|
|
|
return !sidebarQueue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|