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")
)
}
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 {
switch self {
case .videos:

View File

@ -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])

View File

@ -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 }

View File

@ -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<ChannelPlaylist>()
@Environment(\.colorScheme) private var colorScheme
@Environment(\.navigationStyle) private var navigationStyle
@Default(.channelPlaylistListingStyle) private var channelPlaylistListingStyle
@Default(.hideShorts) private var hideShorts

View File

@ -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)
}

View File

@ -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]

View File

@ -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<Bool>("expandVideoDescription", default: expandVideoDescriptionDefault)
#if !os(tvOS)
static let commentsPlacement = Key<CommentsPlacement>("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

View File

@ -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

View File

@ -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 {

View File

@ -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 }
}
}

View File

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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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])

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

@ -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

View File

@ -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