From 5c0cf7452c62be140e848b578b495b963826754d Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sat, 22 Apr 2023 22:44:59 +0200 Subject: [PATCH] Remove unused code --- Model/Accounts/AccountsModel.swift | 11 ---- Model/Channel.swift | 15 ----- Shared/Channels/ChannelCell.swift | 6 -- Shared/Channels/ChannelPlaylistCell.swift | 2 - Shared/Channels/ChannelPlaylistView.swift | 4 -- Shared/Channels/ChannelVideosView.swift | 14 +--- Shared/Constants.swift | 8 --- Shared/Defaults.swift | 13 ++-- Shared/Home/FavoriteItemView.swift | 2 - Shared/Navigation/AccountViewButton.swift | 2 - Shared/Navigation/AccountsViewModel.swift | 4 -- Shared/Navigation/AppSidebarNavigation.swift | 1 - Shared/Navigation/AppSidebarRecents.swift | 1 - .../Navigation/AppSidebarSubscriptions.swift | 1 - Shared/Navigation/AppTabNavigation.swift | 1 - Shared/Navigation/ContentView.swift | 7 -- Shared/Player/Controls/OSD/Buffering.swift | 4 -- Shared/Player/Video Details/ChapterView.swift | 65 ++++++++++--------- .../VideoDetailsPaddingModifier.swift | 3 - Shared/Player/VideoPlayerView.swift | 1 - Shared/Playlists/AddToPlaylistView.swift | 3 - Shared/Settings/AccountForm.swift | 1 - Shared/Settings/AdvancedSettings.swift | 1 - Shared/Subscriptions/FeedView.swift | 1 - Shared/Videos/VideoBanner.swift | 2 +- Shared/Videos/VideoCell.swift | 2 +- Shared/Views/ControlsBar.swift | 2 - Shared/Views/VideoContextMenuView.swift | 1 - 28 files changed, 41 insertions(+), 137 deletions(-) diff --git a/Model/Accounts/AccountsModel.swift b/Model/Accounts/AccountsModel.swift index 7d0ffb97..f16c2b50 100644 --- a/Model/Accounts/AccountsModel.swift +++ b/Model/Accounts/AccountsModel.swift @@ -140,15 +140,4 @@ final class AccountsModel: ObservableObject { KeychainModel.shared.getAccountKey(account, "password") ) } - - static func removeDefaultsCredentials(_ account: Account) { - if let accountIndex = Defaults[.accounts].firstIndex(where: { $0.id == account.id }) { - var account = Defaults[.accounts][accountIndex] - account.name = "" - account.username = "" - account.password = nil - - Defaults[.accounts][accountIndex] = account - } - } } diff --git a/Model/Channel.swift b/Model/Channel.swift index b54230b3..ac15d7bb 100644 --- a/Model/Channel.swift +++ b/Model/Channel.swift @@ -33,21 +33,6 @@ struct Channel: Identifiable, Hashable { } } - var contentItemType: ContentItem.ContentType { - switch self { - case .videos: - return .video - case .playlists: - return .playlist - case .livestreams: - return .video - case .shorts: - return .video - case .channels: - return .channel - } - } - var systemImage: String { switch self { case .videos: diff --git a/Shared/Channels/ChannelCell.swift b/Shared/Channels/ChannelCell.swift index 3e42bc91..80fb548b 100644 --- a/Shared/Channels/ChannelCell.swift +++ b/Shared/Channels/ChannelCell.swift @@ -37,12 +37,6 @@ struct ChannelCell: View { .buttonStyle(.plain) } - var label: some View { - labelContent - .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) - .contentShape(RoundedRectangle(cornerRadius: 12)) - } - var labelContent: some View { VStack { WebImage(url: channel.thumbnailURL, options: [.lowPriority]) diff --git a/Shared/Channels/ChannelPlaylistCell.swift b/Shared/Channels/ChannelPlaylistCell.swift index 7b8e5dc2..4baf4cfb 100644 --- a/Shared/Channels/ChannelPlaylistCell.swift +++ b/Shared/Channels/ChannelPlaylistCell.swift @@ -6,8 +6,6 @@ struct ChannelPlaylistCell: View { @Environment(\.navigationStyle) private var navigationStyle - var navigation = NavigationModel.shared - var body: some View { if navigationStyle == .tab { NavigationLink(destination: ChannelPlaylistView(playlist: playlist)) { cell } diff --git a/Shared/Channels/ChannelPlaylistView.swift b/Shared/Channels/ChannelPlaylistView.swift index cd9f2e56..61ee2eb3 100644 --- a/Shared/Channels/ChannelPlaylistView.swift +++ b/Shared/Channels/ChannelPlaylistView.swift @@ -6,13 +6,9 @@ struct ChannelPlaylistView: View { var playlist: ChannelPlaylist? var showCloseButton = false - @State private var presentingShareSheet = false - @State private var shareURL: URL? - @StateObject private var store = Store() @Environment(\.colorScheme) private var colorScheme - @Environment(\.navigationStyle) private var navigationStyle @Default(.channelPlaylistListingStyle) private var channelPlaylistListingStyle @Default(.hideShorts) private var hideShorts diff --git a/Shared/Channels/ChannelVideosView.swift b/Shared/Channels/ChannelVideosView.swift index d8fadd98..0a8edf87 100644 --- a/Shared/Channels/ChannelVideosView.swift +++ b/Shared/Channels/ChannelVideosView.swift @@ -21,10 +21,6 @@ struct ChannelVideosView: View { @Environment(\.colorScheme) private var colorScheme - #if os(iOS) - @Environment(\.horizontalSizeClass) private var horizontalSizeClass - #endif - @ObservedObject private var accounts = AccountsModel.shared @ObservedObject private var feed = FeedModel.shared @ObservedObject private var navigation = NavigationModel.shared @@ -145,30 +141,22 @@ struct ChannelVideosView: View { contentTypePicker } - ToolbarItem { + ToolbarItemGroup { HStack(spacing: 3) { subscriptionsLabel viewsLabel } - } - ToolbarItem { if let contentItem = presentedChannel?.contentItem { ShareButton(contentItem: contentItem) } - } - ToolbarItem { subscriptionToggleButton .layoutPriority(2) - } - ToolbarItem { favoriteButton .labelStyle(.iconOnly) - } - ToolbarItem { toggleWatchedButton .labelStyle(.iconOnly) } diff --git a/Shared/Constants.swift b/Shared/Constants.swift index b63a51eb..ef85ff0e 100644 --- a/Shared/Constants.swift +++ b/Shared/Constants.swift @@ -61,14 +61,6 @@ struct Constants { #endif } - static var nextSystemImage: String { - if #available(iOS 16, macOS 13, tvOS 16, *) { - return "film.stack" - } else { - return "list.and.film" - } - } - static func seekIcon(_ type: String, _ interval: TimeInterval) -> String { let interval = Int(interval) let allVersions = [10, 15, 30, 45, 60, 75, 90] diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 875ecc7a..c84afa25 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -72,10 +72,12 @@ extension Defaults.Keys { static let qualityProfilesDefault = UIDevice.current.userInterfaceIdiom == .pad ? [ hd2160pMPVProfile, hd1080pMPVProfile, + hd720pMPVProfile, hd720pAVPlayerProfile, sd360pAVPlayerProfile ] : [ hd1080pMPVProfile, + hd720pMPVProfile, hd720pAVPlayerProfile, sd360pAVPlayerProfile ] @@ -88,6 +90,7 @@ extension Defaults.Keys { static let qualityProfilesDefault = [ hd2160pMPVProfile, hd1080pMPVProfile, + hd720pMPVProfile, hd720pAVPlayerProfile ] static let batteryCellularProfileDefault = hd1080pMPVProfile.id @@ -98,6 +101,7 @@ extension Defaults.Keys { static let qualityProfilesDefault = [ hd2160pMPVProfile, hd1080pMPVProfile, + hd720pMPVProfile, hd720pAVPlayerProfile ] static let batteryCellularProfileDefault = hd1080pMPVProfile.id @@ -138,9 +142,6 @@ extension Defaults.Keys { static let expandVideoDescriptionDefault = true #endif static let expandVideoDescription = Key("expandVideoDescription", default: expandVideoDescriptionDefault) - #if !os(tvOS) - static let commentsPlacement = Key("commentsPlacement", default: .separate) - #endif #if os(tvOS) static let pauseOnHidingPlayerDefault = true @@ -349,12 +350,6 @@ enum WatchedVideoPlayNowBehavior: String, Defaults.Serializable { case `continue`, restart } -#if !os(tvOS) - enum CommentsPlacement: String, CaseIterable, Defaults.Serializable { - case info, separate - } -#endif - enum ButtonLabelStyle: String, CaseIterable, Defaults.Serializable { case iconOnly, iconAndText diff --git a/Shared/Home/FavoriteItemView.swift b/Shared/Home/FavoriteItemView.swift index e00447e0..285c1b8e 100644 --- a/Shared/Home/FavoriteItemView.swift +++ b/Shared/Home/FavoriteItemView.swift @@ -9,8 +9,6 @@ struct FavoriteItemView: View { @Environment(\.navigationStyle) private var navigationStyle @StateObject private var store = FavoriteResourceObserver() - @Default(.favorites) private var favorites - @ObservedObject private var accounts = AccountsModel.shared private var playlists = PlaylistsModel.shared private var favoritesModel = FavoritesModel.shared diff --git a/Shared/Navigation/AccountViewButton.swift b/Shared/Navigation/AccountViewButton.swift index 156c79f1..34d587bf 100644 --- a/Shared/Navigation/AccountViewButton.swift +++ b/Shared/Navigation/AccountViewButton.swift @@ -5,10 +5,8 @@ struct AccountViewButton: View { @ObservedObject private var model = AccountsModel.shared private var navigation = NavigationModel.shared - @Default(.accounts) private var accounts @Default(.instances) private var instances @Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername - @Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts @ViewBuilder var body: some View { if !instances.isEmpty { diff --git a/Shared/Navigation/AccountsViewModel.swift b/Shared/Navigation/AccountsViewModel.swift index 626bc766..9ab68ab7 100644 --- a/Shared/Navigation/AccountsViewModel.swift +++ b/Shared/Navigation/AccountsViewModel.swift @@ -29,8 +29,4 @@ final class AccountsViewModel: ObservableObject { var currentAccount: Account? { AccountsModel.shared.current } var instances: [Instance] { InstancesModel.shared.all } - - func accountsOfInstance(_ instance: Instance) -> [Account] { - accounts.filter { $0.instance.apiURL == instance.apiURL }.sorted { $0.name < $1.name } - } } diff --git a/Shared/Navigation/AppSidebarNavigation.swift b/Shared/Navigation/AppSidebarNavigation.swift index 70e7e8a8..811504c6 100644 --- a/Shared/Navigation/AppSidebarNavigation.swift +++ b/Shared/Navigation/AppSidebarNavigation.swift @@ -5,7 +5,6 @@ import SwiftUI #endif struct AppSidebarNavigation: View { - @ObservedObject private var accounts = AccountsModel.shared private var navigation: NavigationModel { .shared } #if os(iOS) diff --git a/Shared/Navigation/AppSidebarRecents.swift b/Shared/Navigation/AppSidebarRecents.swift index 41ec437a..b412d854 100644 --- a/Shared/Navigation/AppSidebarRecents.swift +++ b/Shared/Navigation/AppSidebarRecents.swift @@ -2,7 +2,6 @@ import Defaults import SwiftUI struct AppSidebarRecents: View { - @ObservedObject private var navigation = NavigationModel.shared var recents = RecentsModel.shared @Default(.recentlyOpened) private var recentItems diff --git a/Shared/Navigation/AppSidebarSubscriptions.swift b/Shared/Navigation/AppSidebarSubscriptions.swift index e1d8e52c..865278f9 100644 --- a/Shared/Navigation/AppSidebarSubscriptions.swift +++ b/Shared/Navigation/AppSidebarSubscriptions.swift @@ -6,7 +6,6 @@ struct AppSidebarSubscriptions: View { @ObservedObject private var feed = FeedModel.shared @ObservedObject private var feedCount = UnwatchedFeedCountModel.shared @ObservedObject private var subscriptions = SubscribedChannelsModel.shared - @ObservedObject private var accounts = AccountsModel.shared @Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges diff --git a/Shared/Navigation/AppTabNavigation.swift b/Shared/Navigation/AppTabNavigation.swift index 986e6b7f..0e4df033 100644 --- a/Shared/Navigation/AppTabNavigation.swift +++ b/Shared/Navigation/AppTabNavigation.swift @@ -6,7 +6,6 @@ struct AppTabNavigation: View { @ObservedObject private var navigation = NavigationModel.shared private var player = PlayerModel.shared @ObservedObject private var feed = FeedModel.shared - @ObservedObject private var subscriptions = SubscribedChannelsModel.shared @ObservedObject private var feedCount = UnwatchedFeedCountModel.shared @Default(.showHome) private var showHome diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index 91b0bd15..60e05ce8 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -8,20 +8,13 @@ import Siesta import SwiftUI struct ContentView: View { - @ObservedObject private var accounts = AccountsModel.shared @ObservedObject private var navigation = NavigationModel.shared @ObservedObject private var player = PlayerModel.shared - private var playlists = PlaylistsModel.shared - private var subscriptions = SubscribedChannelsModel.shared #if os(iOS) @Environment(\.horizontalSizeClass) private var horizontalSizeClass #endif - var playerControls: PlayerControlsModel { .shared } - - let persistenceController = PersistenceController.shared - var body: some View { Group { #if os(iOS) diff --git a/Shared/Player/Controls/OSD/Buffering.swift b/Shared/Player/Controls/OSD/Buffering.swift index d7811d35..d9112ff6 100644 --- a/Shared/Player/Controls/OSD/Buffering.swift +++ b/Shared/Player/Controls/OSD/Buffering.swift @@ -6,10 +6,6 @@ struct Buffering: View { var reason = "Buffering stream...".localized() var state: String? - #if os(iOS) - @Environment(\.verticalSizeClass) private var verticalSizeClass - #endif - @ObservedObject private var player = PlayerModel.shared @Default(.playerControlsLayout) private var regularPlayerControlsLayout diff --git a/Shared/Player/Video Details/ChapterView.swift b/Shared/Player/Video Details/ChapterView.swift index fa0626b5..9ee184e4 100644 --- a/Shared/Player/Video Details/ChapterView.swift +++ b/Shared/Player/Video Details/ChapterView.swift @@ -23,40 +23,43 @@ struct ChapterView: View { .buttonStyle(.plain) } - var horizontalChapter: some View { - HStack(spacing: 12) { - if !chapter.image.isNil { - smallImage(chapter) - } + #if os(tvOS) - VStack(alignment: .leading, spacing: 4) { - Text(chapter.title) - .font(.headline) - Text(chapter.start.formattedAsPlaybackTime(allowZero: true) ?? "") - .font(.system(.subheadline).monospacedDigit()) - .foregroundColor(.secondary) + var horizontalChapter: some View { + HStack(spacing: 12) { + if !chapter.image.isNil { + smallImage(chapter) + } + + VStack(alignment: .leading, spacing: 4) { + Text(chapter.title) + .font(.headline) + Text(chapter.start.formattedAsPlaybackTime(allowZero: true) ?? "") + .font(.system(.subheadline).monospacedDigit()) + .foregroundColor(.secondary) + } + } + .frame(maxWidth: .infinity, alignment: .leading) + } + #else + var verticalChapter: some View { + VStack(spacing: 12) { + if !chapter.image.isNil { + smallImage(chapter) + } + VStack(alignment: .leading, spacing: 4) { + Text(chapter.title) + .lineLimit(2) + .multilineTextAlignment(.leading) + .font(.headline) + Text(chapter.start.formattedAsPlaybackTime(allowZero: true) ?? "") + .font(.system(.subheadline).monospacedDigit()) + .foregroundColor(.secondary) + } + .frame(maxWidth: Self.thumbnailWidth, alignment: .leading) } } - .frame(maxWidth: .infinity, alignment: .leading) - } - - var verticalChapter: some View { - VStack(spacing: 12) { - if !chapter.image.isNil { - smallImage(chapter) - } - VStack(alignment: .leading, spacing: 4) { - Text(chapter.title) - .lineLimit(2) - .multilineTextAlignment(.leading) - .font(.headline) - Text(chapter.start.formattedAsPlaybackTime(allowZero: true) ?? "") - .font(.system(.subheadline).monospacedDigit()) - .foregroundColor(.secondary) - } - .frame(maxWidth: Self.thumbnailWidth, alignment: .leading) - } - } + #endif @ViewBuilder func smallImage(_ chapter: Chapter) -> some View { WebImage(url: chapter.image, options: [.lowPriority]) diff --git a/Shared/Player/Video Details/VideoDetailsPaddingModifier.swift b/Shared/Player/Video Details/VideoDetailsPaddingModifier.swift index 77ae70fe..f49767fa 100644 --- a/Shared/Player/Video Details/VideoDetailsPaddingModifier.swift +++ b/Shared/Player/Video Details/VideoDetailsPaddingModifier.swift @@ -5,18 +5,15 @@ struct VideoDetailsPaddingModifier: ViewModifier { static var defaultAdditionalDetailsPadding = 0.0 let playerSize: CGSize - let minimumHeightLeft: Double let additionalPadding: Double let fullScreen: Bool init( playerSize: CGSize, - minimumHeightLeft: Double? = nil, additionalPadding: Double? = nil, fullScreen: Bool = false ) { self.playerSize = playerSize - self.minimumHeightLeft = minimumHeightLeft ?? VideoPlayerView.defaultMinimumHeightLeft self.additionalPadding = additionalPadding ?? Self.defaultAdditionalDetailsPadding self.fullScreen = fullScreen } diff --git a/Shared/Player/VideoPlayerView.swift b/Shared/Player/VideoPlayerView.swift index 61631385..0634f278 100644 --- a/Shared/Player/VideoPlayerView.swift +++ b/Shared/Player/VideoPlayerView.swift @@ -53,7 +53,6 @@ struct VideoPlayerView: View { @State internal var isVerticalDrag = false @State internal var viewDragOffset = Self.hiddenOffset @State internal var orientationObserver: Any? - @State internal var orientationNotification: Any? #endif @ObservedObject internal var player = PlayerModel.shared diff --git a/Shared/Playlists/AddToPlaylistView.swift b/Shared/Playlists/AddToPlaylistView.swift index ff877936..1243c614 100644 --- a/Shared/Playlists/AddToPlaylistView.swift +++ b/Shared/Playlists/AddToPlaylistView.swift @@ -7,9 +7,6 @@ struct AddToPlaylistView: View { @State private var selectedPlaylistID: Playlist.ID = "" - @State private var error = "" - @State private var presentingErrorAlert = false - @Environment(\.colorScheme) private var colorScheme @Environment(\.presentationMode) private var presentationMode diff --git a/Shared/Settings/AccountForm.swift b/Shared/Settings/AccountForm.swift index 8cf49e84..56c26fa5 100644 --- a/Shared/Settings/AccountForm.swift +++ b/Shared/Settings/AccountForm.swift @@ -16,7 +16,6 @@ struct AccountForm: View { @State private var validationDebounce = Debounce() @Environment(\.colorScheme) private var colorScheme - @Environment(\.openURL) private var openURL @Environment(\.presentationMode) private var presentationMode var body: some View { diff --git a/Shared/Settings/AdvancedSettings.swift b/Shared/Settings/AdvancedSettings.swift index 484e4a4c..58f7ec88 100644 --- a/Shared/Settings/AdvancedSettings.swift +++ b/Shared/Settings/AdvancedSettings.swift @@ -9,7 +9,6 @@ struct AdvancedSettings: View { @Default(.showCacheStatus) private var showCacheStatus @Default(.feedCacheSize) private var feedCacheSize - @State private var countries = [String]() @State private var filesToShare = [MPVClient.logFile] @State private var presentingShareSheet = false diff --git a/Shared/Subscriptions/FeedView.swift b/Shared/Subscriptions/FeedView.swift index 631d2a66..0ae789c5 100644 --- a/Shared/Subscriptions/FeedView.swift +++ b/Shared/Subscriptions/FeedView.swift @@ -4,7 +4,6 @@ import SwiftUI struct FeedView: View { @ObservedObject private var feed = FeedModel.shared - @ObservedObject private var accounts = AccountsModel.shared @Default(.showCacheStatus) private var showCacheStatus diff --git a/Shared/Videos/VideoBanner.swift b/Shared/Videos/VideoBanner.swift index f9c4a609..a848a737 100644 --- a/Shared/Videos/VideoBanner.swift +++ b/Shared/Videos/VideoBanner.swift @@ -197,7 +197,7 @@ struct VideoBanner: View { private var contentOpacity: Double { guard saveHistory, !watch.isNil, - watchedVideoStyle == .decreasedOpacity || watchedVideoStyle == .both + watchedVideoStyle.isDecreasingOpacity else { return 1 } diff --git a/Shared/Videos/VideoCell.swift b/Shared/Videos/VideoCell.swift index b60418ee..04e3e963 100644 --- a/Shared/Videos/VideoCell.swift +++ b/Shared/Videos/VideoCell.swift @@ -140,7 +140,7 @@ struct VideoCell: View { private var contentOpacity: Double { guard saveHistory, !watch.isNil, - watchedVideoStyle == .decreasedOpacity || watchedVideoStyle == .both + watchedVideoStyle.isDecreasingOpacity else { return 1 } diff --git a/Shared/Views/ControlsBar.swift b/Shared/Views/ControlsBar.swift index 8745a730..f9a017ad 100644 --- a/Shared/Views/ControlsBar.swift +++ b/Shared/Views/ControlsBar.swift @@ -17,8 +17,6 @@ struct ControlsBar: View { var presentingControls = true var backgroundEnabled = true - var borderTop = true - var borderBottom = true var detailsTogglePlayer = true var detailsToggleFullScreen = false var playerBar = false diff --git a/Shared/Views/VideoContextMenuView.swift b/Shared/Views/VideoContextMenuView.swift index 5e952a60..52bbc601 100644 --- a/Shared/Views/VideoContextMenuView.swift +++ b/Shared/Views/VideoContextMenuView.swift @@ -23,7 +23,6 @@ struct VideoContextMenuView: View { @Default(.saveHistory) private var saveHistory private var backgroundContext = PersistenceController.shared.container.newBackgroundContext() - private var viewContext: NSManagedObjectContext = PersistenceController.shared.container.viewContext init(video: Video) { self.video = video