mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
local files lyrics background color
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import Orion
|
||||
import UIKit
|
||||
|
||||
class HookedInstances {
|
||||
static var productState: SPTCoreProductState?
|
||||
static var currentTrack: SPTPlayerTrack?
|
||||
static var nowPlayingMetaBackgroundModel: SPTNowPlayingMetadataBackgroundViewModel?
|
||||
}
|
||||
|
||||
class SPTNowPlayingModelHook: ClassHook<NSObject> {
|
||||
|
||||
static let targetName = "SPTNowPlayingModel"
|
||||
|
||||
func currentTrack() -> SPTPlayerTrack? {
|
||||
|
||||
if let track = orig.currentTrack() {
|
||||
HookedInstances.currentTrack = track
|
||||
return track
|
||||
@@ -20,12 +20,22 @@ class SPTNowPlayingModelHook: ClassHook<NSObject> {
|
||||
}
|
||||
}
|
||||
|
||||
class SPTCoreProductStateInstanceHook: ClassHook<NSObject> {
|
||||
class SPTNowPlayingMetadataBackgroundViewModelHook: ClassHook<NSObject> {
|
||||
static let targetName = "SPTNowPlayingMetadataBackgroundViewModel"
|
||||
|
||||
func color() -> UIColor {
|
||||
HookedInstances.nowPlayingMetaBackgroundModel = Dynamic.convert(
|
||||
target,
|
||||
to: SPTNowPlayingMetadataBackgroundViewModel.self
|
||||
)
|
||||
return orig.color()
|
||||
}
|
||||
}
|
||||
|
||||
class SPTCoreProductStateInstanceHook: ClassHook<NSObject> {
|
||||
static let targetName = "SPTCoreProductState"
|
||||
|
||||
func stringForKey(_ key: String) -> NSString {
|
||||
|
||||
HookedInstances.productState = Dynamic.convert(
|
||||
target,
|
||||
to: SPTCoreProductState.self
|
||||
|
||||
@@ -259,12 +259,21 @@ func getLyricsForCurrentTrack(originalLyrics: Lyrics? = nil) throws -> Data {
|
||||
lyrics.colors = originalLyrics.colors
|
||||
}
|
||||
else {
|
||||
var color: Color?
|
||||
|
||||
if let extractedColorHex = track.extractedColorHex() {
|
||||
color = Color(hex: extractedColorHex)
|
||||
}
|
||||
else if let uiColor = HookedInstances.nowPlayingMetaBackgroundModel?.color() {
|
||||
color = Color(uiColor)
|
||||
}
|
||||
|
||||
color = color?.normalized(lyricsColorsSettings.normalizationFactor)
|
||||
|
||||
lyrics.colors = LyricsColors.with {
|
||||
$0.backgroundColor = lyricsColorsSettings.useStaticColor
|
||||
? Color(hex: lyricsColorsSettings.staticColor).uInt32
|
||||
: Color(hex: track.extractedColorHex())
|
||||
.normalized(lyricsColorsSettings.normalizationFactor)
|
||||
.uInt32
|
||||
: color?.uInt32 ?? Color.gray.uInt32
|
||||
$0.lineColor = Color.black.uInt32
|
||||
$0.activeLineColor = Color.white.uInt32
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import UIKit
|
||||
|
||||
@objc protocol SPTNowPlayingMetadataBackgroundViewModel {
|
||||
func color() -> UIColor
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import Foundation
|
||||
@objc protocol SPTPlayerTrack {
|
||||
func setMetadata(_ metadata: [String:String])
|
||||
func metadata() -> [String:String]
|
||||
func extractedColorHex() -> String
|
||||
func extractedColorHex() -> String?
|
||||
func trackTitle() -> String
|
||||
func artistTitle() -> String
|
||||
func URI() -> SPTURL
|
||||
|
||||
Reference in New Issue
Block a user