mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
parent
1e2d6cf72f
commit
eed9330c0c
@ -102,6 +102,7 @@ struct ChannelPlaylistView: View {
|
||||
ToolbarItem(placement: playlistButtonsPlacement) {
|
||||
HStack {
|
||||
ListingStyleButtons(listingStyle: $channelPlaylistListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
ShareButton(contentItem: contentItem)
|
||||
|
||||
@ -131,6 +132,7 @@ struct ChannelPlaylistView: View {
|
||||
ListingStyleButtons(listingStyle: $channelPlaylistListingStyle)
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,7 @@ struct ChannelVideosView: View {
|
||||
}
|
||||
|
||||
ListingStyleButtons(listingStyle: $channelPlaylistListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
contentTypePicker
|
||||
}
|
||||
@ -281,6 +282,7 @@ struct ChannelVideosView: View {
|
||||
ListingStyleButtons(listingStyle: $channelPlaylistListingStyle)
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ extension Defaults.Keys {
|
||||
static let channelPlaylistListingStyle = Key<ListingStyle>("channelPlaylistListingStyle", default: .cells)
|
||||
static let searchListingStyle = Key<ListingStyle>("searchListingStyle", default: .cells)
|
||||
static let hideShorts = Key<Bool>("hideShorts", default: false)
|
||||
static let hideWatched = Key<Bool>("hideWatched", default: false)
|
||||
static let showInspector = Key<ShowInspectorSetting>("showInspector", default: .onlyLocal)
|
||||
}
|
||||
|
||||
|
@ -7,22 +7,17 @@ struct PlayerQueueRow: View {
|
||||
let item: PlayerQueueItem
|
||||
var history = false
|
||||
var autoplay = false
|
||||
var watch: Watch?
|
||||
|
||||
private var player = PlayerModel.shared
|
||||
|
||||
@Default(.closePiPOnNavigation) var closePiPOnNavigation
|
||||
|
||||
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
||||
|
||||
init(item: PlayerQueueItem, history: Bool = false, autoplay: Bool = false) {
|
||||
init(item: PlayerQueueItem, history: Bool = false, autoplay: Bool = false, watch: Watch? = nil) {
|
||||
self.item = item
|
||||
self.history = history
|
||||
self.autoplay = autoplay
|
||||
_watchRequest = FetchRequest<Watch>(
|
||||
entity: Watch.entity(),
|
||||
sortDescriptors: [],
|
||||
predicate: NSPredicate(format: "videoID = %@", item.videoID)
|
||||
)
|
||||
self.watch = watch
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -80,10 +75,6 @@ struct PlayerQueueRow: View {
|
||||
#endif
|
||||
}
|
||||
|
||||
private var watch: Watch? {
|
||||
watchRequest.first
|
||||
}
|
||||
|
||||
private var watchStoppedAt: CMTime? {
|
||||
guard let seconds = watch?.stoppedAt else {
|
||||
return nil
|
||||
|
@ -145,6 +145,9 @@ struct PlaylistsView: View {
|
||||
ToolbarItem {
|
||||
ListingStyleButtons(listingStyle: $playlistListingStyle)
|
||||
}
|
||||
ToolbarItem {
|
||||
HideWatchedButtons()
|
||||
}
|
||||
ToolbarItem {
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
@ -216,6 +219,7 @@ struct PlaylistsView: View {
|
||||
ListingStyleButtons(listingStyle: $playlistListingStyle)
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
|
||||
@ -386,6 +390,7 @@ struct PlaylistsView: View {
|
||||
Spacer()
|
||||
|
||||
ListingStyleButtons(listingStyle: $playlistListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
#else
|
||||
Spacer()
|
||||
|
@ -76,6 +76,7 @@ struct SearchView: View {
|
||||
#if os(macOS)
|
||||
ToolbarItemGroup(placement: toolbarPlacement) {
|
||||
ListingStyleButtons(listingStyle: $searchListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
FavoriteButton(item: favoriteItem)
|
||||
.id(favoriteItem?.id)
|
||||
@ -214,6 +215,7 @@ struct SearchView: View {
|
||||
ListingStyleButtons(listingStyle: $searchListingStyle)
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
|
||||
@ -571,6 +573,7 @@ struct SearchView: View {
|
||||
|
||||
Spacer()
|
||||
ListingStyleButtons(listingStyle: $searchListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
.labelStyle(.iconOnly)
|
||||
|
@ -54,6 +54,7 @@ struct FeedView: View {
|
||||
#if os(tvOS)
|
||||
SubscriptionsPageButton()
|
||||
ListingStyleButtons(listingStyle: $subscriptionsListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
#endif
|
||||
|
||||
|
@ -46,6 +46,7 @@ struct SubscriptionsView: View {
|
||||
.toolbar {
|
||||
ToolbarItemGroup {
|
||||
ListingStyleButtons(listingStyle: $subscriptionsListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
toggleWatchedButton
|
||||
.id(feed.watchedId)
|
||||
@ -73,6 +74,7 @@ struct SubscriptionsView: View {
|
||||
}
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,10 @@ struct TrendingView: View {
|
||||
ListingStyleButtons(listingStyle: $trendingListingStyle)
|
||||
}
|
||||
|
||||
ToolbarItem {
|
||||
HideWatchedButtons()
|
||||
}
|
||||
|
||||
ToolbarItem {
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
@ -174,6 +178,7 @@ struct TrendingView: View {
|
||||
ListingStyleButtons(listingStyle: $trendingListingStyle)
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
|
||||
@ -247,6 +252,7 @@ struct TrendingView: View {
|
||||
|
||||
Spacer()
|
||||
ListingStyleButtons(listingStyle: $trendingListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
|
||||
Button {
|
||||
|
@ -6,6 +6,7 @@ import SwiftUI
|
||||
struct VideoCell: View {
|
||||
var id: String?
|
||||
private var video: Video
|
||||
private var watch: Watch?
|
||||
|
||||
@Environment(\.horizontalCells) private var horizontalCells
|
||||
@Environment(\.inChannelView) private var inChannelView
|
||||
@ -27,12 +28,10 @@ struct VideoCell: View {
|
||||
private var navigation: NavigationModel { .shared }
|
||||
private var player: PlayerModel { .shared }
|
||||
|
||||
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
||||
|
||||
init(id: String? = nil, video: Video) {
|
||||
init(id: String? = nil, video: Video, watch: Watch? = nil) {
|
||||
self.id = id
|
||||
self.video = video
|
||||
_watchRequest = video.watchFetchRequest
|
||||
self.watch = watch
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -107,10 +106,6 @@ struct VideoCell: View {
|
||||
watchedVideoPlayNowBehavior == .continue
|
||||
}
|
||||
|
||||
private var watch: Watch? {
|
||||
watchRequest.first
|
||||
}
|
||||
|
||||
private var finished: Bool {
|
||||
watch?.finished ?? false
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import Defaults
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
@ -6,6 +7,18 @@ struct ContentItemView: View {
|
||||
@Environment(\.listingStyle) private var listingStyle
|
||||
@Environment(\.noListingDividers) private var noListingDividers
|
||||
@Environment(\.hideShorts) private var hideShorts
|
||||
@Default(.hideWatched) private var hideWatched
|
||||
|
||||
@FetchRequest private var watchRequest: FetchedResults<Watch>
|
||||
|
||||
init(item: ContentItem) {
|
||||
self.item = item
|
||||
if item.contentType == .video, let video = item.video {
|
||||
_watchRequest = video.watchFetchRequest
|
||||
} else {
|
||||
_watchRequest = Video.fixture.watchFetchRequest
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder var body: some View {
|
||||
if itemVisible {
|
||||
@ -26,6 +39,10 @@ struct ContentItemView: View {
|
||||
}
|
||||
|
||||
var itemVisible: Bool {
|
||||
if hideWatched, watch?.finished ?? false {
|
||||
return false
|
||||
}
|
||||
|
||||
guard hideShorts, item.contentType == .video, let video = item.video else {
|
||||
return true
|
||||
}
|
||||
@ -35,10 +52,10 @@ struct ContentItemView: View {
|
||||
|
||||
@ViewBuilder func videoItem(_ video: Video) -> some View {
|
||||
if listingStyle == .cells {
|
||||
VideoCell(video: video)
|
||||
VideoCell(video: video, watch: watch)
|
||||
} else {
|
||||
let item = PlayerQueueItem(video)
|
||||
PlayerQueueRow(item: item)
|
||||
PlayerQueueRow(item: item, watch: watch)
|
||||
.contextMenu {
|
||||
VideoContextMenuView(video: video)
|
||||
}
|
||||
@ -99,4 +116,8 @@ struct ContentItemView: View {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private var watch: Watch? {
|
||||
watchRequest.first
|
||||
}
|
||||
}
|
||||
|
35
Shared/Views/HideWatchedButtons.swift
Normal file
35
Shared/Views/HideWatchedButtons.swift
Normal file
@ -0,0 +1,35 @@
|
||||
import Defaults
|
||||
import SwiftUI
|
||||
|
||||
struct HideWatchedButtons: View {
|
||||
@Default(.hideWatched) private var hideWatched
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
hideWatched.toggle()
|
||||
} label: {
|
||||
Group {
|
||||
if hideWatched {
|
||||
Label("Watched: hidden", systemImage: "clock")
|
||||
.help("Watched: hidden")
|
||||
} else {
|
||||
Label("Watched: visible", systemImage: "clock.fill")
|
||||
.help("Watched: visible")
|
||||
}
|
||||
}
|
||||
#if os(tvOS)
|
||||
.font(.caption)
|
||||
.imageScale(.small)
|
||||
#endif
|
||||
}
|
||||
.transaction { t in t.disablesAnimations = true }
|
||||
}
|
||||
}
|
||||
|
||||
struct HideWatchedButtons_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VStack {
|
||||
HideWatchedButtons()
|
||||
}
|
||||
}
|
||||
}
|
@ -71,6 +71,10 @@ struct PopularView: View {
|
||||
ListingStyleButtons(listingStyle: $popularListingStyle)
|
||||
}
|
||||
|
||||
ToolbarItem {
|
||||
HideWatchedButtons()
|
||||
}
|
||||
|
||||
ToolbarItem {
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
@ -90,6 +94,7 @@ struct PopularView: View {
|
||||
ListingStyleButtons(listingStyle: $popularListingStyle)
|
||||
|
||||
Section {
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
}
|
||||
|
||||
@ -129,6 +134,7 @@ struct PopularView: View {
|
||||
HStack {
|
||||
Spacer()
|
||||
ListingStyleButtons(listingStyle: $popularListingStyle)
|
||||
HideWatchedButtons()
|
||||
HideShortsButtons(hide: $hideShorts)
|
||||
|
||||
Button {
|
||||
|
@ -550,6 +550,9 @@
|
||||
3774127627387EA200423605 /* Siesta in Frameworks */ = {isa = PBXBuildFile; productRef = 3774127527387EA200423605 /* Siesta */; };
|
||||
3774127A27387EBC00423605 /* Defaults in Frameworks */ = {isa = PBXBuildFile; productRef = 3774127927387EBC00423605 /* Defaults */; };
|
||||
3774127C27387EC800423605 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 3774127B27387EC800423605 /* Alamofire */; };
|
||||
37758C0B2A1D1C8B001FD900 /* HideWatchedButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37758C0A2A1D1C8B001FD900 /* HideWatchedButtons.swift */; };
|
||||
37758C0C2A1D1C8B001FD900 /* HideWatchedButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37758C0A2A1D1C8B001FD900 /* HideWatchedButtons.swift */; };
|
||||
37758C0D2A1D1C8B001FD900 /* HideWatchedButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37758C0A2A1D1C8B001FD900 /* HideWatchedButtons.swift */; };
|
||||
3776924E294630110055EC18 /* ChannelAvatarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3776924D294630110055EC18 /* ChannelAvatarView.swift */; };
|
||||
3776924F294630110055EC18 /* ChannelAvatarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3776924D294630110055EC18 /* ChannelAvatarView.swift */; };
|
||||
37769250294630110055EC18 /* ChannelAvatarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3776924D294630110055EC18 /* ChannelAvatarView.swift */; };
|
||||
@ -1327,6 +1330,7 @@
|
||||
37732FEF2703A26300F04329 /* AccountValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountValidationStatus.swift; sourceTree = "<group>"; };
|
||||
37732FF32703D32400F04329 /* Sidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sidebar.swift; sourceTree = "<group>"; };
|
||||
37737785276F9858000521C1 /* Windows.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Windows.swift; sourceTree = "<group>"; };
|
||||
37758C0A2A1D1C8B001FD900 /* HideWatchedButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HideWatchedButtons.swift; sourceTree = "<group>"; };
|
||||
3776924D294630110055EC18 /* ChannelAvatarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelAvatarView.swift; sourceTree = "<group>"; };
|
||||
3776925129463C310055EC18 /* PlaylistsCacheModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistsCacheModel.swift; sourceTree = "<group>"; };
|
||||
377692552946476F0055EC18 /* ChannelPlaylistsCacheModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelPlaylistsCacheModel.swift; sourceTree = "<group>"; };
|
||||
@ -1876,6 +1880,7 @@
|
||||
3748186D26A769D60084E870 /* DetailBadge.swift */,
|
||||
37599F37272B4D740087F250 /* FavoriteButton.swift */,
|
||||
379EF9DF29AA585F009FE6C6 /* HideShortsButtons.swift */,
|
||||
37758C0A2A1D1C8B001FD900 /* HideWatchedButtons.swift */,
|
||||
37152EE926EFEB95004FB96D /* LazyView.swift */,
|
||||
371CC7732946963000979C1A /* ListingStyleButtons.swift */,
|
||||
37030FF627B0347C00ECDDAA /* MPVPlayerView.swift */,
|
||||
@ -3131,6 +3136,7 @@
|
||||
37F64FE426FE70A60081B69E /* RedrawOnModifier.swift in Sources */,
|
||||
37EBD8C427AF0DA800F1C24B /* PlayerBackend.swift in Sources */,
|
||||
376A33E02720CAD6000C1D6B /* VideosApp.swift in Sources */,
|
||||
37758C0B2A1D1C8B001FD900 /* HideWatchedButtons.swift in Sources */,
|
||||
374AB3DB28BCAF7E00DF56FB /* SeekType.swift in Sources */,
|
||||
37192D5728B179D60012EEDD /* ChaptersView.swift in Sources */,
|
||||
37D836BC294927E700005E5E /* ChannelsCacheModel.swift in Sources */,
|
||||
@ -3443,6 +3449,7 @@
|
||||
37F7AB5528A951B200FB46B5 /* Power.swift in Sources */,
|
||||
372CFD16285F2E2A00B0B54B /* ControlsBar.swift in Sources */,
|
||||
37FFC441272734C3009FFD26 /* Throttle.swift in Sources */,
|
||||
37758C0C2A1D1C8B001FD900 /* HideWatchedButtons.swift in Sources */,
|
||||
37169AA72729E2CC0011DE61 /* AccountsBridge.swift in Sources */,
|
||||
379EF9E129AA585F009FE6C6 /* HideShortsButtons.swift in Sources */,
|
||||
37BA793C26DB8EE4002A0235 /* PlaylistVideosView.swift in Sources */,
|
||||
@ -3832,6 +3839,7 @@
|
||||
372D85DF283842EC00FF3C7D /* PiPDelegate.swift in Sources */,
|
||||
378E9C3A294552A700B2D696 /* ThumbnailView.swift in Sources */,
|
||||
372D85E0283842EE00FF3C7D /* PlayerLayerView.swift in Sources */,
|
||||
37758C0D2A1D1C8B001FD900 /* HideWatchedButtons.swift in Sources */,
|
||||
37CEE4C32677B697005A1EFE /* Stream.swift in Sources */,
|
||||
37F64FE626FE70A60081B69E /* RedrawOnModifier.swift in Sources */,
|
||||
37DCD3192A191A180059A470 /* AVPlayerViewController+FullScreen.swift in Sources */,
|
||||
|
Loading…
Reference in New Issue
Block a user