diff --git a/Sources/EeveeSpotify/DarkPopUps.x.swift b/Sources/EeveeSpotify/DarkPopUps.x.swift index ac52dd82..34918b32 100644 --- a/Sources/EeveeSpotify/DarkPopUps.x.swift +++ b/Sources/EeveeSpotify/DarkPopUps.x.swift @@ -11,22 +11,15 @@ class EncoreLabelHook: ClassHook { func intrinsicContentSize() -> CGSize { - if String( - describing: WindowHelper.shared.viewController(for: target) - ) ~= "SPTEncorePopUpContainer" { - - let label = Dynamic.convert(target.subviews.first!, to: UILabel.self) - - let superview: UIView? + if let viewController = WindowHelper.shared.viewController(for: target) { - if #available(iOS 15.0, *) { - superview = target.superview?.superview?.superview?.superview - } else { - superview = target.superview?.superview?.superview - } + if NSStringFromClass(type(of: viewController)) == "SPTEncorePopUpContainer" { + + let label = Dynamic.convert(target.subviews.first!, to: UILabel.self) - if !(String(describing: superview) ~= "Primary") { - label.textColor = .white + if !label.hasParent("Primary") { + label.textColor = .white + } } } diff --git a/Sources/EeveeSpotify/Helpers/WindowHelper.swift b/Sources/EeveeSpotify/Helpers/WindowHelper.swift index 3f77a759..5aa8e6df 100644 --- a/Sources/EeveeSpotify/Helpers/WindowHelper.swift +++ b/Sources/EeveeSpotify/Helpers/WindowHelper.swift @@ -23,7 +23,7 @@ class WindowHelper { func searchViews(_ view: UIView) { if let viewController = self.viewController(for: view) { - if String(describing: type(of: viewController)) ~= regex { + if NSStringFromClass(type(of: viewController)) ~= regex { result = viewController return } diff --git a/Sources/EeveeSpotify/Lyrics/Repositories/LrclibLyricsRepository.swift b/Sources/EeveeSpotify/Lyrics/Repositories/LrclibLyricsRepository.swift index 434eb4f4..5a6813c4 100644 --- a/Sources/EeveeSpotify/Lyrics/Repositories/LrclibLyricsRepository.swift +++ b/Sources/EeveeSpotify/Lyrics/Repositories/LrclibLyricsRepository.swift @@ -114,9 +114,10 @@ struct LrcLibLyricsRepository: LyricsRepository { } return LyricsDto( - lines: plainLyrics.components(separatedBy: "\n").dropLast().map { content in - LyricsLineDto(content: content) - }, + lines: plainLyrics + .components(separatedBy: "\n") + .dropLast() + .map { content in LyricsLineDto(content: content) }, timeSynced: false ) } diff --git a/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift new file mode 100644 index 00000000..075260ea --- /dev/null +++ b/Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift @@ -0,0 +1,16 @@ +import UIKit + +extension UIView { + func hasParent(_ regex: String) -> Bool { + guard let parent = self.superview else { + return false + } + + let parentClassName = NSStringFromClass(type(of: parent)) + if parentClassName ~= regex { + return true + } else { + return parent.hasParent(regex) + } + } +} diff --git a/Sources/EeveeSpotify/Premium/ServerSidedReminder.x.swift b/Sources/EeveeSpotify/Premium/ServerSidedReminder.x.swift index 9e8021e0..5393e5f6 100644 --- a/Sources/EeveeSpotify/Premium/ServerSidedReminder.x.swift +++ b/Sources/EeveeSpotify/Premium/ServerSidedReminder.x.swift @@ -46,11 +46,10 @@ class UIButtonHook: ClassHook { if highlighted { - if let identifier = target.accessibilityIdentifier, identifier.contains("DownloadButton") { + if let identifier = target.accessibilityIdentifier, identifier.contains("DownloadButton"), + let viewController = WindowHelper.shared.viewController(for: target) { - let vcDescription = String(describing: WindowHelper.shared.viewController(for: target)) - - if !(vcDescription ~= "Podcast|CreativeWorkPlatform") { + if !(NSStringFromClass(type(of: viewController)) ~= "Podcast|CreativeWorkPlatform") { target.removeTarget(nil, action: nil, for: .allEvents) showOfflineModePopUp()