fix lyrics crashes on 9.0.14

This commit is contained in:
eevee
2025-01-29 18:43:33 +03:00
parent 1c9cc0a812
commit fd1d634acd
2 changed files with 30 additions and 5 deletions
@@ -87,30 +87,52 @@ class LyricsOnlyViewControllerHook: ClassHook<UIViewController> {
})
let typeStyle = type(
of: Dynamic.SPTEncoreTypeStyle.alloc(interface: SPTEncoreTypeStyle.self)
of: Dynamic[
dynamicMember: EeveeSpotify.isOldSpotifyVersion
? "SPTEncoreTypeStyle"
: "SPTEncoreTextStyle"
].alloc(interface: SPTEncoreTypeStyle.self)
).bodyMediumBold()
//
if UserDefaults.fallbackReasons, let description = lastLyricsState.fallbackError?.description {
var attributedString = Dynamic.SPTEncoreAttributedString.alloc(
interface: SPTEncoreAttributedString.self
)
text.append(
Dynamic.SPTEncoreAttributedString.alloc(interface: SPTEncoreAttributedString.self)
.initWithString(
EeveeSpotify.isOldSpotifyVersion
? attributedString.initWithString(
"\n\("fallback_attribute".localized): \(description)",
typeStyle: typeStyle,
attributes: attributes
)
: attributedString.initWithString(
"\n\("fallback_attribute".localized): \(description)",
textStyle: typeStyle,
attributes: attributes
)
)
}
if lastLyricsState.wasRomanized {
var attributedString = Dynamic.SPTEncoreAttributedString.alloc(
interface: SPTEncoreAttributedString.self
)
text.append(
Dynamic.SPTEncoreAttributedString.alloc(interface: SPTEncoreAttributedString.self)
.initWithString(
EeveeSpotify.isOldSpotifyVersion
? attributedString.initWithString(
"\n\("romanized_attribute".localized)",
typeStyle: typeStyle,
attributes: attributes
)
: attributedString.initWithString(
"\n\("romanized_attribute".localized)",
textStyle: typeStyle,
attributes: attributes
)
)
}
@@ -2,6 +2,9 @@ import Foundation
@objc protocol SPTEncoreAttributedString {
func initWithString(_ string: String, typeStyle: SPTEncoreTypeStyle, attributes: SPTEncoreAttributes) -> SPTEncoreAttributedString
// new method since 9.0.14
func initWithString(_ string: String, textStyle: SPTEncoreTypeStyle, attributes: SPTEncoreAttributes) -> SPTEncoreAttributedString
func text() -> String
@available(iOS 15.0, *)