diff --git a/Sources/EeveeSpotify/DarkPopUps.x.swift b/Sources/EeveeSpotify/DarkPopUps.x.swift index 34918b3..740523e 100644 --- a/Sources/EeveeSpotify/DarkPopUps.x.swift +++ b/Sources/EeveeSpotify/DarkPopUps.x.swift @@ -17,7 +17,7 @@ class EncoreLabelHook: ClassHook { let label = Dynamic.convert(target.subviews.first!, to: UILabel.self) - if !label.hasParent("Primary") { + if !label.hasParent(matching: "Primary") { label.textColor = .white } } @@ -27,17 +27,15 @@ class EncoreLabelHook: ClassHook { } } -class SPTEncorePopUpDialogHook: ClassHook { +class SPTEncorePopUpDialogHook: ClassHook { typealias Group = DarkPopUps - static let targetName = "_TtCO12EncoreMobile5ViewsP33_5A611B064D744992F9E8B522D8DE459B10ScrollView" + static let targetName = "SPTEncorePopUpDialog" - func intrinsicContentSize() -> CGSize { - - if target.accessibilityIdentifier == "PopUp.Dialog" { - target.backgroundColor = UIColor(Color(hex: "#242424")) - } - - return orig.intrinsicContentSize() + func uiView() -> UIView { + let view = orig.uiView() + view.backgroundColor = UIColor(Color(hex: "#242424")) + + return view } } diff --git a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift index 9bf2a15..da65909 100644 --- a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift @@ -13,18 +13,28 @@ class SPTPlayerTrackHook: ClassHook { } } -class EncoreButtonHook: ClassHook { +class LyricsFullscreenViewControllerHook: ClassHook { - static let targetName = "_TtC12EncoreMobileP33_6EF3A3C098E69FB1E331877B69ACBF8512EncoreButton" - - func intrinsicContentSize() -> CGSize { - - if target.accessibilityIdentifier == "Components.UI.LyricsHeader.ReportButton", - UserDefaults.lyricsSource != .musixmatch { - target.isEnabled = false + static var targetName: String { + if #available(iOS 15.0, *) { + "Lyrics_FullscreenPageImpl.FullscreenViewController" + } else { + "Lyrics_CoreImpl.FullscreenViewController" } + } - return orig.intrinsicContentSize() + func viewDidLoad() { + orig.viewDidLoad() + + if UserDefaults.lyricsSource == .musixmatch { + return + } + + let headerView = Ivars(target.view).headerView + + if let reportButton = headerView.subviews(matching: "EncoreButton")[1] as? UIButton { + reportButton.isEnabled = false + } } } diff --git a/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift index 075260e..0159570 100644 --- a/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift +++ b/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift @@ -1,7 +1,7 @@ import UIKit extension UIView { - func hasParent(_ regex: String) -> Bool { + func hasParent(matching regex: String) -> Bool { guard let parent = self.superview else { return false } @@ -10,7 +10,25 @@ extension UIView { if parentClassName ~= regex { return true } else { - return parent.hasParent(regex) + return parent.hasParent(matching: regex) } } + + func subviews(matching regex: String) -> [UIView] { + var matchingSubviews = [UIView]() + var stack = [self] + + while !stack.isEmpty { + let currentView = stack.removeLast() + + for subview in currentView.subviews { + if NSStringFromClass(type(of: subview)) ~= regex { + matchingSubviews.append(subview) + } + stack.append(subview) + } + } + + return matchingSubviews + } }