From 257983bae3263452ba20e89f151db44c07756df8 Mon Sep 17 00:00:00 2001 From: eevee Date: Thu, 11 Jul 2024 00:49:32 +0300 Subject: [PATCH] something --- .../EeveeSpotify/Lyrics/CustomLyrics.x.swift | 34 ++++++++----------- Sources/EeveeSpotify/Tweak.x.swift | 1 + 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift index da659090..20a3e688 100644 --- a/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift +++ b/Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift @@ -16,17 +16,17 @@ class SPTPlayerTrackHook: ClassHook { class LyricsFullscreenViewControllerHook: ClassHook { static var targetName: String { - if #available(iOS 15.0, *) { - "Lyrics_FullscreenPageImpl.FullscreenViewController" - } else { - "Lyrics_CoreImpl.FullscreenViewController" - } + return EeveeSpotify.isOldSpotifyVersion + ? "Lyrics_CoreImpl.FullscreenViewController" + : "Lyrics_FullscreenPageImpl.FullscreenViewController" } func viewDidLoad() { orig.viewDidLoad() - if UserDefaults.lyricsSource == .musixmatch { + if UserDefaults.lyricsSource == .musixmatch + && lastLyricsError == nil + && lastLyricsLanguageLabel == nil { return } @@ -51,11 +51,9 @@ private var hasShownUnauthorizedPopUp = false class LyricsOnlyViewControllerHook: ClassHook { static var targetName: String { - if #available(iOS 15.0, *) { - "Lyrics_NPVCommunicatorImpl.LyricsOnlyViewController" - } else { - "Lyrics_CoreImpl.LyricsOnlyViewController" - } + return EeveeSpotify.isOldSpotifyVersion + ? "Lyrics_CoreImpl.LyricsOnlyViewController" + : "Lyrics_NPVCommunicatorImpl.LyricsOnlyViewController" } func viewDidLoad() { @@ -70,14 +68,10 @@ class LyricsOnlyViewControllerHook: ClassHook { // - let lyricsLabel: UIView? - - if #available(iOS 15.0, *) { - lyricsLabel = lyricsHeaderViewController.view.subviews.first - } else { - lyricsLabel = lyricsHeaderViewController.view.subviews.first?.subviews.first - } - + let lyricsLabel = EeveeSpotify.isOldSpotifyVersion + ? lyricsHeaderViewController.view.subviews.first?.subviews.first + : lyricsHeaderViewController.view.subviews.first + guard let lyricsLabel = lyricsLabel else { return } @@ -124,7 +118,7 @@ class LyricsOnlyViewControllerHook: ClassHook { ) } - if #unavailable(iOS 15.0) { + if EeveeSpotify.isOldSpotifyVersion { encoreLabel.setNumberOfLines(text.count) } diff --git a/Sources/EeveeSpotify/Tweak.x.swift b/Sources/EeveeSpotify/Tweak.x.swift index 28c81210..c67aa5b5 100644 --- a/Sources/EeveeSpotify/Tweak.x.swift +++ b/Sources/EeveeSpotify/Tweak.x.swift @@ -12,6 +12,7 @@ func exitApplication() { struct EeveeSpotify: Tweak { static let version = "4.3" + static let isOldSpotifyVersion = NSClassFromString("Lyrics_NPVCommunicatorImpl.LyricsOnlyViewController") == nil init() {