diff --git a/Extensions/Color+Background.swift b/Extensions/Color+Background.swift index d996fdd3..63c91287 100644 --- a/Extensions/Color+Background.swift +++ b/Extensions/Color+Background.swift @@ -3,12 +3,10 @@ import SwiftUI extension Color { #if os(macOS) static let background = Color(NSColor.windowBackgroundColor) - static let secondaryBackground = Color(NSColor.underPageBackgroundColor) - static let tertiaryBackground = Color(NSColor.controlBackgroundColor) + static let secondaryBackground = Color(NSColor.controlBackgroundColor) #elseif os(iOS) static let background = Color(UIColor.systemBackground) static let secondaryBackground = Color(UIColor.secondarySystemBackground) - static let tertiaryBackground = Color(UIColor.tertiarySystemBackground) #else static func background(scheme: ColorScheme) -> Color { scheme == .dark ? .black : .init(white: 0.8) diff --git a/Model/Applications/PipedAPI.swift b/Model/Applications/PipedAPI.swift index 1b05600e..5bad15d6 100644 --- a/Model/Applications/PipedAPI.swift +++ b/Model/Applications/PipedAPI.swift @@ -8,10 +8,6 @@ final class PipedAPI: Service, ObservableObject, VideosAPI { @Published var account: Account! - var anonymousAccount: Account { - .init(instanceID: account.instance.id, name: "Anonymous", url: account.instance.apiURL) - } - init(account: Account? = nil) { super.init() diff --git a/Model/CommentsModel.swift b/Model/CommentsModel.swift index 41b2c3b5..42b43b70 100644 --- a/Model/CommentsModel.swift +++ b/Model/CommentsModel.swift @@ -16,7 +16,6 @@ final class CommentsModel: ObservableObject { @Published var repliesPageID: String? @Published var repliesLoaded = false - var accounts: AccountsModel! var player: PlayerModel! static var instance: Instance? { diff --git a/Model/NavigationModel.swift b/Model/NavigationModel.swift index c968c637..aaa4809e 100644 --- a/Model/NavigationModel.swift +++ b/Model/NavigationModel.swift @@ -74,7 +74,7 @@ final class NavigationModel: ObservableObject { var tabSelectionBinding: Binding { Binding( get: { - self.tabSelection ?? .favorites + self.tabSelection ?? .search }, set: { newValue in self.tabSelection = newValue diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index c7f7830f..a145a421 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -685,46 +685,47 @@ final class PlayerModel: ObservableObject { #if os(tvOS) show() - closePipByReplacingItem(wasPlaying: wasPlaying) - #else - closePiPByNilingPlayer(wasPlaying: wasPlaying) #endif + + doClosePiP(wasPlaying: wasPlaying) } - private func closePipByReplacingItem(wasPlaying: Bool) { - let item = player.currentItem - let time = player.currentTime() + #if os(tvOS) + private func doClosePiP(wasPlaying: Bool) { + let item = player.currentItem + let time = player.currentTime() - self.player.replaceCurrentItem(with: nil) + self.player.replaceCurrentItem(with: nil) - guard !item.isNil else { - return + guard !item.isNil else { + return + } + + self.player.seek(to: time) + self.player.replaceCurrentItem(with: item) + + guard wasPlaying else { + return + } + + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in + self?.play() + } } + #else + private func doClosePiP(wasPlaying: Bool) { + controller?.playerView.player = nil + controller?.playerView.player = player - self.player.seek(to: time) - self.player.replaceCurrentItem(with: item) + guard wasPlaying else { + return + } - guard wasPlaying else { - return + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in + self?.play() + } } - - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in - self?.play() - } - } - - private func closePiPByNilingPlayer(wasPlaying: Bool) { - controller?.playerView.player = nil - controller?.playerView.player = player - - guard wasPlaying else { - return - } - - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in - self?.play() - } - } + #endif #if os(macOS) var windowTitle: String { diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 5481ceae..7cf681dd 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -107,10 +107,6 @@ enum PlayerSidebarSetting: String, CaseIterable, Defaults.Serializable { enum VisibleSection: String, CaseIterable, Comparable, Defaults.Serializable { case favorites, subscriptions, popular, trending, playlists - static func from(_ string: String) -> VisibleSection { - allCases.first { $0.rawValue == string }! - } - var title: String { rawValue.localizedCapitalized } diff --git a/Shared/Favorites/FavoritesView.swift b/Shared/Favorites/FavoritesView.swift index faf747fd..48460598 100644 --- a/Shared/Favorites/FavoritesView.swift +++ b/Shared/Favorites/FavoritesView.swift @@ -51,7 +51,7 @@ struct FavoritesView: View { .navigationTitle("Favorites") #endif #if os(macOS) - .background(Color.tertiaryBackground) + .background(Color.secondaryBackground) .frame(minWidth: 360) #endif } diff --git a/Shared/Navigation/AppSidebarNavigation.swift b/Shared/Navigation/AppSidebarNavigation.swift index 65e85acc..67888d21 100644 --- a/Shared/Navigation/AppSidebarNavigation.swift +++ b/Shared/Navigation/AppSidebarNavigation.swift @@ -6,20 +6,19 @@ import SwiftUI struct AppSidebarNavigation: View { @EnvironmentObject private var accounts - @EnvironmentObject private var comments - @EnvironmentObject private var instances - @EnvironmentObject private var navigation - @EnvironmentObject private var player - @EnvironmentObject private var playlists - @EnvironmentObject private var recents - @EnvironmentObject private var search - @EnvironmentObject private var subscriptions - @EnvironmentObject private var thumbnailsModel - - @Default(.visibleSections) private var visibleSections #if os(iOS) @State private var didApplyPrimaryViewWorkAround = false + + @EnvironmentObject private var comments + @EnvironmentObject private var instances + @EnvironmentObject private var navigation + @EnvironmentObject private var player + @EnvironmentObject private var playlists + @EnvironmentObject private var recents + @EnvironmentObject private var search + @EnvironmentObject private var subscriptions + @EnvironmentObject private var thumbnailsModel #endif var body: some View { @@ -66,26 +65,22 @@ struct AppSidebarNavigation: View { #if os(iOS) .background( EmptyView().fullScreenCover(isPresented: $player.presentingPlayer) { - videoPlayer + VideoPlayerView() + .environmentObject(accounts) + .environmentObject(comments) + .environmentObject(instances) + .environmentObject(navigation) + .environmentObject(player) + .environmentObject(playlists) + .environmentObject(recents) + .environmentObject(subscriptions) + .environmentObject(thumbnailsModel) .environment(\.navigationStyle, .sidebar) } ) #endif } - private var videoPlayer: some View { - VideoPlayerView() - .environmentObject(accounts) - .environmentObject(comments) - .environmentObject(instances) - .environmentObject(navigation) - .environmentObject(player) - .environmentObject(playlists) - .environmentObject(recents) - .environmentObject(subscriptions) - .environmentObject(thumbnailsModel) - } - var toolbarContent: some ToolbarContent { Group { #if os(iOS) diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index 586821fc..f91446e5 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -123,7 +123,6 @@ struct ContentView: View { search.accounts = accounts subscriptions.accounts = accounts - comments.accounts = accounts comments.player = player menu.accounts = accounts diff --git a/Shared/Navigation/Sidebar.swift b/Shared/Navigation/Sidebar.swift index cbadfddb..98836a64 100644 --- a/Shared/Navigation/Sidebar.swift +++ b/Shared/Navigation/Sidebar.swift @@ -4,8 +4,6 @@ import SwiftUI struct Sidebar: View { @EnvironmentObject private var accounts @EnvironmentObject private var navigation - @EnvironmentObject private var playlists - @EnvironmentObject private var subscriptions @Default(.visibleSections) private var visibleSections diff --git a/Shared/Player/CommentsView.swift b/Shared/Player/CommentsView.swift index 0ddaaa95..f79ad58e 100644 --- a/Shared/Player/CommentsView.swift +++ b/Shared/Player/CommentsView.swift @@ -4,7 +4,6 @@ struct CommentsView: View { @State private var repliesID: Comment.ID? @EnvironmentObject private var comments - @EnvironmentObject private var player var body: some View { Group { diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index ba5befef..ce8468f7 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -14,7 +14,7 @@ struct VideoPlayerView: View { } @State private var playerSize: CGSize = .zero - @State private var fullScreen = false + @State private var fullScreenDetails = false @Environment(\.colorScheme) private var colorScheme @@ -95,15 +95,15 @@ struct VideoPlayerView: View { Group { #if os(iOS) if verticalSizeClass == .regular { - VideoDetails(sidebarQueue: sidebarQueueBinding, fullScreen: $fullScreen) + VideoDetails(sidebarQueue: sidebarQueueBinding, fullScreen: $fullScreenDetails) } #else - VideoDetails(sidebarQueue: sidebarQueueBinding, fullScreen: $fullScreen) + VideoDetails(sidebarQueue: sidebarQueueBinding, fullScreen: $fullScreenDetails) #endif } .background(colorScheme == .dark ? Color.black : Color.white) - .modifier(VideoDetailsPaddingModifier(geometry: geometry, aspectRatio: player.controller?.aspectRatio, fullScreen: fullScreen)) + .modifier(VideoDetailsPaddingModifier(geometry: geometry, aspectRatio: player.controller?.aspectRatio, fullScreen: fullScreenDetails)) } #endif } @@ -113,12 +113,12 @@ struct VideoPlayerView: View { #endif #if os(iOS) if sidebarQueue { - PlayerQueueView(sidebarQueue: .constant(true), fullScreen: $fullScreen) + PlayerQueueView(sidebarQueue: .constant(true), fullScreen: $fullScreenDetails) .frame(maxWidth: 350) } #elseif os(macOS) if Defaults[.playerSidebar] != .never { - PlayerQueueView(sidebarQueue: sidebarQueueBinding, fullScreen: $fullScreen) + PlayerQueueView(sidebarQueue: sidebarQueueBinding, fullScreen: $fullScreenDetails) .frame(minWidth: 300) } #endif diff --git a/Shared/Playlists/PlaylistsView.swift b/Shared/Playlists/PlaylistsView.swift index 4c1dfc93..4bf5a2f8 100644 --- a/Shared/Playlists/PlaylistsView.swift +++ b/Shared/Playlists/PlaylistsView.swift @@ -179,7 +179,7 @@ struct PlaylistsView: View { } .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) #if os(macOS) - .background(Color.tertiaryBackground) + .background(Color.secondaryBackground) #endif } diff --git a/Shared/Settings/InstanceSettings.swift b/Shared/Settings/InstanceSettings.swift index fd193248..d6024ce9 100644 --- a/Shared/Settings/InstanceSettings.swift +++ b/Shared/Settings/InstanceSettings.swift @@ -8,9 +8,6 @@ struct InstanceSettings: View { @State private var frontendURL = "" - @EnvironmentObject private var model - @EnvironmentObject private var instances - var instance: Instance! { InstancesModel.find(instanceID) } diff --git a/Shared/Settings/PlaybackSettings.swift b/Shared/Settings/PlaybackSettings.swift index 9b23d7a8..c338b2ea 100644 --- a/Shared/Settings/PlaybackSettings.swift +++ b/Shared/Settings/PlaybackSettings.swift @@ -8,7 +8,6 @@ struct PlaybackSettings: View { @Default(.playerSidebar) private var playerSidebar @Default(.showKeywords) private var showKeywords @Default(.showChannelSubscribers) private var channelSubscribers - @Default(.saveHistory) private var saveHistory @Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer @Default(.closePiPOnNavigation) private var closePiPOnNavigation @Default(.closePiPOnOpeningPlayer) private var closePiPOnOpeningPlayer diff --git a/Shared/Videos/VerticalCells.swift b/Shared/Videos/VerticalCells.swift index d90ff235..65709c76 100644 --- a/Shared/Videos/VerticalCells.swift +++ b/Shared/Videos/VerticalCells.swift @@ -19,7 +19,7 @@ struct VerticalCells: View { } .edgesIgnoringSafeArea(.horizontal) #if os(macOS) - .background(Color.tertiaryBackground) + .background(Color.secondaryBackground) .frame(minWidth: 360) #endif } diff --git a/Shared/Videos/VideoCell.swift b/Shared/Videos/VideoCell.swift index 8226b9fa..a5cc594f 100644 --- a/Shared/Videos/VideoCell.swift +++ b/Shared/Videos/VideoCell.swift @@ -62,7 +62,7 @@ struct VideoCell: View { #endif } #if os(macOS) - .background(Color.tertiaryBackground) + .background(Color.secondaryBackground) #endif } diff --git a/Shared/Views/ChannelPlaylistView.swift b/Shared/Views/ChannelPlaylistView.swift index 28eb0c4c..d6fb0dbf 100644 --- a/Shared/Views/ChannelPlaylistView.swift +++ b/Shared/Views/ChannelPlaylistView.swift @@ -13,10 +13,10 @@ struct ChannelPlaylistView: View { #if os(iOS) @Environment(\.inNavigationView) private var inNavigationView + @EnvironmentObject private var player #endif @EnvironmentObject private var accounts - @EnvironmentObject private var player var items: [ContentItem] { ContentItem.array(of: store.item?.videos ?? []) diff --git a/Shared/Views/ChannelVideosView.swift b/Shared/Views/ChannelVideosView.swift index b5474589..f7a28adc 100644 --- a/Shared/Views/ChannelVideosView.swift +++ b/Shared/Views/ChannelVideosView.swift @@ -10,16 +10,15 @@ struct ChannelVideosView: View { @StateObject private var store = Store() @Environment(\.colorScheme) private var colorScheme - @Environment(\.presentationMode) private var presentationMode - @Environment(\.inNavigationView) private var inNavigationView #if os(iOS) + @Environment(\.inNavigationView) private var inNavigationView @Environment(\.horizontalSizeClass) private var horizontalSizeClass + @EnvironmentObject private var player #endif @EnvironmentObject private var accounts @EnvironmentObject private var navigation - @EnvironmentObject private var player @EnvironmentObject private var subscriptions @Namespace private var focusNamespace diff --git a/Shared/Views/LazyView.swift b/Shared/Views/LazyView.swift index f3e8e533..095005e2 100644 --- a/Shared/Views/LazyView.swift +++ b/Shared/Views/LazyView.swift @@ -3,6 +3,7 @@ import SwiftUI struct LazyView: View { let build: () -> Content + init(_ build: @autoclosure @escaping () -> Content) { self.build = build } diff --git a/Shared/Views/PlayerControlsView.swift b/Shared/Views/PlayerControlsView.swift index 340d6f0b..479d0793 100644 --- a/Shared/Views/PlayerControlsView.swift +++ b/Shared/Views/PlayerControlsView.swift @@ -116,7 +116,7 @@ struct PlayerControlsView: View { } else { controls #if !os(tvOS) - .background(Color.tertiaryBackground) + .background(Color.secondaryBackground) #endif } } diff --git a/Shared/Views/VideoContextMenuView.swift b/Shared/Views/VideoContextMenuView.swift index 6c02b425..82b1e953 100644 --- a/Shared/Views/VideoContextMenuView.swift +++ b/Shared/Views/VideoContextMenuView.swift @@ -80,14 +80,6 @@ struct VideoContextMenuView: View { } } - private var isShowingChannelButton: Bool { - if case .channel = navigation.tabSelection { - return false - } - - return !inChannelView - } - private var addToQueueButton: some View { Button { player.enqueueVideo(video) diff --git a/Yattee.xcodeproj/project.pbxproj b/Yattee.xcodeproj/project.pbxproj index ec22c014..11003496 100644 --- a/Yattee.xcodeproj/project.pbxproj +++ b/Yattee.xcodeproj/project.pbxproj @@ -22,7 +22,7 @@ isa = PBXAggregateTarget; buildConfigurationList = 37FD43E72704A2240073EE42 /* Build configuration list for PBXAggregateTarget "Periphery (macOS)" */; buildPhases = ( - 37FD43EA2704A2350073EE42 /* ShellScript */, + 37FD43EA2704A2350073EE42 /* Run Script */, ); dependencies = ( ); @@ -369,7 +369,6 @@ 37B81B0326D2CAE700675966 /* PlaybackBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37B81B0126D2CAE700675966 /* PlaybackBar.swift */; }; 37BA793B26DB8EE4002A0235 /* PlaylistVideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BA793A26DB8EE4002A0235 /* PlaylistVideosView.swift */; }; 37BA793C26DB8EE4002A0235 /* PlaylistVideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BA793A26DB8EE4002A0235 /* PlaylistVideosView.swift */; }; - 37BA793D26DB8EE4002A0235 /* PlaylistVideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BA793A26DB8EE4002A0235 /* PlaylistVideosView.swift */; }; 37BA793F26DB8F97002A0235 /* ChannelVideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BA793E26DB8F97002A0235 /* ChannelVideosView.swift */; }; 37BA794026DB8F97002A0235 /* ChannelVideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BA793E26DB8F97002A0235 /* ChannelVideosView.swift */; }; 37BA794126DB8F97002A0235 /* ChannelVideosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37BA793E26DB8F97002A0235 /* ChannelVideosView.swift */; }; @@ -1668,7 +1667,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (iOS)\" \\\n --targets \"Yattee (iOS)\" \\\n --retain-objc-accessible \\\n --retain-public \\\n -- -destination \"platform=iOS\\ Simulator,name=iPhone\\ 8,OS=15.0\"\n"; + shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (iOS)\" \\\n --targets \"Yattee (iOS)\" \\\n --retain-objc-accessible \\\n --retain-public \\\n -- -destination \"platform=iOS\\ Simulator,name=iPhone\\ 8,OS=14.5\"\n"; }; 37CC3F48270CE89B00608308 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1721,7 +1720,7 @@ shellPath = /bin/sh; shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nexport PATH\n\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; }; - 37FD43EA2704A2350073EE42 /* ShellScript */ = { + 37FD43EA2704A2350073EE42 /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -1730,6 +1729,7 @@ ); inputPaths = ( ); + name = "Run Script"; outputFileListPaths = ( ); outputPaths = ( @@ -2231,7 +2231,6 @@ 37FB2860272225E800A57617 /* ContentItemView.swift in Sources */, 374C053727242D9F009BDDBE /* ServicesSettings.swift in Sources */, 37C069802725C8D400F7F6CB /* CMTime+DefaultTimescale.swift in Sources */, - 37BA793D26DB8EE4002A0235 /* PlaylistVideosView.swift in Sources */, 3711404126B206A6005B3555 /* SearchModel.swift in Sources */, 37FD43F02704A9C00073EE42 /* RecentsModel.swift in Sources */, 379775952689365600DD52A8 /* Array+Next.swift in Sources */, diff --git a/macOS/OpenWindow.swift b/macOS/OpenWindow.swift index a1066f9a..103b7554 100644 --- a/macOS/OpenWindow.swift +++ b/macOS/OpenWindow.swift @@ -32,7 +32,7 @@ enum OpenWindow: String, CaseIterable { func open() { switch self { case .player: - NSWorkspace.shared.open(URL(string: "yattee://player")!) + NSWorkspace.shared.open(URL(string: "yattee://\(location)")!) case .main: Self.main.focus() } diff --git a/tvOS/AccountSelectionView.swift b/tvOS/AccountSelectionView.swift index 978e32eb..4173f53c 100644 --- a/tvOS/AccountSelectionView.swift +++ b/tvOS/AccountSelectionView.swift @@ -5,7 +5,6 @@ import SwiftUI struct AccountSelectionView: View { var showHeader = true - @EnvironmentObject private var instancesModel @EnvironmentObject private var accountsModel @Default(.accounts) private var accounts diff --git a/tvOS/NowPlayingView.swift b/tvOS/NowPlayingView.swift index 6e90a6dc..6ebaec8b 100644 --- a/tvOS/NowPlayingView.swift +++ b/tvOS/NowPlayingView.swift @@ -141,12 +141,6 @@ struct NowPlayingView: View { .frame(minWidth: 0, maxWidth: .infinity, minHeight: 560, maxHeight: .infinity, alignment: .leading) } - func header(_ text: String) -> some View { - Text(text) - .font((inInfoViewController ? Font.system(size: 40) : .title3).bold()) - .foregroundColor(.secondary) - } - private var progressView: some View { VStack { Spacer() diff --git a/tvOS/TVNavigationView.swift b/tvOS/TVNavigationView.swift index 60f50092..f9931eb4 100644 --- a/tvOS/TVNavigationView.swift +++ b/tvOS/TVNavigationView.swift @@ -6,7 +6,6 @@ struct TVNavigationView: View { @EnvironmentObject private var navigation @EnvironmentObject private var player @EnvironmentObject private var recents - @EnvironmentObject private var search @Default(.visibleSections) private var visibleSections var body: some View {