diff --git a/Pearvidious.xcodeproj/project.pbxproj b/Pearvidious.xcodeproj/project.pbxproj index 1743cc9a..fa022e6a 100644 --- a/Pearvidious.xcodeproj/project.pbxproj +++ b/Pearvidious.xcodeproj/project.pbxproj @@ -106,9 +106,6 @@ 376CD21626FBE18D001E1AC1 /* Instance+Fixtures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376CD21526FBE18D001E1AC1 /* Instance+Fixtures.swift */; }; 376CD21726FBE18D001E1AC1 /* Instance+Fixtures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376CD21526FBE18D001E1AC1 /* Instance+Fixtures.swift */; }; 376CD21826FBE18D001E1AC1 /* Instance+Fixtures.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376CD21526FBE18D001E1AC1 /* Instance+Fixtures.swift */; }; - 37754C9D26B7500000DBD602 /* VideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37754C9C26B7500000DBD602 /* VideosView.swift */; }; - 37754C9E26B7500000DBD602 /* VideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37754C9C26B7500000DBD602 /* VideosView.swift */; }; - 37754C9F26B7500000DBD602 /* VideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37754C9C26B7500000DBD602 /* VideosView.swift */; }; 377A20A92693C9A2002842B8 /* TypedContentAccessors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377A20A82693C9A2002842B8 /* TypedContentAccessors.swift */; }; 377A20AA2693C9A2002842B8 /* TypedContentAccessors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377A20A82693C9A2002842B8 /* TypedContentAccessors.swift */; }; 377A20AB2693C9A2002842B8 /* TypedContentAccessors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377A20A82693C9A2002842B8 /* TypedContentAccessors.swift */; }; @@ -154,7 +151,6 @@ 37AAF29026740715007FC770 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF28F26740715007FC770 /* Channel.swift */; }; 37AAF29126740715007FC770 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF28F26740715007FC770 /* Channel.swift */; }; 37AAF29226740715007FC770 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF28F26740715007FC770 /* Channel.swift */; }; - 37AAF29A26740A01007FC770 /* VideosListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF29926740A01007FC770 /* VideosListView.swift */; }; 37AAF2A026741C97007FC770 /* SubscriptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF29F26741C97007FC770 /* SubscriptionsView.swift */; }; 37AAF2A126741C97007FC770 /* SubscriptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF29F26741C97007FC770 /* SubscriptionsView.swift */; }; 37AAF2A226741C97007FC770 /* SubscriptionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37AAF29F26741C97007FC770 /* SubscriptionsView.swift */; }; @@ -338,7 +334,6 @@ 376578902685490700D4EA09 /* PlaylistsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistsView.swift; sourceTree = ""; }; 376B2E0626F920D600B1D64D /* SignInRequiredView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInRequiredView.swift; sourceTree = ""; }; 376CD21526FBE18D001E1AC1 /* Instance+Fixtures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Instance+Fixtures.swift"; sourceTree = ""; }; - 37754C9C26B7500000DBD602 /* VideosView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideosView.swift; sourceTree = ""; }; 377A20A82693C9A2002842B8 /* TypedContentAccessors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypedContentAccessors.swift; sourceTree = ""; }; 3788AC2626F6840700F6BAA9 /* WatchNowSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchNowSection.swift; sourceTree = ""; }; 3788AC2A26F6842D00F6BAA9 /* WatchNowSectionBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchNowSectionBody.swift; sourceTree = ""; }; @@ -353,7 +348,6 @@ 37AAF27D26737323007FC770 /* PopularView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopularView.swift; sourceTree = ""; }; 37AAF27F26737550007FC770 /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = ""; }; 37AAF28F26740715007FC770 /* Channel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Channel.swift; sourceTree = ""; }; - 37AAF29926740A01007FC770 /* VideosListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideosListView.swift; sourceTree = ""; }; 37AAF29F26741C97007FC770 /* SubscriptionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionsView.swift; sourceTree = ""; }; 37B044B626F7AB9000E1419D /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; 37B17D9F268A1F25006AEE9B /* VideoContextMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoContextMenuView.swift; sourceTree = ""; }; @@ -532,8 +526,6 @@ 3748186D26A769D60084E870 /* DetailBadge.swift */, 37A9965926D6F8CA006E3224 /* VideosCellsHorizontal.swift */, 37F4AE7126828F0900BD60EA /* VideosCellsVertical.swift */, - 37AAF29926740A01007FC770 /* VideosListView.swift */, - 37754C9C26B7500000DBD602 /* VideosView.swift */, 37D4B18B26717B3800C925CA /* VideoView.swift */, ); path = Videos; @@ -1072,7 +1064,6 @@ 37977583268922F600DD52A8 /* InvidiousAPI.swift in Sources */, 37BE0BD626A1D4A90092E2DB /* PlayerViewController.swift in Sources */, 37BA793F26DB8F97002A0235 /* ChannelVideosView.swift in Sources */, - 37754C9D26B7500000DBD602 /* VideosView.swift in Sources */, 37C194C726F6A9C8005D3B96 /* RecentsModel.swift in Sources */, 37484C1926FC837400287258 /* PlaybackSettingsView.swift in Sources */, 3711403F26B206A6005B3555 /* SearchModel.swift in Sources */, @@ -1205,7 +1196,6 @@ 37E64DD226D597EB00C71877 /* SubscriptionsModel.swift in Sources */, 37C7A1D6267BFD9D0010EAD6 /* SponsorBlockSegment.swift in Sources */, 37B767DC2677C3CA0098BAA8 /* PlayerModel.swift in Sources */, - 37754C9E26B7500000DBD602 /* VideosView.swift in Sources */, 3797758C2689345500DD52A8 /* Store.swift in Sources */, 37141674267A8E10006CA35D /* Country.swift in Sources */, 37AAF2A126741C97007FC770 /* SubscriptionsView.swift in Sources */, @@ -1251,7 +1241,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 37754C9F26B7500000DBD602 /* VideosView.swift in Sources */, 37AAF28026737550007FC770 /* SearchView.swift in Sources */, 3788AC2D26F6842D00F6BAA9 /* WatchNowSectionBody.swift in Sources */, 37EAD871267B9ED100D9E01B /* Segment.swift in Sources */, @@ -1288,7 +1277,6 @@ 37AAF27E26737323007FC770 /* PopularView.swift in Sources */, 37A9966026D6F9B9006E3224 /* WatchNowView.swift in Sources */, 37484C1F26FC83A400287258 /* InstancesSettingsView.swift in Sources */, - 37AAF29A26740A01007FC770 /* VideosListView.swift in Sources */, 37C7A1D7267BFD9D0010EAD6 /* SponsorBlockSegment.swift in Sources */, 376578932685490700D4EA09 /* PlaylistsView.swift in Sources */, 37BA795126DC3E0E002A0235 /* Int+Format.swift in Sources */, diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index fcb797ad..85adc216 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -1,10 +1,6 @@ import Defaults extension Defaults.Keys { - #if os(tvOS) - static let layout = Key("listingLayout", default: .cells) - #endif - static let instances = Key<[Instance]>("instances", default: []) static let accounts = Key<[Instance.Account]>("accounts", default: []) static let defaultAccountID = Key("defaultAccountID") @@ -19,20 +15,3 @@ extension Defaults.Keys { static let recentlyOpened = Key<[RecentItem]>("recentlyOpened", default: []) static let quality = Key("quality", default: .hd720pFirstThenBest) } - -enum ListingLayout: String, CaseIterable, Identifiable, Defaults.Serializable { - case list, cells - - var id: String { - rawValue - } - - var name: String { - switch self { - case .list: - return "List" - case .cells: - return "Cells" - } - } -} diff --git a/Shared/Playlists/PlaylistsView.swift b/Shared/Playlists/PlaylistsView.swift index 9aaefff0..8c178994 100644 --- a/Shared/Playlists/PlaylistsView.swift +++ b/Shared/Playlists/PlaylistsView.swift @@ -36,7 +36,7 @@ struct PlaylistsView: View { } else if store.collection.isEmpty { hintText("You have no playlists\n\nTap on \"New Playlist\" to create one") } else { - VideosView(videos: videos) + VideosCellsVertical(videos: videos) } } } diff --git a/Shared/Trending/TrendingView.swift b/Shared/Trending/TrendingView.swift index cb63000a..f0fb6476 100644 --- a/Shared/Trending/TrendingView.swift +++ b/Shared/Trending/TrendingView.swift @@ -31,7 +31,7 @@ struct TrendingView: View { Text("Loading") } - VideosView(videos: store.collection) + VideosCellsVertical(videos: store.collection) } } #if os(tvOS) diff --git a/Shared/Videos/VideoView.swift b/Shared/Videos/VideoView.swift index 2abef1db..561f1243 100644 --- a/Shared/Videos/VideoView.swift +++ b/Shared/Videos/VideoView.swift @@ -12,7 +12,6 @@ struct VideoView: View { @Environment(\.horizontalCells) private var horizontalCells var video: Video - var layout: ListingLayout var body: some View { Group { @@ -26,27 +25,23 @@ struct VideoView: View { } } } - .modifier(ButtonStyleModifier(layout: layout)) + .buttonStyle(.plain) .contentShape(RoundedRectangle(cornerRadius: 12)) .contextMenu { VideoContextMenuView(video: video) } } var content: some View { VStack { - if layout == .cells { - #if os(iOS) - if verticalSizeClass == .compact, !horizontalCells { - horizontalRow - .padding(.vertical, 4) - } else { - verticalRow - } - #else + #if os(iOS) + if verticalSizeClass == .compact, !horizontalCells { + horizontalRow + .padding(.vertical, 4) + } else { verticalRow - #endif - } else { - horizontalRow - } + } + #else + verticalRow + #endif } #if os(macOS) .background() @@ -222,7 +217,7 @@ struct VideoView: View { .background(.gray) .mask(RoundedRectangle(cornerRadius: 12)) #if os(tvOS) - .frame(minHeight: layout == .cells ? 320 : 200) + .frame(minHeight: 320) #endif .modifier(AspectRatioModifier()) } @@ -248,22 +243,4 @@ struct VideoView: View { } } } - - struct ButtonStyleModifier: ViewModifier { - var layout: ListingLayout - - func body(content: Content) -> some View { - Section { - #if os(tvOS) - if layout == .cells { - content.buttonStyle(.plain) - } else { - content - } - #else - content.buttonStyle(.plain) - #endif - } - } - } } diff --git a/Shared/Videos/VideosCellsHorizontal.swift b/Shared/Videos/VideosCellsHorizontal.swift index 49f686f3..b62d167a 100644 --- a/Shared/Videos/VideosCellsHorizontal.swift +++ b/Shared/Videos/VideosCellsHorizontal.swift @@ -13,7 +13,7 @@ struct VideosCellsHorizontal: View { ScrollView(.horizontal, showsIndicators: false) { LazyHStack(spacing: 20) { ForEach(videos) { video in - VideoView(video: video, layout: .cells) + VideoView(video: video) .environment(\.horizontalCells, true) #if os(tvOS) .frame(width: 580) diff --git a/Shared/Videos/VideosCellsVertical.swift b/Shared/Videos/VideosCellsVertical.swift index 7bce9320..2be9ae98 100644 --- a/Shared/Videos/VideosCellsVertical.swift +++ b/Shared/Videos/VideosCellsVertical.swift @@ -13,7 +13,7 @@ struct VideosCellsVertical: View { ScrollView(.vertical, showsIndicators: scrollViewShowsIndicators) { LazyVGrid(columns: items, alignment: .center) { ForEach(videos) { video in - VideoView(video: video, layout: .cells) + VideoView(video: video) #if os(tvOS) .padding(.horizontal) #endif @@ -35,6 +35,10 @@ struct VideosCellsVertical: View { #endif } .edgesIgnoringSafeArea(.horizontal) + #if os(macOS) + .background() + .frame(minWidth: 360) + #endif } var items: [GridItem] { @@ -68,9 +72,9 @@ struct VideosCellsVertical: View { } } -struct VideoCellsView_Previews: PreviewProvider { +struct VideoCellsVertical_Previews: PreviewProvider { static var previews: some View { - VideosView(videos: Video.allFixtures) + VideosCellsVertical(videos: Video.allFixtures) .frame(minWidth: 1000) .environmentObject(NavigationModel()) } diff --git a/Shared/Videos/VideosListView.swift b/Shared/Videos/VideosListView.swift deleted file mode 100644 index 4b64021a..00000000 --- a/Shared/Videos/VideosListView.swift +++ /dev/null @@ -1,36 +0,0 @@ -import Defaults -import SwiftUI - -struct VideosListView: View { - var videos: [Video] - - var body: some View { - Section { - ScrollViewReader { scrollView in - List { - ForEach(videos) { video in - VideoView(video: video, layout: .list) - .listRowInsets(EdgeInsets()) - } - .onChange(of: videos) { videos in - #if !os(tvOS) - - guard let video = videos.first else { - return - } - - scrollView.scrollTo(video.id, anchor: .top) - #endif - } - } - } - .listStyle(.grouped) - } - } -} - -struct VideosListView_Previews: PreviewProvider { - static var previews: some View { - VideosListView(videos: Video.allFixtures) - } -} diff --git a/Shared/Videos/VideosView.swift b/Shared/Videos/VideosView.swift deleted file mode 100644 index f8cefcfb..00000000 --- a/Shared/Videos/VideosView.swift +++ /dev/null @@ -1,30 +0,0 @@ -import Defaults -import SwiftUI - -struct VideosView: View { - @EnvironmentObject private var navigation - - #if os(tvOS) - @Default(.layout) private var layout - #endif - - var videos: [Video] - - var body: some View { - VStack { - #if os(tvOS) - if layout == .cells { - VideosCellsVertical(videos: videos) - } else { - VideosListView(videos: videos) - } - #else - VideosCellsVertical(videos: videos) - #endif - } - #if os(macOS) - .background() - .frame(minWidth: 360) - #endif - } -} diff --git a/Shared/Views/ChannelVideosView.swift b/Shared/Views/ChannelVideosView.swift index 789d7f10..97d791f4 100644 --- a/Shared/Views/ChannelVideosView.swift +++ b/Shared/Views/ChannelVideosView.swift @@ -39,7 +39,7 @@ struct ChannelVideosView: View { .frame(maxWidth: .infinity) #endif - VideosView(videos: store.item?.videos ?? []) + VideosCellsVertical(videos: store.item?.videos ?? []) #if !os(iOS) .prefersDefaultFocus(in: focusNamespace) diff --git a/Shared/Views/PlaylistVideosView.swift b/Shared/Views/PlaylistVideosView.swift index 5e71a115..1f0b1cb0 100644 --- a/Shared/Views/PlaylistVideosView.swift +++ b/Shared/Views/PlaylistVideosView.swift @@ -9,7 +9,7 @@ struct PlaylistVideosView: View { } var body: some View { - VideosView(videos: playlist.videos) + VideosCellsVertical(videos: playlist.videos) #if !os(tvOS) .navigationTitle("\(playlist.title) Playlist") #endif diff --git a/Shared/Views/PopularView.swift b/Shared/Views/PopularView.swift index 814ee458..5f33a7b1 100644 --- a/Shared/Views/PopularView.swift +++ b/Shared/Views/PopularView.swift @@ -11,7 +11,7 @@ struct PopularView: View { } var body: some View { - VideosView(videos: store.collection) + VideosCellsVertical(videos: store.collection) .onAppear { resource.addObserver(store) resource.loadIfNeeded() diff --git a/Shared/Views/SearchView.swift b/Shared/Views/SearchView.swift index 82fdc967..0c6b7dd3 100644 --- a/Shared/Views/SearchView.swift +++ b/Shared/Views/SearchView.swift @@ -37,7 +37,7 @@ struct SearchView: View { } .edgesIgnoringSafeArea(.horizontal) #else - VideosView(videos: state.store.collection) + VideosCellsVertical(videos: state.store.collection) #endif if noResults { diff --git a/Shared/Views/SubscriptionsView.swift b/Shared/Views/SubscriptionsView.swift index 24202966..96278910 100644 --- a/Shared/Views/SubscriptionsView.swift +++ b/Shared/Views/SubscriptionsView.swift @@ -12,7 +12,7 @@ struct SubscriptionsView: View { var body: some View { SignInRequiredView(title: "Subscriptions") { - VideosView(videos: store.collection) + VideosCellsVertical(videos: store.collection) .onAppear { loadResources() } diff --git a/tvOS/OptionsView.swift b/tvOS/OptionsView.swift index 02e4d5f7..0ec07523 100644 --- a/tvOS/OptionsView.swift +++ b/tvOS/OptionsView.swift @@ -4,8 +4,6 @@ import SwiftUI struct OptionsView: View { @EnvironmentObject private var navigation - @Default(.layout) private var layout - @Environment(\.dismiss) private var dismiss var body: some View { @@ -18,7 +16,7 @@ struct OptionsView: View { Spacer() CoverSectionView("View Options") { - CoverSectionRowView("Show videos as") { nextLayoutButton } +// CoverSectionRowView("Show videos as") { nextLayoutButton } } CoverSectionView(divider: false) { @@ -39,19 +37,6 @@ struct OptionsView: View { } .background(.thinMaterial) } - - var nextLayoutButton: some View { - Button(layout.name) { - self.layout = layout.next() - } - .contextMenu { - ForEach(ListingLayout.allCases) { layout in - Button(layout.name) { - Defaults[.layout] = layout - } - } - } - } } struct OptionsView_Previews: PreviewProvider {