Remove unused code

This commit is contained in:
Arkadiusz Fal 2023-04-22 22:44:59 +02:00
parent 2d02d9b472
commit 5c0cf7452c
28 changed files with 41 additions and 137 deletions

View File

@ -140,15 +140,4 @@ final class AccountsModel: ObservableObject {
KeychainModel.shared.getAccountKey(account, "password") 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
}
}
} }

View File

@ -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 { var systemImage: String {
switch self { switch self {
case .videos: case .videos:

View File

@ -37,12 +37,6 @@ struct ChannelCell: View {
.buttonStyle(.plain) .buttonStyle(.plain)
} }
var label: some View {
labelContent
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.contentShape(RoundedRectangle(cornerRadius: 12))
}
var labelContent: some View { var labelContent: some View {
VStack { VStack {
WebImage(url: channel.thumbnailURL, options: [.lowPriority]) WebImage(url: channel.thumbnailURL, options: [.lowPriority])

View File

@ -6,8 +6,6 @@ struct ChannelPlaylistCell: View {
@Environment(\.navigationStyle) private var navigationStyle @Environment(\.navigationStyle) private var navigationStyle
var navigation = NavigationModel.shared
var body: some View { var body: some View {
if navigationStyle == .tab { if navigationStyle == .tab {
NavigationLink(destination: ChannelPlaylistView(playlist: playlist)) { cell } NavigationLink(destination: ChannelPlaylistView(playlist: playlist)) { cell }

View File

@ -6,13 +6,9 @@ struct ChannelPlaylistView: View {
var playlist: ChannelPlaylist? var playlist: ChannelPlaylist?
var showCloseButton = false var showCloseButton = false
@State private var presentingShareSheet = false
@State private var shareURL: URL?
@StateObject private var store = Store<ChannelPlaylist>() @StateObject private var store = Store<ChannelPlaylist>()
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@Environment(\.navigationStyle) private var navigationStyle
@Default(.channelPlaylistListingStyle) private var channelPlaylistListingStyle @Default(.channelPlaylistListingStyle) private var channelPlaylistListingStyle
@Default(.hideShorts) private var hideShorts @Default(.hideShorts) private var hideShorts

View File

@ -21,10 +21,6 @@ struct ChannelVideosView: View {
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
#if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif
@ObservedObject private var accounts = AccountsModel.shared @ObservedObject private var accounts = AccountsModel.shared
@ObservedObject private var feed = FeedModel.shared @ObservedObject private var feed = FeedModel.shared
@ObservedObject private var navigation = NavigationModel.shared @ObservedObject private var navigation = NavigationModel.shared
@ -145,30 +141,22 @@ struct ChannelVideosView: View {
contentTypePicker contentTypePicker
} }
ToolbarItem { ToolbarItemGroup {
HStack(spacing: 3) { HStack(spacing: 3) {
subscriptionsLabel subscriptionsLabel
viewsLabel viewsLabel
} }
}
ToolbarItem {
if let contentItem = presentedChannel?.contentItem { if let contentItem = presentedChannel?.contentItem {
ShareButton(contentItem: contentItem) ShareButton(contentItem: contentItem)
} }
}
ToolbarItem {
subscriptionToggleButton subscriptionToggleButton
.layoutPriority(2) .layoutPriority(2)
}
ToolbarItem {
favoriteButton favoriteButton
.labelStyle(.iconOnly) .labelStyle(.iconOnly)
}
ToolbarItem {
toggleWatchedButton toggleWatchedButton
.labelStyle(.iconOnly) .labelStyle(.iconOnly)
} }

View File

@ -61,14 +61,6 @@ struct Constants {
#endif #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 { static func seekIcon(_ type: String, _ interval: TimeInterval) -> String {
let interval = Int(interval) let interval = Int(interval)
let allVersions = [10, 15, 30, 45, 60, 75, 90] let allVersions = [10, 15, 30, 45, 60, 75, 90]

View File

@ -72,10 +72,12 @@ extension Defaults.Keys {
static let qualityProfilesDefault = UIDevice.current.userInterfaceIdiom == .pad ? [ static let qualityProfilesDefault = UIDevice.current.userInterfaceIdiom == .pad ? [
hd2160pMPVProfile, hd2160pMPVProfile,
hd1080pMPVProfile, hd1080pMPVProfile,
hd720pMPVProfile,
hd720pAVPlayerProfile, hd720pAVPlayerProfile,
sd360pAVPlayerProfile sd360pAVPlayerProfile
] : [ ] : [
hd1080pMPVProfile, hd1080pMPVProfile,
hd720pMPVProfile,
hd720pAVPlayerProfile, hd720pAVPlayerProfile,
sd360pAVPlayerProfile sd360pAVPlayerProfile
] ]
@ -88,6 +90,7 @@ extension Defaults.Keys {
static let qualityProfilesDefault = [ static let qualityProfilesDefault = [
hd2160pMPVProfile, hd2160pMPVProfile,
hd1080pMPVProfile, hd1080pMPVProfile,
hd720pMPVProfile,
hd720pAVPlayerProfile hd720pAVPlayerProfile
] ]
static let batteryCellularProfileDefault = hd1080pMPVProfile.id static let batteryCellularProfileDefault = hd1080pMPVProfile.id
@ -98,6 +101,7 @@ extension Defaults.Keys {
static let qualityProfilesDefault = [ static let qualityProfilesDefault = [
hd2160pMPVProfile, hd2160pMPVProfile,
hd1080pMPVProfile, hd1080pMPVProfile,
hd720pMPVProfile,
hd720pAVPlayerProfile hd720pAVPlayerProfile
] ]
static let batteryCellularProfileDefault = hd1080pMPVProfile.id static let batteryCellularProfileDefault = hd1080pMPVProfile.id
@ -138,9 +142,6 @@ extension Defaults.Keys {
static let expandVideoDescriptionDefault = true static let expandVideoDescriptionDefault = true
#endif #endif
static let expandVideoDescription = Key<Bool>("expandVideoDescription", default: expandVideoDescriptionDefault) static let expandVideoDescription = Key<Bool>("expandVideoDescription", default: expandVideoDescriptionDefault)
#if !os(tvOS)
static let commentsPlacement = Key<CommentsPlacement>("commentsPlacement", default: .separate)
#endif
#if os(tvOS) #if os(tvOS)
static let pauseOnHidingPlayerDefault = true static let pauseOnHidingPlayerDefault = true
@ -349,12 +350,6 @@ enum WatchedVideoPlayNowBehavior: String, Defaults.Serializable {
case `continue`, restart case `continue`, restart
} }
#if !os(tvOS)
enum CommentsPlacement: String, CaseIterable, Defaults.Serializable {
case info, separate
}
#endif
enum ButtonLabelStyle: String, CaseIterable, Defaults.Serializable { enum ButtonLabelStyle: String, CaseIterable, Defaults.Serializable {
case iconOnly, iconAndText case iconOnly, iconAndText

View File

@ -9,8 +9,6 @@ struct FavoriteItemView: View {
@Environment(\.navigationStyle) private var navigationStyle @Environment(\.navigationStyle) private var navigationStyle
@StateObject private var store = FavoriteResourceObserver() @StateObject private var store = FavoriteResourceObserver()
@Default(.favorites) private var favorites
@ObservedObject private var accounts = AccountsModel.shared @ObservedObject private var accounts = AccountsModel.shared
private var playlists = PlaylistsModel.shared private var playlists = PlaylistsModel.shared
private var favoritesModel = FavoritesModel.shared private var favoritesModel = FavoritesModel.shared

View File

@ -5,10 +5,8 @@ struct AccountViewButton: View {
@ObservedObject private var model = AccountsModel.shared @ObservedObject private var model = AccountsModel.shared
private var navigation = NavigationModel.shared private var navigation = NavigationModel.shared
@Default(.accounts) private var accounts
@Default(.instances) private var instances @Default(.instances) private var instances
@Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername @Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername
@Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts
@ViewBuilder var body: some View { @ViewBuilder var body: some View {
if !instances.isEmpty { if !instances.isEmpty {

View File

@ -29,8 +29,4 @@ final class AccountsViewModel: ObservableObject {
var currentAccount: Account? { AccountsModel.shared.current } var currentAccount: Account? { AccountsModel.shared.current }
var instances: [Instance] { InstancesModel.shared.all } var instances: [Instance] { InstancesModel.shared.all }
func accountsOfInstance(_ instance: Instance) -> [Account] {
accounts.filter { $0.instance.apiURL == instance.apiURL }.sorted { $0.name < $1.name }
}
} }

View File

@ -5,7 +5,6 @@ import SwiftUI
#endif #endif
struct AppSidebarNavigation: View { struct AppSidebarNavigation: View {
@ObservedObject private var accounts = AccountsModel.shared
private var navigation: NavigationModel { .shared } private var navigation: NavigationModel { .shared }
#if os(iOS) #if os(iOS)

View File

@ -2,7 +2,6 @@ import Defaults
import SwiftUI import SwiftUI
struct AppSidebarRecents: View { struct AppSidebarRecents: View {
@ObservedObject private var navigation = NavigationModel.shared
var recents = RecentsModel.shared var recents = RecentsModel.shared
@Default(.recentlyOpened) private var recentItems @Default(.recentlyOpened) private var recentItems

View File

@ -6,7 +6,6 @@ struct AppSidebarSubscriptions: View {
@ObservedObject private var feed = FeedModel.shared @ObservedObject private var feed = FeedModel.shared
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared @ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared @ObservedObject private var subscriptions = SubscribedChannelsModel.shared
@ObservedObject private var accounts = AccountsModel.shared
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges @Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges

View File

@ -6,7 +6,6 @@ struct AppTabNavigation: View {
@ObservedObject private var navigation = NavigationModel.shared @ObservedObject private var navigation = NavigationModel.shared
private var player = PlayerModel.shared private var player = PlayerModel.shared
@ObservedObject private var feed = FeedModel.shared @ObservedObject private var feed = FeedModel.shared
@ObservedObject private var subscriptions = SubscribedChannelsModel.shared
@ObservedObject private var feedCount = UnwatchedFeedCountModel.shared @ObservedObject private var feedCount = UnwatchedFeedCountModel.shared
@Default(.showHome) private var showHome @Default(.showHome) private var showHome

View File

@ -8,20 +8,13 @@ import Siesta
import SwiftUI import SwiftUI
struct ContentView: View { struct ContentView: View {
@ObservedObject private var accounts = AccountsModel.shared
@ObservedObject private var navigation = NavigationModel.shared @ObservedObject private var navigation = NavigationModel.shared
@ObservedObject private var player = PlayerModel.shared @ObservedObject private var player = PlayerModel.shared
private var playlists = PlaylistsModel.shared
private var subscriptions = SubscribedChannelsModel.shared
#if os(iOS) #if os(iOS)
@Environment(\.horizontalSizeClass) private var horizontalSizeClass @Environment(\.horizontalSizeClass) private var horizontalSizeClass
#endif #endif
var playerControls: PlayerControlsModel { .shared }
let persistenceController = PersistenceController.shared
var body: some View { var body: some View {
Group { Group {
#if os(iOS) #if os(iOS)

View File

@ -6,10 +6,6 @@ struct Buffering: View {
var reason = "Buffering stream...".localized() var reason = "Buffering stream...".localized()
var state: String? var state: String?
#if os(iOS)
@Environment(\.verticalSizeClass) private var verticalSizeClass
#endif
@ObservedObject private var player = PlayerModel.shared @ObservedObject private var player = PlayerModel.shared
@Default(.playerControlsLayout) private var regularPlayerControlsLayout @Default(.playerControlsLayout) private var regularPlayerControlsLayout

View File

@ -23,40 +23,43 @@ struct ChapterView: View {
.buttonStyle(.plain) .buttonStyle(.plain)
} }
var horizontalChapter: some View { #if os(tvOS)
HStack(spacing: 12) {
if !chapter.image.isNil {
smallImage(chapter)
}
VStack(alignment: .leading, spacing: 4) { var horizontalChapter: some View {
Text(chapter.title) HStack(spacing: 12) {
.font(.headline) if !chapter.image.isNil {
Text(chapter.start.formattedAsPlaybackTime(allowZero: true) ?? "") smallImage(chapter)
.font(.system(.subheadline).monospacedDigit()) }
.foregroundColor(.secondary)
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) #endif
}
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)
}
}
@ViewBuilder func smallImage(_ chapter: Chapter) -> some View { @ViewBuilder func smallImage(_ chapter: Chapter) -> some View {
WebImage(url: chapter.image, options: [.lowPriority]) WebImage(url: chapter.image, options: [.lowPriority])

View File

@ -5,18 +5,15 @@ struct VideoDetailsPaddingModifier: ViewModifier {
static var defaultAdditionalDetailsPadding = 0.0 static var defaultAdditionalDetailsPadding = 0.0
let playerSize: CGSize let playerSize: CGSize
let minimumHeightLeft: Double
let additionalPadding: Double let additionalPadding: Double
let fullScreen: Bool let fullScreen: Bool
init( init(
playerSize: CGSize, playerSize: CGSize,
minimumHeightLeft: Double? = nil,
additionalPadding: Double? = nil, additionalPadding: Double? = nil,
fullScreen: Bool = false fullScreen: Bool = false
) { ) {
self.playerSize = playerSize self.playerSize = playerSize
self.minimumHeightLeft = minimumHeightLeft ?? VideoPlayerView.defaultMinimumHeightLeft
self.additionalPadding = additionalPadding ?? Self.defaultAdditionalDetailsPadding self.additionalPadding = additionalPadding ?? Self.defaultAdditionalDetailsPadding
self.fullScreen = fullScreen self.fullScreen = fullScreen
} }

View File

@ -53,7 +53,6 @@ struct VideoPlayerView: View {
@State internal var isVerticalDrag = false @State internal var isVerticalDrag = false
@State internal var viewDragOffset = Self.hiddenOffset @State internal var viewDragOffset = Self.hiddenOffset
@State internal var orientationObserver: Any? @State internal var orientationObserver: Any?
@State internal var orientationNotification: Any?
#endif #endif
@ObservedObject internal var player = PlayerModel.shared @ObservedObject internal var player = PlayerModel.shared

View File

@ -7,9 +7,6 @@ struct AddToPlaylistView: View {
@State private var selectedPlaylistID: Playlist.ID = "" @State private var selectedPlaylistID: Playlist.ID = ""
@State private var error = ""
@State private var presentingErrorAlert = false
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@Environment(\.presentationMode) private var presentationMode @Environment(\.presentationMode) private var presentationMode

View File

@ -16,7 +16,6 @@ struct AccountForm: View {
@State private var validationDebounce = Debounce() @State private var validationDebounce = Debounce()
@Environment(\.colorScheme) private var colorScheme @Environment(\.colorScheme) private var colorScheme
@Environment(\.openURL) private var openURL
@Environment(\.presentationMode) private var presentationMode @Environment(\.presentationMode) private var presentationMode
var body: some View { var body: some View {

View File

@ -9,7 +9,6 @@ struct AdvancedSettings: View {
@Default(.showCacheStatus) private var showCacheStatus @Default(.showCacheStatus) private var showCacheStatus
@Default(.feedCacheSize) private var feedCacheSize @Default(.feedCacheSize) private var feedCacheSize
@State private var countries = [String]()
@State private var filesToShare = [MPVClient.logFile] @State private var filesToShare = [MPVClient.logFile]
@State private var presentingShareSheet = false @State private var presentingShareSheet = false

View File

@ -4,7 +4,6 @@ import SwiftUI
struct FeedView: View { struct FeedView: View {
@ObservedObject private var feed = FeedModel.shared @ObservedObject private var feed = FeedModel.shared
@ObservedObject private var accounts = AccountsModel.shared
@Default(.showCacheStatus) private var showCacheStatus @Default(.showCacheStatus) private var showCacheStatus

View File

@ -197,7 +197,7 @@ struct VideoBanner: View {
private var contentOpacity: Double { private var contentOpacity: Double {
guard saveHistory, guard saveHistory,
!watch.isNil, !watch.isNil,
watchedVideoStyle == .decreasedOpacity || watchedVideoStyle == .both watchedVideoStyle.isDecreasingOpacity
else { else {
return 1 return 1
} }

View File

@ -140,7 +140,7 @@ struct VideoCell: View {
private var contentOpacity: Double { private var contentOpacity: Double {
guard saveHistory, guard saveHistory,
!watch.isNil, !watch.isNil,
watchedVideoStyle == .decreasedOpacity || watchedVideoStyle == .both watchedVideoStyle.isDecreasingOpacity
else { else {
return 1 return 1
} }

View File

@ -17,8 +17,6 @@ struct ControlsBar: View {
var presentingControls = true var presentingControls = true
var backgroundEnabled = true var backgroundEnabled = true
var borderTop = true
var borderBottom = true
var detailsTogglePlayer = true var detailsTogglePlayer = true
var detailsToggleFullScreen = false var detailsToggleFullScreen = false
var playerBar = false var playerBar = false

View File

@ -23,7 +23,6 @@ struct VideoContextMenuView: View {
@Default(.saveHistory) private var saveHistory @Default(.saveHistory) private var saveHistory
private var backgroundContext = PersistenceController.shared.container.newBackgroundContext() private var backgroundContext = PersistenceController.shared.container.newBackgroundContext()
private var viewContext: NSManagedObjectContext = PersistenceController.shared.container.viewContext
init(video: Video) { init(video: Video) {
self.video = video self.video = video