From c1f3fecfe7c24ba764563516d21318d4151488c2 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 20 Mar 2022 21:31:19 +0100 Subject: [PATCH] Add toggle for dislikes --- Model/Player/PlayerModel.swift | 4 + Shared/Defaults.swift | 2 + Shared/Settings/PlayerSettings.swift | 7 + Shared/Settings/SettingsView.swift | 2 +- Shared/Views/MPVPlayerView.swift | 4 +- .../xcshareddata/swiftpm/Package.resolved | 131 ++++++++++++++++++ 6 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 Yattee.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index b2189a1b..c000d521 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -228,6 +228,10 @@ final class PlayerModel: ObservableObject { } } + guard Defaults[.enableReturnYouTubeDislike] else { + return + } + self?.returnYouTubeDislike.loadDislikes(videoID: video.videoID) { [weak self] dislikes in self?.currentItem?.video?.dislikes = dislikes } diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index 1f857d34..c6476d8b 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -23,6 +23,8 @@ extension Defaults.Keys { static let sponsorBlockInstance = Key("sponsorBlockInstance", default: "https://sponsor.ajay.app") static let sponsorBlockCategories = Key>("sponsorBlockCategories", default: Set(SponsorBlockAPI.categories)) + static let enableReturnYouTubeDislike = Key("enableReturnYouTubeDislike", default: false) + static let favorites = Key<[FavoriteItem]>("favorites", default: [ .init(section: .trending("US", "default")), .init(section: .trending("GB", "default")), diff --git a/Shared/Settings/PlayerSettings.swift b/Shared/Settings/PlayerSettings.swift index 3030392c..d70cb99b 100644 --- a/Shared/Settings/PlayerSettings.swift +++ b/Shared/Settings/PlayerSettings.swift @@ -28,6 +28,8 @@ struct PlayerSettings: View { @Default(.closePiPAndOpenPlayerOnEnteringForeground) private var closePiPAndOpenPlayerOnEnteringForeground #endif + @Default(.enableReturnYouTubeDislike) private var enableReturnYouTubeDislike + #if os(iOS) private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom @@ -84,6 +86,7 @@ struct PlayerSettings: View { keywordsToggle showHistoryToggle channelSubscribersToggle + returnYouTubeDislikeToggle } Section(header: SettingsHeader(text: "Picture in Picture")) { @@ -200,6 +203,10 @@ struct PlayerSettings: View { Toggle("Show subscribers count", isOn: $channelSubscribers) } + private var returnYouTubeDislikeToggle: some View { + Toggle("Enable Return YouTube Dislike", isOn: $enableReturnYouTubeDislike) + } + private var pauseOnHidingPlayerToggle: some View { Toggle("Pause when player is closed", isOn: $pauseOnHidingPlayer) } diff --git a/Shared/Settings/SettingsView.swift b/Shared/Settings/SettingsView.swift index 5a792192..c6f2fd97 100644 --- a/Shared/Settings/SettingsView.swift +++ b/Shared/Settings/SettingsView.swift @@ -179,7 +179,7 @@ struct SettingsView: View { case .browsing: return 350 case .player: - return 450 + return 470 case .history: return 480 case .sponsorBlock: diff --git a/Shared/Views/MPVPlayerView.swift b/Shared/Views/MPVPlayerView.swift index 521fe47b..fd5cdab5 100644 --- a/Shared/Views/MPVPlayerView.swift +++ b/Shared/Views/MPVPlayerView.swift @@ -23,6 +23,8 @@ import SwiftUI @EnvironmentObject private var player func makeNSView(context _: Context) -> some NSView { + player.mpvBackend.client = client + client.layer = layer layer.client = client @@ -31,8 +33,6 @@ import SwiftUI view.layer = client.layer view.wantsLayer = true - player.mpvBackend.client = client - return view } diff --git a/Yattee.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Yattee.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 00000000..73564d67 --- /dev/null +++ b/Yattee.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,131 @@ +{ + "pins" : [ + { + "identity" : "alamofire", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Alamofire/Alamofire.git", + "state" : { + "revision" : "f82c23a8a7ef8dc1a49a8bfc6a96883e79121864", + "version" : "5.5.0" + } + }, + { + "identity" : "defaults", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sindresorhus/Defaults", + "state" : { + "revision" : "119f654d44f7b90f00dc11f7dd1c94a36f12576b", + "version" : "6.2.1" + } + }, + { + "identity" : "libwebp-xcode", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/libwebp-Xcode.git", + "state" : { + "revision" : "2b3b43faaef54d1b897482428428357b7f7cd08b", + "version" : "1.2.1" + } + }, + { + "identity" : "pincache", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pinterest/PINCache", + "state" : { + "branch" : "master", + "revision" : "9ca06045b5aff12ee8c0ef5880aa8469c4896144" + } + }, + { + "identity" : "pinoperation", + "kind" : "remoteSourceControl", + "location" : "https://github.com/pinterest/PINOperation.git", + "state" : { + "revision" : "44d8ca154a4e75a028a5548c31ff3a53b90cef15", + "version" : "1.2.1" + } + }, + { + "identity" : "sdwebimage", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImage.git", + "state" : { + "revision" : "2e63d0061da449ad0ed130768d05dceb1496de44", + "version" : "5.12.5" + } + }, + { + "identity" : "sdwebimagepinplugin", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImagePINPlugin.git", + "state" : { + "revision" : "bd73a4fb30352ec311303d811559c9c46df4caa4", + "version" : "0.3.0" + } + }, + { + "identity" : "sdwebimageswiftui", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImageSwiftUI.git", + "state" : { + "revision" : "cd8625b7cf11a97698e180d28bb7d5d357196678", + "version" : "2.0.2" + } + }, + { + "identity" : "sdwebimagewebpcoder", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SDWebImage/SDWebImageWebPCoder.git", + "state" : { + "revision" : "95a6838df13bc08d8064cf7e048b787b6e52348d", + "version" : "0.8.4" + } + }, + { + "identity" : "siesta", + "kind" : "remoteSourceControl", + "location" : "https://github.com/bustoutsolutions/siesta", + "state" : { + "revision" : "43f34046ebb5beb6802200353c473af303bbc31e", + "version" : "1.5.2" + } + }, + { + "identity" : "sparkle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sparkle-project/Sparkle", + "state" : { + "branch" : "2.x", + "revision" : "f250bead4b943ef9711c61274a1f52e380afa0e8" + } + }, + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log.git", + "state" : { + "revision" : "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", + "version" : "1.4.2" + } + }, + { + "identity" : "swiftui-introspect", + "kind" : "remoteSourceControl", + "location" : "https://github.com/siteline/SwiftUI-Introspect.git", + "state" : { + "revision" : "f2616860a41f9d9932da412a8978fec79c06fe24", + "version" : "0.1.4" + } + }, + { + "identity" : "swiftyjson", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SwiftyJSON/SwiftyJSON.git", + "state" : { + "revision" : "b3dcd7dbd0d488e1a7077cb33b00f2083e382f07", + "version" : "5.0.1" + } + } + ], + "version" : 2 +}