Skip to content

Commit

Permalink
fix lyrics crashes on 9.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
whoeevee committed Jan 29, 2025
1 parent 1c9cc0a commit fd1d634
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
32 changes: 27 additions & 5 deletions Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, *)
Expand Down

0 comments on commit fd1d634

Please sign in to comment.