mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
ios 14
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@ import Foundation
|
||||
|
||||
@objc protocol SPTEncoreLabel {
|
||||
func text() -> NSArray
|
||||
func setNumberOfLines(_ number: Int)
|
||||
func setText(_ text: NSArray)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import Foundation
|
||||
|
||||
@objc protocol SPTEncoreTypeStyle {
|
||||
static func bodyMediumBold() -> SPTEncoreTypeStyle
|
||||
}
|
||||
Reference in New Issue
Block a user