This commit is contained in:
eevee
2024-06-30 09:34:53 +03:00
parent e8e77f07cf
commit e153fff66e
5 changed files with 58 additions and 14 deletions

View File

@@ -16,8 +16,16 @@ class EncoreLabelHook: ClassHook<UIView> {
) ~= "SPTEncorePopUpContainer" {
let label = Dynamic.convert(target.subviews.first!, to: UILabel.self)
let superview: UIView?
if #available(iOS 15.0, *) {
superview = target.superview?.superview?.superview?.superview
} else {
superview = target.superview?.superview?.superview
}
if !(String(describing: target.superview?.superview?.superview?.superview) ~= "Primary") {
if !(String(describing: superview) ~= "Primary") {
label.textColor = .white
}
}

View File

@@ -38,8 +38,14 @@ private var hasShownUnauthorizedPopUp = false
//
class LyricsOnlyViewControllerHook: ClassHook<UIViewController> {
static let targetName = "Lyrics_NPVCommunicatorImpl.LyricsOnlyViewController"
static var targetName: String {
if #available(iOS 15.0, *) {
"Lyrics_NPVCommunicatorImpl.LyricsOnlyViewController"
} else {
"Lyrics_CoreImpl.LyricsOnlyViewController"
}
}
func viewDidLoad() {
@@ -50,20 +56,32 @@ class LyricsOnlyViewControllerHook: ClassHook<UIViewController> {
}
guard
let lyricsHeaderViewController = target.parent?.children.first,
let lyricsLabel = lyricsHeaderViewController.view.subviews.first
let lyricsHeaderViewController = target.parent?.children.first
else {
return
}
//
let lyricsLabel: UIView?
if #available(iOS 15.0, *) {
lyricsLabel = lyricsHeaderViewController.view.subviews.first
} else {
lyricsLabel = lyricsHeaderViewController.view.subviews.first?.subviews.first
}
guard let lyricsLabel = lyricsLabel else {
return
}
//
let encoreLabel = Dynamic.convert(lyricsLabel, to: SPTEncoreLabel.self)
let attributedString = Dynamic.convert(
encoreLabel.text().firstObject as AnyObject,
to: SPTEncoreAttributedString.self
)
var text = [attributedString]
var text = [
encoreLabel.text().firstObject
]
if let description = lastLyricsError?.description {
@@ -73,14 +91,22 @@ class LyricsOnlyViewControllerHook: ClassHook<UIViewController> {
attributes.setForegroundColor(.white.withAlphaComponent(0.5))
})
let typeStyle = type(
of: Dynamic.SPTEncoreTypeStyle.alloc(interface: SPTEncoreTypeStyle.self)
).bodyMediumBold()
text.append(
Dynamic.SPTEncoreAttributedString.alloc(interface: SPTEncoreAttributedString.self)
.initWithString(
"\nFallback: \(description)",
typeStyle: attributedString.typeStyle(),
typeStyle: typeStyle,
attributes: attributes
)
)
if #unavailable(iOS 15.0) {
encoreLabel.setNumberOfLines(2)
}
}
encoreLabel.setText(text as NSArray)

View File

@@ -1,8 +1,12 @@
import Foundation
@objc protocol SPTEncoreAttributedString {
func initWithString(_ string: String, typeStyle: Any, attributes: Any) -> SPTEncoreAttributedString
func initWithString(_ string: String, typeStyle: SPTEncoreTypeStyle, attributes: SPTEncoreAttributes) -> SPTEncoreAttributedString
func text() -> String
func typeStyle() -> Any
@available(iOS 15.0, *)
func typeStyle() -> SPTEncoreTypeStyle
@available(iOS 15.0, *)
func attributes() -> SPTEncoreAttributes
}

View File

@@ -2,5 +2,6 @@ import Foundation
@objc protocol SPTEncoreLabel {
func text() -> NSArray
func setNumberOfLines(_ number: Int)
func setText(_ text: NSArray)
}

View File

@@ -0,0 +1,5 @@
import Foundation
@objc protocol SPTEncoreTypeStyle {
static func bodyMediumBold() -> SPTEncoreTypeStyle
}